arrangement api

This commit is contained in:
Ryan Oldenburg 2021-05-07 12:25:36 -05:00
parent eb550c0671
commit 7b2393874b
2 changed files with 12 additions and 10 deletions

View file

@ -339,7 +339,7 @@ proc fillText*(
wrap = true, wrap = true,
kerning = true kerning = true
) = ) =
for path in font.typeset( for _, path in font.typeset(
text, text,
bounds, bounds,
hAlign, hAlign,
@ -362,7 +362,7 @@ proc fillText*(
wrap = true, wrap = true,
kerning = true kerning = true
) = ) =
for path in font.typeset( for _, path in font.typeset(
text, text,
bounds, bounds,
hAlign, hAlign,
@ -387,7 +387,7 @@ proc strokeText*(
wrap = true, wrap = true,
kerning = true kerning = true
) = ) =
for path in font.typeset( for _, path in font.typeset(
text, text,
bounds, bounds,
hAlign, hAlign,
@ -411,7 +411,7 @@ proc strokeText*(
wrap = true, wrap = true,
kerning = true kerning = true
) = ) =
for path in font.typeset( for _, path in font.typeset(
text, text,
bounds, bounds,
hAlign, hAlign,

View file

@ -255,14 +255,16 @@ proc typeset*(
result.positions[i].y += yAdjustment result.positions[i].y += yAdjustment
result.selectionRects[i].y += yAdjustment result.selectionRects[i].y += yAdjustment
iterator paths*(arrangement: Arrangement): Path = proc getPath*(arrangement: Arrangement, i: int): Path =
for i in 0 ..< arrangement.runes.len: result = arrangement.font.typeface.getGlyphPath(arrangement.runes[i])
if arrangement.runes[i].uint32 > SP.uint32: # Don't draw control runes result.transform(
var path = arrangement.font.typeface.getGlyphPath(arrangement.runes[i])
path.transform(
translate(arrangement.positions[i]) * scale(vec2(arrangement.font.scale)) translate(arrangement.positions[i]) * scale(vec2(arrangement.font.scale))
) )
yield path
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
yield (i, arrangement.getPath(i))
proc parseOtf*(buf: string): Font = proc parseOtf*(buf: string): Font =
result.typeface = Typeface() result.typeface = Typeface()