]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/text/text-docs.factor
8005c778d8e6718fcd9a4990671cc7e3099f0b56
[factor.git] / basis / ui / text / text-docs.factor
1 IN: ui.text
2 USING: help.markup help.syntax kernel ui.text.private strings math ;
3
4 HELP: open-font
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." } ;
9
10 HELP: string-width
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." } ;
14
15 HELP: text-width
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." } ;
18
19 HELP: string-height
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." } ;
23
24 HELP: text-height
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." } ;
27
28 HELP: string-dim
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." } ;
32
33 HELP: text-dim
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." } ;
36
37 HELP: draw-string
38 { $values { "font" font } { "string" string } { "loc" "a pair of integers" } }
39 { $contract "Draws a line of text." } ;
40
41 HELP: draw-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." } ;
44
45 HELP: x>offset
46 { $values { "x" real } { "font" font } { "string" string } { "n" integer } }
47 { $contract "Outputs the string index closest to the given x co-ordinate." } ;
48
49 HELP: offset>x
50 { $values { "n" integer } { "font" font } { "string" string } { "x" real } }
51 { $contract "Outputs the x co-ordinate of the character at the given index." } ;
52
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."
55 $nl
56 "Measuring text:"
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 }
63 "Rendering text:"
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 } ;
71
72 ABOUT: "text-rendering"