     compute-height ;
 
 : cache-font-metrics ( font -- metrics )
-    strip-font-colors (cache-font-metrics) ;
+    [ name>> ] [ size>> ] [ font-traits ] tri (cache-font-metrics) ;
 
 [
     \ (cache-font) reset-memoized

! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.syntax assocs core-foundation
core-foundation.dictionaries core-foundation.strings
core-graphics.types destructors init
kernel math memoize fonts combinators unix.types ;
IN: core-text.fonts

TYPEDEF: void* CTFontRef

: font-name ( string -- string' )
    font-names ?at drop ;

: font-traits ( font -- n )
    [ 0 ] dip
    [ bold?>> [ kCTFontBoldTrait bitor ] when ]
    [ italic?>> [ kCTFontItalicTrait bitor ] when ] bi ;

MEMO:: (cache-font) ( name size traits -- open-font )
    [
        name font-name <CFString> &CFRelease
        size f CTFontCreateWithName dup
        0.0 f traits dup CTFontCreateCopyWithSymbolicTraits
        [ [ CFRelease ] dip ] when*
    ] with-destructors ;

: cache-font ( font -- open-font )
    [ name>> ] [ size>> ] [ font-traits ] tri (cache-font) ;

MEMO: (cache-font-metrics) ( name size traits -- metrics )
    [ metrics new ] 3dip
    (cache-font) {
        [ CTFontGetAscent >>ascent ]
        [ CTFontGetDescent >>descent ]
