diff --git a/basis/freetype/freetype.factor b/basis/freetype/freetype.factor index 0134fa5dd8..06c875b2fa 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? ] [ "libfreetype.6.dylib" "cdecl" add-library ] } + { [ os macosx? ] [ "/usr/X11R6/lib/libfreetype.6.dylib" "cdecl" add-library ] } { [ os windows? ] [ "freetype6.dll" "cdecl" add-library ] } { [ t ] [ drop ] } } cond >> diff --git a/basis/ui/text/freetype/freetype-docs.factor b/basis/ui/text/freetype/freetype-docs.factor index c3ee2357a8..d8e18cfe42 100644 --- a/basis/ui/text/freetype/freetype-docs.factor +++ b/basis/ui/text/freetype/freetype-docs.factor @@ -1,5 +1,6 @@ USING: help.syntax help.markup strings kernel alien opengl -opengl.sprites quotations ui.render freetype ; +opengl.sprites quotations ui.render ui.text ui.text.private +freetype ; IN: ui.text.freetype HELP: freetype @@ -7,52 +8,21 @@ HELP: freetype { $description "Outputs a native handle used by the FreeType library, initializing FreeType first if necessary." } ; HELP: open-fonts -{ $var-description "Global variable. Hashtable mapping font descriptors to " { $link font } " instances." } ; - -{ font open-fonts open-font char-width string-width text-dim draw-string draw-text } related-words +{ $var-description "Global variable. Hashtable mapping font descriptors to " { $link freetype-font } " instances." } ; HELP: init-freetype { $description "Initializes the FreeType library." } { $notes "Do not call this word if you are using the UI." } ; -HELP: font - -{ $class-description - -"A font which has been loaded by FreeType. Font instances have the following slots:" - -{ - $list - { - { $snippet "ascent" } ", " - { $snippet "descent" } ", " - { $snippet "height" } " - metrics." - } - - { - { $snippet "handle" } - " - alien pointer to an " - { $snippet "FT_Face" } "." - } - - { - { $snippet "widths" } - " - sequence of character widths. Use " - { $snippet "width" } - " and " - { $snippet "width" } - " to compute string widths instead of reading this sequence directly." - } -} - -} ; +HELP: freetype-font +{ $class-description "A font which has been loaded by FreeType." } ; HELP: close-freetype { $description "Closes the FreeType library." } { $notes "Do not call this word if you are using the UI." } ; HELP: open-face -{ $values { "font" string } { "style" "one of " { $link plain } ", " { $link bold } ", " { $link italic } " or " { $link bold-italic } } { "face" "alien pointer to an " { $snippet "FT_Face" } } } +{ $values { "font" font } { "face" "alien pointer to an " { $snippet "FT_Face" } } } { $description "Loads a TrueType font with the requested logical font name and style." } { $notes "This is a low-level word. Call " { $link open-font } " instead." } ; diff --git a/basis/ui/text/freetype/freetype.factor b/basis/ui/text/freetype/freetype.factor index 87283f5ddd..b02032dcf0 100644 --- a/basis/ui/text/freetype/freetype.factor +++ b/basis/ui/text/freetype/freetype.factor @@ -45,7 +45,7 @@ M: freetype-renderer free-fonts ( world -- ) values [ second free-sprites ] each ; : ttf-name ( font -- name ) - [ [ name>> ] [ bold>> ] [ italic>> ] tri ] output>array H{ + [ [ name>> ] [ bold?>> ] [ italic?>> ] tri ] output>array H{ { { "monospace" f f } "VeraMono" } { { "monospace" t f } "VeraMoBd" } { { "monospace" t t } "VeraMoBI" } @@ -71,7 +71,7 @@ M: freetype-renderer free-fonts ( world -- ) FT_New_Memory_Face freetype-error ] keep *void* ; -: open-face ( font style -- face ) +: open-face ( font -- face ) ttf-name ttf-path malloc-file-contents (open-face) ; SYMBOL: dpi @@ -108,7 +108,7 @@ SYMBOL: dpi init-font ; M: freetype-renderer open-font ( font -- open-font ) - dup font? [ + dup freetype-font? [ freetype drop open-fonts get [ ] cache ] unless ; @@ -122,7 +122,7 @@ M: freetype-renderer open-font ( font -- open-font ) ] cache nip ; M: freetype-renderer string-width ( open-font string -- w ) - [ 0 ] 2dip [ char-width + ] with each ; + [ [ 0 ] dip ] dip [ char-width + ] with each ; M: freetype-renderer string-height ( open-font string -- h ) drop height>> ;