]> gitweb.factorcode.org Git - factor.git/commitdiff
core-text: cache attribute assoc.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 1 Aug 2012 05:03:32 +0000 (22:03 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 1 Aug 2012 05:03:32 +0000 (22:03 -0700)
basis/core-text/core-text.factor

index b23546a74b656fbc0355ba79c34af1340e63ca6a..ad25e3adb00426e09ed3ba02dbc7a8bcc7fe35dc 100644 (file)
@@ -34,16 +34,19 @@ FUNCTION: CGRect CTLineGetImageBounds ( CTLineRef line, CGContextRef context ) ;
 
 ERROR: not-a-string object ;
 
+MEMO: make-attributes ( open-font color -- hashtable )
+    [
+        kCTForegroundColorAttributeName ,,
+        kCTFontAttributeName ,,
+    ] H{ } make ;
+
 : <CTLine> ( string open-font color -- line )
     [
         [
             dup selection? [ string>> ] when
             dup string? [ not-a-string ] unless
         ] 2dip
-        [
-            kCTForegroundColorAttributeName ,,
-            kCTFontAttributeName ,,
-        ] H{ } make <CFAttributedString> &CFRelease
+        make-attributes <CFAttributedString> &CFRelease
         CTLineCreateWithAttributedString
     ] with-destructors ;