Move fonts to basis/bitstream-vera
Use ui.cocoa.text instead of ui.freetype on Mac OS X Update deploy tool to not copy fonts/ directory on Mac OS Xdb4
parent
e6e831c577
commit
25b0512fd6
|
@ -10,6 +10,4 @@ IN: bootstrap.ui
|
|||
{ [ os unix? ] [ "x11" ] }
|
||||
} cond
|
||||
] unless* "ui." prepend require
|
||||
|
||||
"ui.freetype" require
|
||||
] when
|
||||
|
|
|
@ -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 >>
|
||||
|
|
|
@ -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 {
|
||||
nip
|
||||
[ copy-dll ]
|
||||
[ copy-freetype ]
|
||||
[ copy-nib ]
|
||||
[ "Contents/Resources/" copy-fonts ]
|
||||
[ "Contents/Resources" append-path make-directories ]
|
||||
} cleave
|
||||
tri
|
||||
]
|
||||
[ create-app-plist ]
|
||||
[ "Contents/MacOS/" append-path "" copy-vm ] 2tri
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Slava Pestov
|
|
@ -0,0 +1 @@
|
|||
UI text rendering implementation using Mac OS X Core Text
|
|
@ -0,0 +1 @@
|
|||
unportable
|
|
@ -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
|
|
@ -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> ( 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 <line-texture> ] 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 <CGPoint> CTLineGetStringIndexForPosition ;
|
||||
|
||||
core-text-renderer font-renderer set-global
|
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
UI text rendering implementation based on FreeType
|
||||
UI text rendering implementation using FreeType
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
unportable
|
|
@ -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 )
|
||||
[
|
||||
|
|
|
@ -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 -- )
|
||||
|
|
|
@ -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." }
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue