readfont extensions
This commit is contained in:
parent
8574b12900
commit
bf4174abd9
1 changed files with 9 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
import bumpy, chroma, flatty/binny, os, pixie/blends, pixie/common,
|
import bumpy, chroma, flatty/binny, os, pixie/blends, pixie/common,
|
||||||
pixie/fileformats/bmp, pixie/fileformats/gif, pixie/fileformats/jpg,
|
pixie/fileformats/bmp, pixie/fileformats/gif, pixie/fileformats/jpg,
|
||||||
pixie/fileformats/png, pixie/fileformats/svg, pixie/fonts, pixie/images,
|
pixie/fileformats/png, pixie/fileformats/svg, pixie/fonts, pixie/images,
|
||||||
pixie/masks, pixie/paints, pixie/paths, vmath
|
pixie/masks, pixie/paints, pixie/paths, strutils, vmath
|
||||||
|
|
||||||
export blends, bumpy, chroma, common, fonts, images, masks, paints, paths, vmath
|
export blends, bumpy, chroma, common, fonts, images, masks, paints, paths, vmath
|
||||||
|
|
||||||
|
@ -11,7 +11,13 @@ 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():
|
||||||
|
of ".ttf":
|
||||||
|
parseTtf(readFile(filePath))
|
||||||
|
of ".otf":
|
||||||
parseOtf(readFile(filePath))
|
parseOtf(readFile(filePath))
|
||||||
|
else:
|
||||||
|
raise newException(PixieError, "Unsupported font format")
|
||||||
|
|
||||||
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.
|
||||||
|
@ -59,7 +65,7 @@ proc writeFile*(image: Image, filePath: string, fileFormat: FileFormat) =
|
||||||
|
|
||||||
proc writeFile*(image: Image, filePath: string) =
|
proc writeFile*(image: Image, filePath: string) =
|
||||||
## Writes an image to a file.
|
## Writes an image to a file.
|
||||||
let fileFormat = case splitFile(filePath).ext:
|
let fileFormat = case splitFile(filePath).ext.toLowerAscii():
|
||||||
of ".png": ffPng
|
of ".png": ffPng
|
||||||
of ".bmp": ffBmp
|
of ".bmp": ffBmp
|
||||||
of ".jpg", ".jpeg": ffJpg
|
of ".jpg", ".jpeg": ffJpg
|
||||||
|
|
Loading…
Reference in a new issue