1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: tools.test core-text core-text.fonts core-foundation
4 core-foundation.dictionaries destructors arrays kernel generalizations
5 locals math accessors core-foundation.utilities combinators hashtables colors
9 : test-font ( name -- font )
10 [ >cf &CFRelease 0.0 f CTFontCreateWithName ] with-destructors ;
12 { } [ "Helvetica" test-font CFRelease ] unit-test
16 kCTFontAttributeName "Helvetica" test-font &CFRelease 2array 1array
17 <CFDictionary> &CFRelease drop
21 :: test-typographic-bounds ( string font -- ? )
23 font test-font &CFRelease :> ctfont
24 string ctfont COLOR: white <CTLine> &CFRelease :> ctline
25 ctfont ctline compute-line-metrics {
33 { t } [ "Hello world" "Helvetica" test-typographic-bounds ] unit-test
35 { t } [ "Hello world" "Chicago" test-typographic-bounds ] unit-test
37 { t } [ "日本語" "Helvetica" test-typographic-bounds ] unit-test