|
1 | 1 | import std/os |
2 | 2 |
|
3 | | -{.compile: "stb_truetype.c".} |
4 | | -{.passC: "-I" & currentSourcePath().splitPath().head.} |
| 3 | +const StbDir = currentSourcePath().splitPath().head / |
| 4 | + ".." / ".." / ".." / ".." / |
| 5 | + "modules" / "third-party" / "stb" |
| 6 | + |
| 7 | +{.passC: "-O3 -I" & StbDir.} |
| 8 | + |
| 9 | +{.emit: """ |
| 10 | +#define STB_TRUETYPE_IMPLEMENTATION |
| 11 | +#include "stb_truetype.h" |
| 12 | +""".} |
5 | 13 |
|
6 | 14 | type |
7 | | - stbtt_fontinfo* {.importc, header: "stb_truetype.h".} = object |
| 15 | + stbtt_fontinfo* {.importc, header: StbDir / "stb_truetype.h".} = object |
8 | 16 |
|
9 | 17 | proc stbtt_InitFont*(info: ptr stbtt_fontinfo, data: ptr UncheckedArray[byte], offset: cint): cint |
10 | | - {.importc, header: "stb_truetype.h".} |
| 18 | + {.importc, header: StbDir / "stb_truetype.h".} |
11 | 19 |
|
12 | 20 | proc stbtt_ScaleForPixelHeight*(info: ptr stbtt_fontinfo, pixels: cfloat): cfloat |
13 | | - {.importc, header: "stb_truetype.h".} |
| 21 | + {.importc, header: StbDir / "stb_truetype.h".} |
14 | 22 |
|
15 | 23 | proc stbtt_GetFontVMetrics*(info: ptr stbtt_fontinfo, ascent, descent, lineGap: ptr cint) |
16 | | - {.importc, header: "stb_truetype.h".} |
| 24 | + {.importc, header: StbDir / "stb_truetype.h".} |
17 | 25 |
|
18 | 26 | proc stbtt_GetCodepointBitmapBox*(info: ptr stbtt_fontinfo, codepoint: cint, |
19 | 27 | scale_x, scale_y: cfloat, ix0, iy0, ix1, iy1: ptr cint) |
20 | | - {.importc, header: "stb_truetype.h".} |
| 28 | + {.importc, header: StbDir / "stb_truetype.h".} |
21 | 29 |
|
22 | 30 | proc stbtt_MakeCodepointBitmap*(info: ptr stbtt_fontinfo, output: ptr UncheckedArray[byte], |
23 | 31 | out_w, out_h, out_stride: cint, scale_x, scale_y: cfloat, codepoint: cint) |
24 | | - {.importc, header: "stb_truetype.h".} |
| 32 | + {.importc, header: StbDir / "stb_truetype.h".} |
25 | 33 |
|
26 | 34 | proc stbtt_GetCodepointHMetrics*(info: ptr stbtt_fontinfo, codepoint: cint, |
27 | 35 | advanceWidth, leftSideBearing: ptr cint) |
28 | | - {.importc, header: "stb_truetype.h".} |
| 36 | + {.importc, header: StbDir / "stb_truetype.h".} |
29 | 37 |
|
30 | 38 | proc stbtt_GetCodepointKernAdvance*(info: ptr stbtt_fontinfo, ch1, ch2: cint): cint |
31 | | - {.importc, header: "stb_truetype.h".} |
| 39 | + {.importc, header: StbDir / "stb_truetype.h".} |
0 commit comments