Fix strikethough and underline for CFF fonts with winding order flag.

This commit is contained in:
treeform 2021-09-07 09:55:01 -07:00
parent 34eead2c72
commit 8d1a84efea
6 changed files with 16 additions and 2 deletions

View file

@ -2415,6 +2415,12 @@ proc getKerningAdjustment*(
elif opentype.kern != nil:
result = opentype.kern.kerningPairs.getOrDefault(glyphPair, 0)
proc getWindingOrder*(opentype: OpenType): bool =
## Returns the expected winding order of a font.
## Gyph - false - clockwise
## CFF - true - counterclockwise
return opentype.cff == nil
proc parseOpenType*(buf: string): OpenType {.raises: [PixieError].} =
result = OpenType()
result.buf = buf

View file

@ -92,6 +92,12 @@ proc strikeoutThickness(typeface: Typeface): float32 =
if typeface.opentype != nil:
result = typeface.opentype.os2.yStrikeoutSize.float32
proc getWindingOrder(typeface: Typeface): bool =
## Returns the expected winding order of a font.
if typeface.opentype != nil:
return typeface.opentype.getWindingOrder()
return true
proc getGlyphPath*(
typeface: Typeface, rune: Rune
): Path {.inline, raises: [PixieError].} =
@ -478,14 +484,16 @@ proc textUber(
arrangement.selectionRects[runeIndex].x,
position.y - underlinePosition + underlineThickness / 2,
arrangement.selectionRects[runeIndex].w,
underlineThickness
underlineThickness,
font.typeface.getWindingOrder()
)
if font.strikethrough:
path.rect(
arrangement.selectionRects[runeIndex].x,
position.y - strikeoutPosition,
arrangement.selectionRects[runeIndex].w,
strikeoutThickness
strikeoutThickness,
font.typeface.getWindingOrder()
)
when stroke:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB