2 USING: help.markup help.syntax kernel ui.text.private strings math ;
5 { $values { "font" font } { "open-font" object } }
6 { $contract "Loads a font if it has not already been loaded, otherwise outputs the existing font." }
7 { $errors "Throws an error if the font does not exist." }
8 { $notes "This word should not be called by user code. All high-level text rendering words will call " { $link open-font } " automatically." } ;
11 { $values { "open-font" "a value output by " { $link open-font } } { "string" string } { "w" "a positive integer" } }
12 { $contract "Outputs the width of a string." }
13 { $notes "This is a low-level word; use " { $link text-width } " instead." } ;
16 { $values { "font" font } { "text" "a string or sequence of strings" } { "w" "a positive integer" } }
17 { $description "Outputs the width of a piece of text." } ;
20 { $values { "open-font" "a value output by " { $link open-font } } { "string" string } { "h" "a positive integer" } }
21 { $contract "Outputs the height of a string." }
22 { $notes "This is a low-level word; use " { $link text-height } " instead." } ;
25 { $values { "font" font } { "text" "a string or sequence of strings" } { "h" "a positive integer" } }
26 { $description "Outputs the height of a piece of text." } ;
29 { $values { "open-font" "a value output by " { $link open-font } } { "string" string } { "dim" "a pair of integers" } }
30 { $contract "Outputs the dimensions of a string." }
31 { $notes "This is a low-level word; use " { $link text-dim } " instead." } ;
34 { $values { "font" font } { "text" "a string or sequence of strings" } { "dim" "a pair of integers" } }
35 { $description "Outputs the dimensions of a piece of text, which is either a single-line string or an array of lines." } ;
38 { $values { "font" font } { "string" string } { "loc" "a pair of integers" } }
39 { $contract "Draws a line of text." } ;
42 { $values { "font" font } { "text" "a string or an array of strings" } { "loc" "a pair of integers" } }
43 { $description "Draws a piece of text." } ;
46 { $values { "x" real } { "font" font } { "string" string } { "n" integer } }
47 { $contract "Outputs the string index closest to the given x co-ordinate." } ;
50 { $values { "n" integer } { "font" font } { "string" string } { "x" real } }
51 { $contract "Outputs the x co-ordinate of the character at the given index." } ;
53 ARTICLE: "text-rendering" "Rendering text"
54 "The " { $vocab-link "ui.text" } " vocabulary provides a cross-platform interface to the operating system's native font rendering engine. Currently, it uses Core Text on Mac OS X and FreeType on Windows and X11."
57 { $subsection text-dim }
58 { $subsection text-width }
59 { $subsection text-height }
60 "Converting screen locations to string offsets, and vice versa:"
61 { $subsection x>offset }
62 { $subsection offset>x }
64 { $subsection draw-text }
65 "Low-level text protocol for UI backends:"
66 { $subsection open-font }
67 { $subsection string-width }
68 { $subsection string-height }
69 { $subsection string-dim }
70 { $subsection draw-string } ;
72 ABOUT: "text-rendering"