CTLineCreateWithAttributedString
] with-destructors ;
-TUPLE: line line metrics image loc dim disposed ;
+TUPLE: line < disposable line metrics image loc dim ;
: typographic-bounds ( line -- width ascent descent leading )
0 <CGFloat> 0 <CGFloat> 0 <CGFloat>
:: <line> ( font string -- line )
[
+ line new-disposable
+
[let* | open-font [ font cache-font ]
line [ string open-font font foreground>> <CTLine> |CFRelease ]
ext [ (loc) (dim) [ + ceiling ] 2map ]
dim [ ext loc [ - >integer ] 2map ]
metrics [ open-font line compute-line-metrics ] |
- line metrics
+
+ line >>line
+
+ metrics >>metrics
+
dim [
{
[ font dim fill-background ]
[ loc set-text-position ]
[ [ line ] dip CTLineDraw ]
} cleave
- ] make-bitmap-image
- metrics loc dim line-loc
- metrics metrics>dim
+ ] make-bitmap-image >>image
+
+ metrics loc dim line-loc >>loc
+
+ metrics metrics>dim >>dim
]
- f line boa
] with-destructors ;
M: line dispose* line>> CFRelease ;