add filePath to typeface

This commit is contained in:
Ryan Oldenburg 2021-05-11 22:18:10 -05:00
parent 971287ce7e
commit e186456788
2 changed files with 12 additions and 9 deletions

View file

@ -11,6 +11,7 @@ type
proc readFont*(filePath: string): Font = proc readFont*(filePath: string): Font =
## Loads a font from a file. ## Loads a font from a file.
result =
case splitFile(filePath).ext.toLowerAscii(): case splitFile(filePath).ext.toLowerAscii():
of ".ttf": of ".ttf":
parseTtf(readFile(filePath)) parseTtf(readFile(filePath))
@ -20,6 +21,7 @@ proc readFont*(filePath: string): Font =
parseSvgFont(readFile(filePath)) parseSvgFont(readFile(filePath))
else: else:
raise newException(PixieError, "Unsupported font format") raise newException(PixieError, "Unsupported font format")
result.typeface.filePath = filePath
converter autoStraightAlpha*(c: ColorRGBX): ColorRGBA {.inline.} = converter autoStraightAlpha*(c: ColorRGBX): ColorRGBA {.inline.} =
## Convert a paremultiplied alpha RGBA to a straight alpha RGBA. ## Convert a paremultiplied alpha RGBA to a straight alpha RGBA.

View file

@ -10,6 +10,7 @@ type
Typeface* = ref object Typeface* = ref object
opentype: OpenType opentype: OpenType
svgFont: SvgFont svgFont: SvgFont
filePath*: string
Font* = object Font* = object
typeface*: Typeface typeface*: Typeface