factor/basis/core-text/core-text-tests.factor

36 lines
1.1 KiB
Factor
Raw Normal View History

2009-01-16 20:11:48 -05:00
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2009-01-16 23:48:07 -05:00
USING: tools.test core-text core-foundation
core-foundation.dictionaries destructors
2009-01-19 23:30:32 -05:00
arrays kernel generalizations math accessors
combinators hashtables ;
2009-01-16 20:11:48 -05:00
IN: core-text.tests
: test-font ( name -- object )
kCTFontFamilyNameAttribute associate <CTFont> ;
2009-01-19 23:30:32 -05:00
[ ] [ "Helvetica" test-font CFRelease ] unit-test
2009-01-16 23:48:07 -05:00
[ ] [
[
kCTFontAttributeName "Helvetica" test-font &CFRelease 2array 1array
2009-01-16 23:48:07 -05:00
<CFDictionary> &CFRelease drop
] with-destructors
2009-01-19 23:30:32 -05:00
] unit-test
: test-typographic-bounds ( string font -- ? )
2009-01-19 23:30:32 -05:00
[
test-font &CFRelease <CTLine> &CFRelease
line-typographic-bounds {
[ width>> float? ]
[ ascent>> float? ]
[ descent>> float? ]
[ leading>> float? ]
} cleave and and and
] with-destructors ;
[ t ] [ "Hello world" "Helvetica" test-typographic-bounds ] unit-test
2009-01-19 23:30:32 -05:00
[ t ] [ "Hello world" "Chicago" test-typographic-bounds ] unit-test
[ t ] [ "日本語" "Helvetica" test-typographic-bounds ] unit-test