added library schrift
This commit is contained in:
parent
f86a360f39
commit
dbe70eb4f4
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
*.o
|
||||
build/*
|
||||
**/.ccls-cache
|
||||
|
3
lib/libschrift.c3l/Makefile
Normal file
3
lib/libschrift.c3l/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
all:
|
||||
make -C thirdparty/libschrift
|
||||
cp thirdparty/libschrift/libschrift.a linux-x64/libschrift.a
|
56
lib/libschrift.c3l/libschrift.c3
Normal file
56
lib/libschrift.c3l/libschrift.c3
Normal file
@ -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");
|
BIN
lib/libschrift.c3l/linux-x64/libschrift.a
Normal file
BIN
lib/libschrift.c3l/linux-x64/libschrift.a
Normal file
Binary file not shown.
9
lib/libschrift.c3l/manifest.json
Normal file
9
lib/libschrift.c3l/manifest.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"provides" : "schrift",
|
||||
"targets" : {
|
||||
"linux-x64" : {
|
||||
"dependencies" : [],
|
||||
"linked-libraries" : ["schrift", "c"]
|
||||
}
|
||||
}
|
||||
}
|
45
lib/libschrift.c3l/project.json
Normal file
45
lib/libschrift.c3l/project.json
Normal file
@ -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 <alemauri001@gmail.com" ],
|
||||
// Version using semantic versioning.
|
||||
"version": "0.1.0",
|
||||
// Sources compiled for all targets.
|
||||
"sources": [ ],
|
||||
// C sources if the project also compiles C sources
|
||||
// relative to the project file.
|
||||
// "c-sources": [ "csource/**" ],
|
||||
// Output location, relative to project file.
|
||||
"output": "build",
|
||||
// Architecture and OS target.
|
||||
// You can use 'c3c --list-targets' to list all valid targets.
|
||||
// "target": "windows-x64",
|
||||
"features": [
|
||||
// See rcore.c3
|
||||
//"SUPPORT_INTERNAL_MEMORY_MANAGEMENT",
|
||||
//"SUPPORT_STANDARD_FILEIO",
|
||||
//"SUPPORT_FILE_SYSTEM_FUNCTIONS",
|
||||
//"SUPPORT_DATA_ENCODER",
|
||||
// See text.c3
|
||||
//"SUPPORT_TEXT_CODEPOINTS_MANAGEMENT",
|
||||
//"SUPPORT_TEXT_C_STRING_MANAGEMENT",
|
||||
//"SUPPORT_RANDOM_GENERATION",
|
||||
|
||||
//"SUPPORT_RAYGUI",
|
||||
//"RAYGUI_NO_ICONS",
|
||||
//"RAYGUI_CUSTOM_ICONS",
|
||||
],
|
||||
// Global settings.
|
||||
// CPU name, used for optimizations in the LLVM backend.
|
||||
"cpu": "generic",
|
||||
// Optimization: "O0", "O1", "O2", "O3", "O4", "O5", "Os", "Oz".
|
||||
"opt": "O0",
|
||||
// See resources/examples/project_all_settings.json and 'c3c --list-project-properties' to see more properties.
|
||||
}
|
1
lib/libschrift.c3l/thirdparty/libschrift
vendored
Submodule
1
lib/libschrift.c3l/thirdparty/libschrift
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 24737d2922b23df4a5692014f5ba03da0c296112
|
@ -6,7 +6,7 @@
|
||||
// Directories where C3 library files may be found.
|
||||
"dependency-search-paths": [ "lib" ],
|
||||
// Libraries to use for all targets.
|
||||
"dependencies": [ "raylib" ],
|
||||
"dependencies": [ "raylib", "schrift" ],
|
||||
"features": [
|
||||
// See rcore.c3
|
||||
//"SUPPORT_INTERNAL_MEMORY_MANAGEMENT",
|
||||
|
@ -167,6 +167,7 @@ struct Ctx {
|
||||
// total size in pixels of the context
|
||||
ushort width, height;
|
||||
Style style;
|
||||
Font font;
|
||||
|
||||
bool has_focus;
|
||||
struct input {
|
||||
|
18
src/ugui_font.c3
Normal file
18
src/ugui_font.c3
Normal file
@ -0,0 +1,18 @@
|
||||
module ugui;
|
||||
|
||||
import schrift;
|
||||
|
||||
struct Font @private {
|
||||
schrift::Sft sft;
|
||||
String path;
|
||||
}
|
||||
|
||||
fn void! Ctx.font_load(&ctx, String path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
fn void Ctx.font_free(&ctx)
|
||||
{
|
||||
|
||||
}
|
6
test/test_font.c3
Normal file
6
test/test_font.c3
Normal file
@ -0,0 +1,6 @@
|
||||
import rl;
|
||||
|
||||
fn int main(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user