From 64d168f53b0fe70bda77e2ed7bec35f3f0f1af78 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Sat, 25 Oct 2025 17:28:48 +0200 Subject: [PATCH] initial commit --- .gitignore | 1 + .gitmodules | 3 +++ Makefile | 4 +++ libschrift.c3 | 58 +++++++++++++++++++++++++++++++++++++++++++ manifest.json | 9 +++++++ project.json | 14 +++++++++++ thirdparty/libschrift | 1 + 7 files changed, 90 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Makefile create mode 100644 libschrift.c3 create mode 100644 manifest.json create mode 100644 project.json create mode 160000 thirdparty/libschrift diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10301e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.a diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8d9e7b8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "thirdparty/libschrift"] + path = thirdparty/libschrift + url = https://github.com/tomolt/libschrift diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1de46d5 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +all: + make -C thirdparty/libschrift + mkdir -p linux-x64 + cp thirdparty/libschrift/libschrift.a linux-x64/libschrift.a diff --git a/libschrift.c3 b/libschrift.c3 new file mode 100644 index 0000000..699d296 --- /dev/null +++ b/libschrift.c3 @@ -0,0 +1,58 @@ +module schrift; + +alias SftFont = void*; +alias SftUChar = uint; +alias SftGlyph = uint; + +const int SFT_DOWNWARD_Y = 0x01; + +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 ZString sft_version() @extern("sft_version"); + +extern fn SftFont loadmem(void* mem, usz size) @extern("sft_loadmem"); +extern fn SftFont loadfile(ZString filename) @extern("sft_loadfile"); +extern fn void freefont(SftFont font) @extern("sft_freefont"); + +extern fn int lmetrics(Sft* sft, SftLMetrics* metrics) @extern("sft_lmetrics"); +extern fn int lookup(Sft* sft, SftUChar codepoint, SftGlyph* glyph) @extern("sft_lookup"); +extern fn int gmetrics(Sft* sft, SftGlyph glyph, SftGMetrics* metrics) @extern("sft_gmetrics"); +extern fn int kerning(Sft* sft, SftGlyph leftGlyph, SftGlyph rightGlyph, SftKerning* kerning) @extern("sft_kerning"); +extern fn int render(Sft* sft, SftGlyph glyph, SftImage image) @extern("sft_render"); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..efb7f23 --- /dev/null +++ b/manifest.json @@ -0,0 +1,9 @@ +{ + "provides" : "schrift", + "targets" : { + "linux-x64" : { + "dependencies" : [], + "linked-libraries" : ["schrift", "c"] + } + } +} diff --git a/project.json b/project.json new file mode 100644 index 0000000..92b049c --- /dev/null +++ b/project.json @@ -0,0 +1,14 @@ +{ + "langrev": "1", + "warnings": [ "no-unused" ], + "dependency-search-paths": [ ".." ], + "dependencies": [ "schrift" ], + "authors": [ "Alessandro Mauri ", "Thomas Oltmann " ], + "version": "0.1.0", + "sources": [ ], + "output": "build", + "target": "linux-x64", + "features": [], + "cpu": "generic", + "opt": "O0", +} diff --git a/thirdparty/libschrift b/thirdparty/libschrift new file mode 160000 index 0000000..24737d2 --- /dev/null +++ b/thirdparty/libschrift @@ -0,0 +1 @@ +Subproject commit 24737d2922b23df4a5692014f5ba03da0c296112