add filePath to typeface
This commit is contained in:
parent
971287ce7e
commit
e186456788
2 changed files with 12 additions and 9 deletions
|
@ -11,15 +11,17 @@ type
|
||||||
|
|
||||||
proc readFont*(filePath: string): Font =
|
proc readFont*(filePath: string): Font =
|
||||||
## Loads a font from a file.
|
## Loads a font from a file.
|
||||||
case splitFile(filePath).ext.toLowerAscii():
|
result =
|
||||||
of ".ttf":
|
case splitFile(filePath).ext.toLowerAscii():
|
||||||
parseTtf(readFile(filePath))
|
of ".ttf":
|
||||||
of ".otf":
|
parseTtf(readFile(filePath))
|
||||||
parseOtf(readFile(filePath))
|
of ".otf":
|
||||||
of ".svg":
|
parseOtf(readFile(filePath))
|
||||||
parseSvgFont(readFile(filePath))
|
of ".svg":
|
||||||
else:
|
parseSvgFont(readFile(filePath))
|
||||||
raise newException(PixieError, "Unsupported font format")
|
else:
|
||||||
|
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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue