Use flatty/encode
This commit is contained in:
parent
4896fd0e68
commit
536230a391
2 changed files with 4 additions and 30 deletions
|
@ -9,10 +9,11 @@ requires "nim >= 1.4.8"
|
||||||
requires "vmath >= 1.1.4"
|
requires "vmath >= 1.1.4"
|
||||||
requires "chroma >= 0.2.5"
|
requires "chroma >= 0.2.5"
|
||||||
requires "zippy >= 0.9.7"
|
requires "zippy >= 0.9.7"
|
||||||
requires "flatty >= 0.2.4"
|
requires "flatty >= 3.0.0"
|
||||||
requires "nimsimd >= 1.0.0"
|
requires "nimsimd >= 1.0.0"
|
||||||
requires "bumpy >= 1.1.0"
|
requires "bumpy >= 1.1.0"
|
||||||
|
|
||||||
|
|
||||||
task bindings, "Generate bindings":
|
task bindings, "Generate bindings":
|
||||||
|
|
||||||
proc compile(libName: string, flags = "") =
|
proc compile(libName: string, flags = "") =
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import flatty/binny, math, pixie/common, pixie/paths, sets, strutils, tables,
|
import flatty/binny, flatty/encode, math, pixie/common, pixie/paths, sets,
|
||||||
unicode, vmath
|
strutils, tables, unicode, vmath
|
||||||
|
|
||||||
## See https://docs.microsoft.com/en-us/typography/opentype/spec/
|
## See https://docs.microsoft.com/en-us/typography/opentype/spec/
|
||||||
|
|
||||||
|
@ -430,33 +430,6 @@ proc readVersion16Dot16(buf: string, offset: int): float32 =
|
||||||
failUnsupported("invalid version format")
|
failUnsupported("invalid version format")
|
||||||
majorDigit.float32 + minorDigit.float32 / 10
|
majorDigit.float32 + minorDigit.float32 / 10
|
||||||
|
|
||||||
func maybeSwap(u: uint16, swap: bool): uint16 =
|
|
||||||
if swap:
|
|
||||||
((u and 0xFF) shl 8) or ((u and 0xFF00) shr 8)
|
|
||||||
else:
|
|
||||||
u
|
|
||||||
|
|
||||||
proc fromUTF16Inner(input: string, i: var int, swap: bool): string =
|
|
||||||
## Converts UTF16 Big Endian to UTF8 string.
|
|
||||||
while i + 1 < input.len:
|
|
||||||
var u1 = input.readUInt16(i).maybeSwap(swap)
|
|
||||||
i += 2
|
|
||||||
if u1 - 0xd800 >= 0x800:
|
|
||||||
result.add Rune(u1.int)
|
|
||||||
else:
|
|
||||||
var u2 = input.readUInt16(i).maybeSwap(swap)
|
|
||||||
i += 2
|
|
||||||
if ((u1 and 0xfc00) == 0xd800) and ((u2 and 0xfc00) == 0xdc00):
|
|
||||||
result.add Rune((u1.uint32 shl 10) + u2.uint32 - 0x35fdc00)
|
|
||||||
else:
|
|
||||||
# Error, produce tofu character.
|
|
||||||
result.add "□"
|
|
||||||
|
|
||||||
proc fromUTF16BE*(input: string): string =
|
|
||||||
## Converts UTF16 Big Endian to UTF8 string.
|
|
||||||
var i = 0
|
|
||||||
input.fromUTF16Inner(i, true)
|
|
||||||
|
|
||||||
proc parseCmapTable(buf: string, offset: int): CmapTable =
|
proc parseCmapTable(buf: string, offset: int): CmapTable =
|
||||||
var i = offset
|
var i = offset
|
||||||
buf.eofCheck(i + 4)
|
buf.eofCheck(i + 4)
|
||||||
|
|
Loading…
Reference in a new issue