Merge branch 'master' of factorcode.org:/git/factor

db4
Joe Groff 2011-08-27 18:03:17 -07:00
commit 3d2f731aab
4 changed files with 31 additions and 14 deletions

View File

@ -47,7 +47,10 @@ ERROR: not-a-string object ;
CTLineCreateWithAttributedString CTLineCreateWithAttributedString
] with-destructors ; ] with-destructors ;
TUPLE: line < disposable line metrics image loc dim ; TUPLE: line < disposable line metrics image loc dim rendered-line ;
TUPLE: rendered-line font string loc dim ;
C: <rendered-line> rendered-line
: typographic-bounds ( line -- width ascent descent leading ) : typographic-bounds ( line -- width ascent descent leading )
{ CGFloat CGFloat CGFloat } { CGFloat CGFloat CGFloat }
@ -126,22 +129,34 @@ TUPLE: line < disposable line metrics image loc dim ;
line >>line line >>line
metrics >>metrics font string loc dim <rendered-line> >>rendered-line
dim [ metrics >>metrics
{
[ font dim fill-background ]
[ loc dim line string fill-selection-background ]
[ loc set-text-position ]
[ [ line ] dip CTLineDraw ]
} cleave
] make-bitmap-image >>image
metrics loc dim line-loc >>loc metrics loc dim line-loc >>loc
metrics metrics>dim >>dim metrics metrics>dim >>dim
] with-destructors ; ] with-destructors ;
:: render ( line -- line image )
line line>> :> ctline
line rendered-line>> string>> :> string
line rendered-line>> font>> :> font
line rendered-line>> loc>> :> loc
line rendered-line>> dim>> :> dim
line dim [
{
[ font dim fill-background ]
[ loc dim ctline string fill-selection-background ]
[ loc set-text-position ]
[ [ ctline ] dip CTLineDraw ]
} cleave
] make-bitmap-image ;
: line>image ( line -- image )
dup image>> [ render >>image ] unless image>> ;
M: line dispose* line>> CFRelease ; M: line dispose* line>> CFRelease ;
SYMBOL: cached-lines SYMBOL: cached-lines

View File

@ -18,7 +18,7 @@ M: core-text-renderer flush-layout-cache
cached-lines get purge-cache ; cached-lines get purge-cache ;
M: core-text-renderer string>image ( font string -- image loc ) M: core-text-renderer string>image ( font string -- image loc )
cached-line [ image>> ] [ loc>> ] bi ; cached-line [ line>image ] [ loc>> ] bi ;
M: core-text-renderer x>offset ( x font string -- n ) M: core-text-renderer x>offset ( x font string -- n )
[ 2drop 0 ] [ [ 2drop 0 ] [

View File

@ -6,6 +6,7 @@ fry io kernel literals math prettyprint sequences splitting
system memoize graphviz ; system memoize graphviz ;
IN: graphviz.ffi IN: graphviz.ffi
<<
"libgraph" { "libgraph" {
{ [ os macosx? ] [ "libgraph.dylib" ] } { [ os macosx? ] [ "libgraph.dylib" ] }
{ [ os unix? ] [ "libgraph.so" ] } { [ os unix? ] [ "libgraph.so" ] }
@ -18,6 +19,7 @@ IN: graphviz.ffi
{ [ os unix? ] [ "libgvc.so" ] } { [ os unix? ] [ "libgvc.so" ] }
{ [ os winnt? ] [ "gvc.dll" ] } { [ os winnt? ] [ "gvc.dll" ] }
} cond cdecl add-library } cond cdecl add-library
>>
LIBRARY: libgraph LIBRARY: libgraph

View File

@ -110,7 +110,7 @@ PRIVATE>
<PRIVATE <PRIVATE
: define-graphviz-by-engine ( -K -- ) : define-graphviz-by-engine ( -K -- )
[ create-in dup make-inline ] [ "graphviz.render" create dup make-inline ]
[ [ graphviz ] curry ] bi [ [ graphviz ] curry ] bi
(( graph -O -T -- )) (( graph -O -T -- ))
define-declared ; define-declared ;
@ -118,7 +118,7 @@ PRIVATE>
: define-graphviz-by-format ( -T -- ) : define-graphviz-by-format ( -T -- )
[ [
dup supported-engines member? [ "-file" append ] when dup supported-engines member? [ "-file" append ] when
create-in dup make-inline "graphviz.render" create dup make-inline
] ]
[ [ graphviz* ] curry ] bi [ [ graphviz* ] curry ] bi
(( graph -O -- )) (( graph -O -- ))