diff --git a/fonts/Vera.ttf b/basis/bitstream-vera/Vera.ttf similarity index 100% rename from fonts/Vera.ttf rename to basis/bitstream-vera/Vera.ttf diff --git a/fonts/VeraBI.ttf b/basis/bitstream-vera/VeraBI.ttf similarity index 100% rename from fonts/VeraBI.ttf rename to basis/bitstream-vera/VeraBI.ttf diff --git a/fonts/VeraBd.ttf b/basis/bitstream-vera/VeraBd.ttf similarity index 100% rename from fonts/VeraBd.ttf rename to basis/bitstream-vera/VeraBd.ttf diff --git a/fonts/VeraIt.ttf b/basis/bitstream-vera/VeraIt.ttf similarity index 100% rename from fonts/VeraIt.ttf rename to basis/bitstream-vera/VeraIt.ttf diff --git a/fonts/VeraMoBI.ttf b/basis/bitstream-vera/VeraMoBI.ttf similarity index 100% rename from fonts/VeraMoBI.ttf rename to basis/bitstream-vera/VeraMoBI.ttf diff --git a/fonts/VeraMoBd.ttf b/basis/bitstream-vera/VeraMoBd.ttf similarity index 100% rename from fonts/VeraMoBd.ttf rename to basis/bitstream-vera/VeraMoBd.ttf diff --git a/fonts/VeraMoIt.ttf b/basis/bitstream-vera/VeraMoIt.ttf similarity index 100% rename from fonts/VeraMoIt.ttf rename to basis/bitstream-vera/VeraMoIt.ttf diff --git a/fonts/VeraMono.ttf b/basis/bitstream-vera/VeraMono.ttf similarity index 100% rename from fonts/VeraMono.ttf rename to basis/bitstream-vera/VeraMono.ttf diff --git a/fonts/VeraSe.ttf b/basis/bitstream-vera/VeraSe.ttf similarity index 100% rename from fonts/VeraSe.ttf rename to basis/bitstream-vera/VeraSe.ttf diff --git a/fonts/VeraSeBd.ttf b/basis/bitstream-vera/VeraSeBd.ttf similarity index 100% rename from fonts/VeraSeBd.ttf rename to basis/bitstream-vera/VeraSeBd.ttf diff --git a/basis/bootstrap/ui/ui.factor b/basis/bootstrap/ui/ui.factor index 0cdf3137f6..7fc7499aa7 100644 --- a/basis/bootstrap/ui/ui.factor +++ b/basis/bootstrap/ui/ui.factor @@ -10,6 +10,4 @@ IN: bootstrap.ui { [ os unix? ] [ "x11" ] } } cond ] unless* "ui." prepend require - - "ui.freetype" require ] when diff --git a/basis/freetype/freetype.factor b/basis/freetype/freetype.factor index 683169e394..0134fa5dd8 100644 --- a/basis/freetype/freetype.factor +++ b/basis/freetype/freetype.factor @@ -4,7 +4,7 @@ USING: alien alien.syntax kernel system combinators ; IN: freetype << "freetype" { - { [ os macosx? ] [ "@executable_path/../Frameworks/libfreetype.6.dylib" "cdecl" add-library ] } + { [ os macosx? ] [ "libfreetype.6.dylib" "cdecl" add-library ] } { [ os windows? ] [ "freetype6.dll" "cdecl" add-library ] } { [ t ] [ drop ] } } cond >> diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index 91b4d603af..ede833d448 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2008 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: io io.files io.files.info.unix io.pathnames io.directories io.directories.hierarchy kernel namespaces make @@ -35,9 +35,6 @@ IN: tools.deploy.macosx : copy-dll ( bundle-name -- ) "Frameworks/libfactor.dylib" copy-bundle-dir ; -: copy-freetype ( bundle-name -- ) - deploy-ui? get [ "Frameworks" copy-bundle-dir ] [ drop ] if ; - : copy-nib ( bundle-name -- ) deploy-ui? get [ "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir @@ -45,13 +42,11 @@ IN: tools.deploy.macosx : create-app-dir ( vocab bundle-name -- vm ) [ - nip { - [ copy-dll ] - [ copy-freetype ] - [ copy-nib ] - [ "Contents/Resources/" copy-fonts ] - [ "Contents/Resources" append-path make-directories ] - } cleave + nip + [ copy-dll ] + [ copy-nib ] + [ "Contents/Resources" append-path make-directories ] + tri ] [ create-app-plist ] [ "Contents/MacOS/" append-path "" copy-vm ] 2tri diff --git a/basis/ui/cocoa/cocoa.factor b/basis/ui/cocoa/cocoa.factor index 7f9a8d5409..cce57a0aad 100755 --- a/basis/ui/cocoa/cocoa.factor +++ b/basis/ui/cocoa/cocoa.factor @@ -7,8 +7,8 @@ cocoa.windows cocoa.classes cocoa.nibs sequences system ui ui.backend ui.clipboards ui.gadgets ui.gadgets.worlds ui.cocoa.views core-foundation core-foundation.run-loop core-graphics.types threads math.geometry.rect fry libc -generalizations alien.c-types cocoa.views combinators -io.thread ; +generalizations alien.c-types cocoa.views ui.cocoa.text +combinators io.thread ; IN: ui.cocoa TUPLE: handle ; diff --git a/basis/ui/cocoa/text/authors.txt b/basis/ui/cocoa/text/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/ui/cocoa/text/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/basis/ui/cocoa/text/summary.txt b/basis/ui/cocoa/text/summary.txt new file mode 100644 index 0000000000..aa17c65ba1 --- /dev/null +++ b/basis/ui/cocoa/text/summary.txt @@ -0,0 +1 @@ +UI text rendering implementation using Mac OS X Core Text diff --git a/basis/ui/cocoa/text/tags.txt b/basis/ui/cocoa/text/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/ui/cocoa/text/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/ui/cocoa/text/text-tests.factor b/basis/ui/cocoa/text/text-tests.factor new file mode 100644 index 0000000000..4ad259aa0c --- /dev/null +++ b/basis/ui/cocoa/text/text-tests.factor @@ -0,0 +1,4 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test ui.cocoa.text ; +IN: ui.cocoa.text.tests diff --git a/basis/ui/cocoa/text/text.factor b/basis/ui/cocoa/text/text.factor new file mode 100644 index 0000000000..4e8d2aec70 --- /dev/null +++ b/basis/ui/cocoa/text/text.factor @@ -0,0 +1,60 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: assocs accessors alien core-graphics.types core-text kernel +namespaces sequences ui.gadgets.worlds ui.render opengl opengl.gl ; +IN: ui.cocoa.text + +SINGLETON: core-text-renderer + +CONSTANT: font-names + H{ + { "monospace" "Monaco" } + { "sans-serif" "Helvetica" } + { "serif" "Times" } + } + +USING: classes.algebra unicode.case.private ; + +: font-name/size ( font -- name size ) + [ first font-names at-default ] [ third ] bi ; + +M: core-text-renderer open-font + dup alien? [ font-name/size cached-font ] unless ; + +: string-dim ( open-font string -- dim ) + swap cached-line dim>> ; + +M: core-text-renderer string-width ( open-font string -- w ) + string-dim first ; + +M: core-text-renderer string-height ( open-font string -- h ) + [ " " ] when-empty string-dim second ; + +TUPLE: line-texture line texture age ; + +: ( line -- texture ) + dup [ dim>> ] [ bitmap>> ] bi GL_RGBA make-texture + 0 \ line-texture boa ; + +: line-texture ( string open-font -- texture ) + world get fonts>> [ cached-line ] 2cache ; + +: draw-line-texture ( line-texture -- ) + GL_TEXTURE_2D [ + GL_TEXTURE_BIT [ + GL_TEXTURE_COORD_ARRAY [ + GL_TEXTURE_2D over texture>> glBindTexture + init-texture rect-texture-coords + line>> dim>> fill-rect-vertices (gl-fill-rect) + GL_TEXTURE_2D 0 glBindTexture + ] do-enabled-client-state + ] do-attribs + ] do-enabled ; + +M: core-text-renderer draw-string ( font string loc -- ) + [ swap open-font line-texture draw-line-texture ] with-translation ; + +M: core-text-renderer x>offset ( x font string -- n ) + swap cached-line swap 0 CTLineGetStringIndexForPosition ; + +core-text-renderer font-renderer set-global \ No newline at end of file diff --git a/basis/ui/freetype/freetype.factor b/basis/ui/freetype/freetype.factor index e8debb6763..f993fc3feb 100644 --- a/basis/ui/freetype/freetype.factor +++ b/basis/ui/freetype/freetype.factor @@ -7,7 +7,7 @@ ui.gadgets.worlds ui.render ui.backend byte-arrays accessors locals specialized-arrays.direct.uchar ; IN: ui.freetype -TUPLE: freetype-renderer ; +SINGLETON: freetype-renderer SYMBOL: open-fonts @@ -61,7 +61,7 @@ M: freetype-renderer free-fonts ( world -- ) } at ; : ttf-path ( name -- string ) - "resource:fonts/" ".ttf" surround ; + "resource:basis/bitstream-vera/" ".ttf" surround ; : (open-face) ( path length -- face ) #! We use FT_New_Memory_Face, not FT_New_Face, since @@ -223,4 +223,4 @@ M: freetype-renderer x>offset ( x font string -- n ) [ run-char-widths [ <= ] with find drop ] keep swap [ ] [ length ] ?if ; -T{ freetype-renderer } font-renderer set-global +freetype-renderer font-renderer set-global diff --git a/basis/ui/freetype/summary.txt b/basis/ui/freetype/summary.txt index f7bfcac7b9..ba62d60e87 100644 --- a/basis/ui/freetype/summary.txt +++ b/basis/ui/freetype/summary.txt @@ -1 +1 @@ -UI text rendering implementation based on FreeType +UI text rendering implementation using FreeType diff --git a/basis/ui/freetype/tags.txt b/basis/ui/freetype/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/ui/freetype/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index 6d7199c77c..c748af7f29 100755 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -174,7 +174,7 @@ M: editor ungraft* line-translation gl-translate ; : draw-line ( editor str -- ) - [ font>> ] dip { 0 0 } draw-string ; + [ font>> ] dip { 0 0 } draw-text ; : first-visible-line ( editor -- n ) [ diff --git a/basis/ui/gadgets/tables/tables.factor b/basis/ui/gadgets/tables/tables.factor index e034b49f77..6940550995 100644 --- a/basis/ui/gadgets/tables/tables.factor +++ b/basis/ui/gadgets/tables/tables.factor @@ -142,7 +142,7 @@ M: table layout* : draw-column ( font column width align -- ) over [ - [ 2dup ] 2dip column-loc draw-string + [ 2dup ] 2dip column-loc draw-text ] dip table-gap + 0 2array gl-translate ; : draw-row ( columns widths align font -- ) diff --git a/basis/ui/gadgets/worlds/worlds-docs.factor b/basis/ui/gadgets/worlds/worlds-docs.factor index f4e63aa9e3..766bf32d32 100644 --- a/basis/ui/gadgets/worlds/worlds-docs.factor +++ b/basis/ui/gadgets/worlds/worlds-docs.factor @@ -39,7 +39,7 @@ HELP: world { { $snippet "status" } " - a " { $link model } " holding a string to be displayed in the world's status bar." } { { $snippet "focus" } " - the current owner of the keyboard focus in the world." } { { $snippet "focused?" } " - a boolean indicating if the native window containing the world has keyboard focus." } - { { $snippet "fonts" } " - a hashtable mapping font instances to vectors of " { $link sprite } " instances." } + { { $snippet "fonts" } " - a hashtable used by the " { $link font-renderer } "." } { { $snippet "handle" } " - a backend-specific native handle representing the native window containing the world, or " { $link f } " if the world is not grafted." } { { $snippet "window-loc" } " - the on-screen location of the native window containing the world. The co-ordinate system here is backend-specific." } } diff --git a/basis/ui/windows/windows.factor b/basis/ui/windows/windows.factor index a6e39000bf..dc096155d4 100755 --- a/basis/ui/windows/windows.factor +++ b/basis/ui/windows/windows.factor @@ -3,14 +3,14 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.strings arrays assocs ui ui.gadgets ui.backend ui.clipboards ui.gadgets.worlds -ui.gestures ui.event-loop io kernel math math.vectors namespaces -make sequences strings vectors words windows.kernel32 -windows.gdi32 windows.user32 windows.opengl32 windows.messages -windows.types windows.nt windows threads libc combinators fry -combinators.short-circuit continuations command-line shuffle -opengl ui.render ascii math.bitwise locals accessors -math.geometry.rect math.order ascii calendar io.encodings.utf16n -; +ui.gestures ui.event-loop ui.freetype io kernel math +math.vectors namespaces make sequences strings vectors words +windows.kernel32 windows.gdi32 windows.user32 windows.opengl32 +windows.messages windows.types windows.nt windows threads libc +combinators fry combinators.short-circuit continuations +command-line shuffle opengl ui.render ascii math.bitwise locals +accessors math.geometry.rect math.order ascii calendar +io.encodings.utf16n ; IN: ui.windows SINGLETON: windows-ui-backend diff --git a/basis/ui/x11/x11.factor b/basis/ui/x11/x11.factor index 1c31f0125b..8667a9f16e 100755 --- a/basis/ui/x11/x11.factor +++ b/basis/ui/x11/x11.factor @@ -2,10 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types arrays ui ui.gadgets ui.gestures ui.backend ui.clipboards ui.gadgets.worlds ui.render -ui.event-loop assocs kernel math namespaces opengl sequences -strings x11.xlib x11.events x11.xim x11.glx x11.clipboard -x11.constants x11.windows io.encodings.string io.encodings.ascii -io.encodings.utf8 combinators command-line +ui.event-loop ui.freetype assocs kernel math namespaces opengl +sequences strings x11.xlib x11.events x11.xim x11.glx +x11.clipboard x11.constants x11.windows io.encodings.string +io.encodings.ascii io.encodings.utf8 combinators command-line math.vectors classes.tuple opengl.gl threads math.geometry.rect environment ascii ; IN: ui.x11