Skip to content

Commit c8a8f4f

Browse files
committed
Fix binding ABI value types
1 parent 8eacfed commit c8a8f4f

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

bindings/bindings.nim

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ proc checkError(): bool =
1010
result = lastError != nil
1111

1212
type
13-
Vector2* = object
13+
Vector2* {.bycopy.} = object
1414
x*, y*: float32
1515

16-
Matrix3* = object
16+
Matrix3* {.bycopy.} = object
1717
values*: array[9, float32]
1818

1919
proc matrix3(): Matrix3 =
@@ -34,6 +34,21 @@ proc scale(x, y: float32): Matrix3 =
3434
proc inverse(m: Matrix3): Matrix3 =
3535
cast[Matrix3](inverse(cast[Mat3](m)))
3636

37+
proc hasGlyph(typeface: Typeface, rune: int32): bool {.raises: [].} =
38+
typeface.hasGlyph(Rune(rune))
39+
40+
proc getGlyphPath(typeface: Typeface, rune: int32): Path {.raises: [].} =
41+
try:
42+
result = typeface.getGlyphPath(Rune(rune))
43+
except:
44+
lastError = currentExceptionAsPixieError()
45+
46+
proc getAdvance(typeface: Typeface, rune: int32): float32 {.raises: [].} =
47+
typeface.getAdvance(Rune(rune))
48+
49+
proc getKerningAdjustment(typeface: Typeface, left, right: int32): float32 {.raises: [].} =
50+
typeface.getKerningAdjustment(Rune(left), Rune(right))
51+
3752
proc parseColor(s: string): Color {.raises: [PixieError]} =
3853
try:
3954
result = parseHtmlColor(s)
@@ -193,10 +208,10 @@ exportRefObject Typeface:
193208
descent
194209
lineGap
195210
lineHeight
196-
hasGlyph
197-
getGlyphPath
198-
getAdvance
199-
getKerningAdjustment
211+
hasGlyph(Typeface, int32)
212+
getGlyphPath(Typeface, int32)
213+
getAdvance(Typeface, int32)
214+
getKerningAdjustment(Typeface, int32, int32)
200215
newFont
201216

202217
exportRefObject Font:

0 commit comments

Comments
 (0)