From 7b2393874bbfebbd903babf0950bcfe68d9c7470 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Fri, 7 May 2021 12:25:36 -0500 Subject: [PATCH] arrangement api --- src/pixie.nim | 8 ++++---- src/pixie/fonts.nim | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/pixie.nim b/src/pixie.nim index d9b066a..f60b012 100644 --- a/src/pixie.nim +++ b/src/pixie.nim @@ -339,7 +339,7 @@ proc fillText*( wrap = true, kerning = true ) = - for path in font.typeset( + for _, path in font.typeset( text, bounds, hAlign, @@ -362,7 +362,7 @@ proc fillText*( wrap = true, kerning = true ) = - for path in font.typeset( + for _, path in font.typeset( text, bounds, hAlign, @@ -387,7 +387,7 @@ proc strokeText*( wrap = true, kerning = true ) = - for path in font.typeset( + for _, path in font.typeset( text, bounds, hAlign, @@ -411,7 +411,7 @@ proc strokeText*( wrap = true, kerning = true ) = - for path in font.typeset( + for _, path in font.typeset( text, bounds, hAlign, diff --git a/src/pixie/fonts.nim b/src/pixie/fonts.nim index e4a8ebd..2a7bdc8 100644 --- a/src/pixie/fonts.nim +++ b/src/pixie/fonts.nim @@ -255,14 +255,16 @@ proc typeset*( result.positions[i].y += yAdjustment result.selectionRects[i].y += yAdjustment -iterator paths*(arrangement: Arrangement): Path = +proc getPath*(arrangement: Arrangement, i: int): Path = + 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) = for i in 0 ..< arrangement.runes.len: if arrangement.runes[i].uint32 > SP.uint32: # Don't draw control runes - var path = arrangement.font.typeface.getGlyphPath(arrangement.runes[i]) - path.transform( - translate(arrangement.positions[i]) * scale(vec2(arrangement.font.scale)) - ) - yield path + yield (i, arrangement.getPath(i)) proc parseOtf*(buf: string): Font = result.typeface = Typeface()