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

View file

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