From 43e80a70abfbd97cbf5641bb191f06232f0d948e Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Fri, 7 May 2021 16:09:31 -0500 Subject: [PATCH] docs --- src/pixie.nim | 40 ++++++++++++++++++++++++++++++++++++---- src/pixie/fonts.nim | 17 +++++++++++++---- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/pixie.nim b/src/pixie.nim index f60b012..b8f86ac 100644 --- a/src/pixie.nim +++ b/src/pixie.nim @@ -339,7 +339,15 @@ proc fillText*( wrap = 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, bounds, hAlign, @@ -362,7 +370,15 @@ proc fillText*( wrap = 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, bounds, hAlign, @@ -387,7 +403,15 @@ proc strokeText*( wrap = 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, bounds, hAlign, @@ -411,7 +435,15 @@ proc strokeText*( wrap = 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, bounds, hAlign, diff --git a/src/pixie/fonts.nim b/src/pixie/fonts.nim index 6b45408..c983975 100644 --- a/src/pixie/fonts.nim +++ b/src/pixie/fonts.nim @@ -126,6 +126,14 @@ proc typeset*( wrap = true, kerning = true ): 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.font = font @@ -255,16 +263,17 @@ proc typeset*( result.positions[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.transform( 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: - if arrangement.runes[i].uint32 > SP.uint32: # Don't draw control runes - yield (i, arrangement.getPath(i)) + yield arrangement.getPath(i) proc parseOtf*(buf: string): Font = result.typeface = Typeface()