Clean up some code in core-text, and core-text.fonts
parent
221222cb8f
commit
11f509b0c7
|
@ -48,22 +48,28 @@ ERROR: not-a-string object ;
|
||||||
|
|
||||||
TUPLE: line font line metrics image loc dim disposed ;
|
TUPLE: line font line metrics image loc dim disposed ;
|
||||||
|
|
||||||
: compute-line-metrics ( open-font line -- line-metrics )
|
: typographic-bounds ( line -- width ascent descent leading )
|
||||||
[
|
|
||||||
[ metrics new ] dip
|
|
||||||
[ CTFontGetCapHeight >>cap-height ]
|
|
||||||
[ CTFontGetXHeight >>x-height ]
|
|
||||||
bi
|
|
||||||
] dip
|
|
||||||
0 <CGFloat> 0 <CGFloat> 0 <CGFloat>
|
0 <CGFloat> 0 <CGFloat> 0 <CGFloat>
|
||||||
[ CTLineGetTypographicBounds ] 3keep
|
[ CTLineGetTypographicBounds ] 3keep [ *CGFloat ] tri@ ; inline
|
||||||
|
|
||||||
|
: store-typographic-bounds ( metrics width ascent descent leading -- metrics )
|
||||||
{
|
{
|
||||||
[ >>width ]
|
[ >>width ]
|
||||||
[ *CGFloat >>ascent ]
|
[ >>ascent ]
|
||||||
[ *CGFloat >>descent ]
|
[ >>descent ]
|
||||||
[ *CGFloat >>leading ]
|
[ >>leading ]
|
||||||
} spread
|
} spread ; inline
|
||||||
dup compute-height ;
|
|
||||||
|
: compute-font-metrics ( metrics font -- metrics )
|
||||||
|
[ CTFontGetCapHeight >>cap-height ]
|
||||||
|
[ CTFontGetXHeight >>x-height ]
|
||||||
|
bi ; inline
|
||||||
|
|
||||||
|
: compute-line-metrics ( open-font line -- line-metrics )
|
||||||
|
[ metrics new ] 2dip
|
||||||
|
[ compute-font-metrics ]
|
||||||
|
[ typographic-bounds store-typographic-bounds ] bi*
|
||||||
|
compute-height ;
|
||||||
|
|
||||||
: metrics>dim ( bounds -- dim )
|
: metrics>dim ( bounds -- dim )
|
||||||
[ width>> ] [ [ ascent>> ] [ descent>> ] bi + ] bi
|
[ width>> ] [ [ ascent>> ] [ descent>> ] bi + ] bi
|
||||||
|
|
|
@ -118,7 +118,7 @@ MEMO: (cache-font-metrics) ( font -- metrics )
|
||||||
[ CTFontGetCapHeight >>cap-height ]
|
[ CTFontGetCapHeight >>cap-height ]
|
||||||
[ CTFontGetXHeight >>x-height ]
|
[ CTFontGetXHeight >>x-height ]
|
||||||
} cleave
|
} cleave
|
||||||
dup compute-height ;
|
compute-height ;
|
||||||
|
|
||||||
: cache-font-metrics ( font -- metrics )
|
: cache-font-metrics ( font -- metrics )
|
||||||
strip-font-colors (cache-font-metrics) ;
|
strip-font-colors (cache-font-metrics) ;
|
||||||
|
|
|
@ -60,8 +60,8 @@ italic?
|
||||||
|
|
||||||
TUPLE: metrics width ascent descent height leading cap-height x-height ;
|
TUPLE: metrics width ascent descent height leading cap-height x-height ;
|
||||||
|
|
||||||
: compute-height ( metrics -- )
|
: compute-height ( metrics -- metrics )
|
||||||
dup [ ascent>> ] [ descent>> ] bi + >>height drop ;
|
dup [ ascent>> ] [ descent>> ] bi + >>height ; inline
|
||||||
|
|
||||||
TUPLE: selection string start end color ;
|
TUPLE: selection string start end color ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue