diff --git a/.gitignore b/.gitignore index 228cff3..87b38e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o build/* +**/.ccls-cache diff --git a/lib/libschrift.c3l/Makefile b/lib/libschrift.c3l/Makefile new file mode 100644 index 0000000..ff62ec4 --- /dev/null +++ b/lib/libschrift.c3l/Makefile @@ -0,0 +1,3 @@ +all: + make -C thirdparty/libschrift + cp thirdparty/libschrift/libschrift.a linux-x64/libschrift.a diff --git a/lib/libschrift.c3l/libschrift.c3 b/lib/libschrift.c3l/libschrift.c3 new file mode 100644 index 0000000..1b0f24b --- /dev/null +++ b/lib/libschrift.c3l/libschrift.c3 @@ -0,0 +1,56 @@ +module schrift; + +def SftFont = void*; +def SftUChar = uint; +def SftGlyph = uint; + +struct Sft +{ + SftFont font; + double xScale; + double yScale; + double xOffset; + double yOffset; + int flags; +} + +struct SftLMetrics +{ + double ascender; + double descender; + double lineGap; +} + +struct SftGMetrics +{ + double advanceWidth; + double leftSideBearing; + int yOffset; + int minWidth; + int minHeight; +} + +struct SftKerning +{ + double xShift; + double yShift; +} + +struct SftImage +{ + void *pixels; + int width; + int height; +} + +extern fn char* sft_version() @extern("sft_version"); + +extern fn SftFont sft_loadmem(void* mem, usz size) @extern("sft_loadmem"); +extern fn SftFont sft_loadfile(char* filename) @extern("sft_loadfile"); +extern fn void sft_freefont(SftFont font) @extern("sft_freefont"); + +extern fn int sft_lmetrics(Sft* sft, SftLMetrics* metrics) @extern("sft_lmetrics"); +extern fn int sft_lookup(Sft* sft, SftUChar codepoint, SftGlyph* glyph) @extern("sft_lookup"); +extern fn int sft_gmetrics(Sft* sft, SftGlyph glyph, SftGMetrics* metrics) @extern("sft_gmetrics"); +extern fn int sft_kerning(Sft* sft, SftGlyph leftGlyph, SftGlyph rightGlyph, SftKerning* kerning) @extern("sft_kerning"); +extern fn int sft_render(Sft* sft, SftGlyph glyph, SftImage image) @extern("sft_render"); diff --git a/lib/libschrift.c3l/linux-x64/libschrift.a b/lib/libschrift.c3l/linux-x64/libschrift.a new file mode 100644 index 0000000..e3a0423 Binary files /dev/null and b/lib/libschrift.c3l/linux-x64/libschrift.a differ diff --git a/lib/libschrift.c3l/manifest.json b/lib/libschrift.c3l/manifest.json new file mode 100644 index 0000000..efb7f23 --- /dev/null +++ b/lib/libschrift.c3l/manifest.json @@ -0,0 +1,9 @@ +{ + "provides" : "schrift", + "targets" : { + "linux-x64" : { + "dependencies" : [], + "linked-libraries" : ["schrift", "c"] + } + } +} diff --git a/lib/libschrift.c3l/project.json b/lib/libschrift.c3l/project.json new file mode 100644 index 0000000..573769f --- /dev/null +++ b/lib/libschrift.c3l/project.json @@ -0,0 +1,45 @@ +{ + // Language version of C3. + "langrev": "1", + // Warnings used for all targets. + "warnings": [ "no-unused" ], + // Directories where C3 library files may be found. + "dependency-search-paths": [ ".." ], + // Libraries to use for all targets. + "dependencies": [ "schrift" ], + // Authors, optionally with email. + "authors": [ "Alessandro Mauri