docs
This commit is contained in:
parent
84dd01fd00
commit
43e80a70ab
2 changed files with 49 additions and 8 deletions
|
@ -339,7 +339,15 @@ proc fillText*(
|
||||||
wrap = true,
|
wrap = true,
|
||||||
kerning = true
|
kerning = true
|
||||||
) =
|
) =
|
||||||
for _, path in font.typeset(
|
## Typesets and fills the text. Optional parameters:
|
||||||
|
## transform: translation or matrix to apply
|
||||||
|
## bounds: width determines wrapping and halign, height for valign
|
||||||
|
## hAlign: horizontal alignment of the text
|
||||||
|
## vAlign: vertical alignment of the text
|
||||||
|
## textCase: text character case
|
||||||
|
## wrap: enable/disable text wrapping
|
||||||
|
## kerning: enable/disable kerning adjustments to letter spacing
|
||||||
|
for path in font.typeset(
|
||||||
text,
|
text,
|
||||||
bounds,
|
bounds,
|
||||||
hAlign,
|
hAlign,
|
||||||
|
@ -362,7 +370,15 @@ proc fillText*(
|
||||||
wrap = true,
|
wrap = true,
|
||||||
kerning = true
|
kerning = true
|
||||||
) =
|
) =
|
||||||
for _, path in font.typeset(
|
## Typesets and fills the text. Optional parameters:
|
||||||
|
## transform: translation or matrix to apply
|
||||||
|
## bounds: width determines wrapping and halign, height for valign
|
||||||
|
## hAlign: horizontal alignment of the text
|
||||||
|
## vAlign: vertical alignment of the text
|
||||||
|
## textCase: text character case
|
||||||
|
## wrap: enable/disable text wrapping
|
||||||
|
## kerning: enable/disable kerning adjustments to letter spacing
|
||||||
|
for path in font.typeset(
|
||||||
text,
|
text,
|
||||||
bounds,
|
bounds,
|
||||||
hAlign,
|
hAlign,
|
||||||
|
@ -387,7 +403,15 @@ proc strokeText*(
|
||||||
wrap = true,
|
wrap = true,
|
||||||
kerning = true
|
kerning = true
|
||||||
) =
|
) =
|
||||||
for _, path in font.typeset(
|
## Typesets and strokes the text. Optional parameters:
|
||||||
|
## transform: translation or matrix to apply
|
||||||
|
## bounds: width determines wrapping and halign, height for valign
|
||||||
|
## hAlign: horizontal alignment of the text
|
||||||
|
## vAlign: vertical alignment of the text
|
||||||
|
## textCase: text character case
|
||||||
|
## wrap: enable/disable text wrapping
|
||||||
|
## kerning: enable/disable kerning adjustments to letter spacing
|
||||||
|
for path in font.typeset(
|
||||||
text,
|
text,
|
||||||
bounds,
|
bounds,
|
||||||
hAlign,
|
hAlign,
|
||||||
|
@ -411,7 +435,15 @@ proc strokeText*(
|
||||||
wrap = true,
|
wrap = true,
|
||||||
kerning = true
|
kerning = true
|
||||||
) =
|
) =
|
||||||
for _, path in font.typeset(
|
## Typesets and strokes the text. Optional parameters:
|
||||||
|
## transform: translation or matrix to apply
|
||||||
|
## bounds: width determines wrapping and halign, height for valign
|
||||||
|
## hAlign: horizontal alignment of the text
|
||||||
|
## vAlign: vertical alignment of the text
|
||||||
|
## textCase: text character case
|
||||||
|
## wrap: enable/disable text wrapping
|
||||||
|
## kerning: enable/disable kerning adjustments to letter spacing
|
||||||
|
for path in font.typeset(
|
||||||
text,
|
text,
|
||||||
bounds,
|
bounds,
|
||||||
hAlign,
|
hAlign,
|
||||||
|
|
|
@ -126,6 +126,14 @@ proc typeset*(
|
||||||
wrap = true,
|
wrap = true,
|
||||||
kerning = true
|
kerning = true
|
||||||
): Arrangement =
|
): Arrangement =
|
||||||
|
## Lays out the character glyphs and returns the arrangement.
|
||||||
|
## Optional parameters:
|
||||||
|
## bounds: width determines wrapping and halign, height for valign
|
||||||
|
## hAlign: horizontal alignment of the text
|
||||||
|
## vAlign: vertical alignment of the text
|
||||||
|
## textCase: text character case
|
||||||
|
## wrap: enable/disable text wrapping
|
||||||
|
## kerning: enable/disable kerning adjustments to letter spacing
|
||||||
result = Arrangement()
|
result = Arrangement()
|
||||||
result.font = font
|
result.font = font
|
||||||
|
|
||||||
|
@ -255,16 +263,17 @@ proc typeset*(
|
||||||
result.positions[i].y += yAdjustment
|
result.positions[i].y += yAdjustment
|
||||||
result.selectionRects[i].y += yAdjustment
|
result.selectionRects[i].y += yAdjustment
|
||||||
|
|
||||||
proc getPath*(arrangement: Arrangement, i: int): Path =
|
proc getPath*(arrangement: Arrangement, index: int): Path =
|
||||||
|
## Returns the path for index.
|
||||||
result = arrangement.font.typeface.getGlyphPath(arrangement.runes[i])
|
result = arrangement.font.typeface.getGlyphPath(arrangement.runes[i])
|
||||||
result.transform(
|
result.transform(
|
||||||
translate(arrangement.positions[i]) * scale(vec2(arrangement.font.scale))
|
translate(arrangement.positions[i]) * scale(vec2(arrangement.font.scale))
|
||||||
)
|
)
|
||||||
|
|
||||||
iterator paths*(arrangement: Arrangement): (int, Path) =
|
iterator paths*(arrangement: Arrangement): Path =
|
||||||
|
## Iterates over the paths for the arrangement.
|
||||||
for i in 0 ..< arrangement.runes.len:
|
for i in 0 ..< arrangement.runes.len:
|
||||||
if arrangement.runes[i].uint32 > SP.uint32: # Don't draw control runes
|
yield arrangement.getPath(i)
|
||||||
yield (i, arrangement.getPath(i))
|
|
||||||
|
|
||||||
proc parseOtf*(buf: string): Font =
|
proc parseOtf*(buf: string): Font =
|
||||||
result.typeface = Typeface()
|
result.typeface = Typeface()
|
||||||
|
|
Loading…
Reference in a new issue