]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/text/text-docs.factor
Add foreground and background color slots to font tuple
[factor.git] / basis / ui / text / text-docs.factor
1 IN: ui.text
2 USING: help.markup help.syntax kernel ui.text.private strings math fonts ;
3
4 HELP: string-width
5 { $values { "font" font } { "string" string } { "w" "a positive integer" } }
6 { $contract "Outputs the width of a string." }
7 { $notes "This is a low-level word; use " { $link text-width } " instead." } ;
8
9 HELP: text-width
10 { $values { "font" font } { "text" "a string or sequence of strings" } { "w" "a positive integer" } }
11 { $description "Outputs the width of a piece of text." } ;
12
13 HELP: string-height
14 { $values { "font" font } { "string" string } { "h" "a positive integer" } }
15 { $contract "Outputs the height of a string." }
16 { $notes "This is a low-level word; use " { $link text-height } " instead." } ;
17
18 HELP: text-height
19 { $values { "font" font } { "text" "a string or sequence of strings" } { "h" "a positive integer" } }
20 { $description "Outputs the height of a piece of text." } ;
21
22 HELP: string-dim
23 { $values { "font" font } { "string" string } { "dim" "a pair of integers" } }
24 { $contract "Outputs the dimensions of a string." }
25 { $notes "This is a low-level word; use " { $link text-dim } " instead." } ;
26
27 HELP: text-dim
28 { $values { "font" font } { "text" "a string or sequence of strings" } { "dim" "a pair of integers" } }
29 { $description "Outputs the dimensions of a piece of text, which is either a single-line string or an array of lines." } ;
30
31 HELP: draw-string
32 { $values { "font" font } { "string" string } { "loc" "a pair of integers" } }
33 { $contract "Draws a line of text." } ;
34
35 HELP: draw-text
36 { $values { "font" font } { "text" "a string or an array of strings" } { "loc" "a pair of integers" } }
37 { $description "Draws a piece of text." } ;
38
39 HELP: x>offset
40 { $values { "x" real } { "font" font } { "string" string } { "n" integer } }
41 { $contract "Outputs the string index closest to the given x co-ordinate." } ;
42
43 HELP: offset>x
44 { $values { "n" integer } { "font" font } { "string" string } { "x" real } }
45 { $contract "Outputs the x co-ordinate of the character at the given index." } ;
46
47 ARTICLE: "text-rendering" "Rendering text"
48 "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."
49 { $subsection "fonts" }
50 "Measuring text:"
51 { $subsection text-dim }
52 { $subsection text-width }
53 { $subsection text-height }
54 "Converting screen locations to string offsets, and vice versa:"
55 { $subsection x>offset }
56 { $subsection offset>x }
57 "Rendering text:"
58 { $subsection draw-text }
59 "Low-level text protocol for UI backends:"
60 { $subsection string-width }
61 { $subsection string-height }
62 { $subsection string-dim }
63 { $subsection draw-string } ;
64
65 ABOUT: "text-rendering"