From e186456788c75eadb87c0dbdfc6fa8a10cbe09dd Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Tue, 11 May 2021 22:18:10 -0500 Subject: [PATCH] add filePath to typeface --- src/pixie.nim | 20 +++++++++++--------- src/pixie/fonts.nim | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/pixie.nim b/src/pixie.nim index d6a5b1c..cb6f3f6 100644 --- a/src/pixie.nim +++ b/src/pixie.nim @@ -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. diff --git a/src/pixie/fonts.nim b/src/pixie/fonts.nim index aad28f5..64747ed 100644 --- a/src/pixie/fonts.nim +++ b/src/pixie/fonts.nim @@ -10,6 +10,7 @@ type Typeface* = ref object opentype: OpenType svgFont: SvgFont + filePath*: string Font* = object typeface*: Typeface