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
|
2009-01-21 00:06:23 -05:00
|
|
|
combinators hashtables ;
|
2009-01-16 20:11:48 -05:00
|
|
|
IN: core-text.tests
|
2009-01-16 23:37:56 -05:00
|
|
|
|
2009-01-19 23:30:32 -05:00
|
|
|
: test-font ( -- object )
|
2009-01-21 00:06:23 -05:00
|
|
|
"Helvetica" kCTFontNameAttribute associate <CTFont> ;
|
2009-01-19 23:30:32 -05:00
|
|
|
|
|
|
|
[ ] [ test-font CFRelease ] unit-test
|
2009-01-16 23:48:07 -05:00
|
|
|
|
|
|
|
[ ] [
|
|
|
|
[
|
2009-01-19 23:30:32 -05:00
|
|
|
kCTFontAttributeName 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 -- ? )
|
|
|
|
[
|
|
|
|
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" test-typographic-bounds ] unit-test
|
|
|
|
|
|
|
|
[ t ] [ "日本語" test-typographic-bounds ] unit-test
|