Author: mesyeti <mesyeti@mesyeti.uk>
start of ttf
.gitmodules | 3 +++ source/schift.c | 1 + source/schrift.h | 6 ++++++ source/ttf.c | 25 +++++++++++++++++++++++++ source/ttf.h | 14 ++++++++++++++
diff --git a/.gitmodules b/.gitmodules index 3853cc6df8de381a1486906db6482136dc58caab..b9321feeb8626ed24b49cb036963fbfd4e007fa8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ url = https://github.com/nothings/stb [submodule "lib/tini"] path = lib/tini url = https://codeberg.org/lordoftrident/tini/ +[submodule "lib/libschrift"] + path = lib/libschrift + url = https://github.com/tomolt/libschrift diff --git a/source/schift.c b/source/schift.c new file mode 100644 index 0000000000000000000000000000000000000000..778ac42e05fa003d78fb917af0f503429ace0d4f --- /dev/null +++ b/source/schift.c @@ -0,0 +1 @@ +#include <libschrift/schrift.c> diff --git a/source/schrift.h b/source/schrift.h new file mode 100644 index 0000000000000000000000000000000000000000..56642647d9d5929a3ccb6172c6dd13e0020c9d21 --- /dev/null +++ b/source/schrift.h @@ -0,0 +1,6 @@ +#ifndef YT_SCHRIFT_H +#define YT_SCHRIFT_H + +#include <libschrift/schrift.h> + +#endif diff --git a/source/ttf.c b/source/ttf.c new file mode 100644 index 0000000000000000000000000000000000000000..c1525458f845dbc6bd112ba94e33497c490b9135 --- /dev/null +++ b/source/ttf.c @@ -0,0 +1,25 @@ +#include "ttf.h" + +TTFont TTFont_Load(const char* path, bool* success) { + *success = true; + + TTFont ret; + ret.sft.font = sft_loadfile(path); + + if (!ret.sft.font) { + *success = false; + return ret; + } + + ret.sft.xScale = 1; + ret.sft.yScale = 1; + ret.sft.xOffset = 0; + ret.sft.yOffset = 0; + ret.sft.flags = SFT_DOWNWARD_Y; + + return ret; +} + +void TTFont_Free(TTFont* font) { + sft_freefont(font->sft.font); +} diff --git a/source/ttf.h b/source/ttf.h new file mode 100644 index 0000000000000000000000000000000000000000..9709f4f9301c4290db4016d24e89acc319d29d1c --- /dev/null +++ b/source/ttf.h @@ -0,0 +1,14 @@ +#ifndef YT_TTF_H +#define YT_TTF_H + +#include "common.h" +#include "schrift.h" + +typedef struct { + SFT sft; +} TTFont; + +TTFont TTFont_Load(const char* path, bool* success); +void TTFont_Free(TTFont* font); + +#endif