diff --git a/data/fonts/goxel-font.ttf b/data/fonts/goxel-font.ttf
new file mode 100644
index 000000000..8462d32fe
Binary files /dev/null and b/data/fonts/goxel-font.ttf differ
diff --git a/src/assets/fonts.inl b/src/assets/fonts.inl
index ef8846dc9..08b8d273b 100644
--- a/src/assets/fonts.inl
+++ b/src/assets/fonts.inl
@@ -31928,6 +31928,81 @@
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,29,
}
},
+{.path = "data/fonts/goxel-font.ttf", .size = 1896, .data =
+(const uint8_t[]){
+ 0,1,0,0,0,13,0,128,0,3,0,80,70,70,84,77,167,168,226,128,0,0,7,76,0,0,0,
+ 28,79,83,47,50,60,122,88,21,0,0,1,88,0,0,0,96,99,109,97,112,233,131,231,
+ 18,0,0,1,204,0,0,1,72,99,118,116,32,0,33,2,121,0,0,3,20,0,0,0,4,103,97,
+ 115,112,255,255,0,3,0,0,7,68,0,0,0,8,103,108,121,102,175,248,123,39,0,
+ 0,3,40,0,0,1,172,104,101,97,100,39,127,99,53,0,0,0,220,0,0,0,54,104,104,
+ 101,97,6,72,3,128,0,0,1,20,0,0,0,36,104,109,116,120,11,227,0,119,0,0,1,
+ 184,0,0,0,20,108,111,99,97,1,98,0,240,0,0,3,24,0,0,0,14,109,97,120,112,
+ 0,75,0,85,0,0,1,56,0,0,0,32,110,97,109,101,99,250,88,194,0,0,4,212,0,0,
+ 1,254,112,111,115,116,53,0,25,30,0,0,6,212,0,0,0,109,0,1,0,0,0,1,0,0,240,
+ 84,75,213,95,15,60,245,0,11,3,232,0,0,0,0,226,189,15,203,0,0,0,0,226,189,
+ 15,203,0,33,255,147,2,197,3,39,0,0,0,8,0,2,0,0,0,0,0,0,0,1,0,0,3,39,255,
+ 147,0,90,3,232,0,0,0,0,2,197,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,1,0,
+ 0,0,6,0,36,0,3,0,0,0,0,0,2,0,0,0,1,0,1,0,0,0,64,0,46,0,0,0,0,0,4,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60,178,7,4,0,
+ 237,50,177,6,5,220,60,178,3,2,0,237,50,0,177,3,0,47,60,178,5,4,0,237,50,
+ 178,7,6,1,252,60,178,1,2,0,237,50,51,17,33,17,39,51,17,35,33,1,9,232,199,
+ 199,2,154,253,102,33,2,88,0,0,3,0,43,255,147,2,197,3,39,0,3,0,19,0,35,
+ 0,0,55,17,51,17,3,33,50,22,21,17,20,6,35,33,34,38,53,17,52,54,55,34,6,
+ 21,17,20,22,51,33,50,54,53,17,52,38,35,146,146,125,1,163,18,26,26,18,254,
+ 93,19,25,25,19,51,72,72,51,1,163,50,72,72,50,225,1,223,254,33,1,246,25,
+ 19,253,99,18,26,26,18,2,157,19,25,79,72,51,253,99,51,71,71,51,2,157,51,
+ 72,0,0,3,0,43,255,147,2,197,3,39,0,3,0,19,0,35,0,0,37,17,51,17,1,33,50,
+ 22,21,17,20,6,35,33,34,38,53,17,52,54,55,34,6,21,17,20,22,51,33,50,54,
+ 53,17,52,38,35,1,36,166,254,221,1,163,18,26,26,18,254,93,19,25,25,19,51,
+ 72,72,51,1,163,50,72,72,50,225,1,223,254,33,1,246,25,19,253,99,18,26,26,
+ 18,2,157,19,25,79,72,51,253,99,51,71,71,51,2,157,51,72,0,0,0,0,3,0,43,
+ 255,147,2,197,3,39,0,3,0,19,0,35,0,0,37,17,51,17,1,33,50,22,21,17,20,6,
+ 35,33,34,38,53,17,52,54,55,34,6,21,17,20,22,51,33,50,54,53,17,52,38,35,
+ 1,202,146,254,75,1,163,18,26,26,18,254,93,19,25,25,19,51,72,72,51,1,163,
+ 50,72,72,50,225,1,223,254,33,1,246,25,19,253,99,18,26,26,18,2,157,19,25,
+ 79,72,51,253,99,51,71,71,51,2,157,51,72,0,0,0,0,0,0,14,0,174,0,1,0,0,0,
+ 0,0,0,0,37,0,76,0,1,0,0,0,0,0,1,0,5,0,126,0,1,0,0,0,0,0,2,0,7,0,148,0,
+ 1,0,0,0,0,0,3,0,33,0,224,0,1,0,0,0,0,0,4,0,5,1,14,0,1,0,0,0,0,0,5,0,13,
+ 1,48,0,1,0,0,0,0,0,6,0,5,1,74,0,3,0,1,4,9,0,0,0,74,0,0,0,3,0,1,4,9,0,1,
+ 0,10,0,114,0,3,0,1,4,9,0,2,0,14,0,132,0,3,0,1,4,9,0,3,0,66,0,156,0,3,0,
+ 1,4,9,0,4,0,10,1,2,0,3,0,1,4,9,0,5,0,26,1,20,0,3,0,1,4,9,0,6,0,10,1,62,
+ 0,67,0,111,0,112,0,121,0,114,0,105,0,103,0,104,0,116,0,32,0,40,0,99,0,
+ 41,0,32,0,50,0,48,0,50,0,52,0,44,0,32,0,71,0,117,0,105,0,108,0,108,0,97,
+ 0,117,0,109,0,101,0,32,0,67,0,104,0,101,0,114,0,101,0,97,0,117,0,0,67,
+ 111,112,121,114,105,103,104,116,32,40,99,41,32,50,48,50,52,44,32,71,117,
+ 105,108,108,97,117,109,101,32,67,104,101,114,101,97,117,0,0,71,0,111,0,
+ 120,0,101,0,108,0,0,71,111,120,101,108,0,0,82,0,101,0,103,0,117,0,108,
+ 0,97,0,114,0,0,82,101,103,117,108,97,114,0,0,70,0,111,0,110,0,116,0,70,
+ 0,111,0,114,0,103,0,101,0,32,0,50,0,46,0,48,0,32,0,58,0,32,0,71,0,111,
+ 0,120,0,101,0,108,0,32,0,58,0,32,0,49,0,55,0,45,0,55,0,45,0,50,0,48,0,
+ 50,0,52,0,0,70,111,110,116,70,111,114,103,101,32,50,46,48,32,58,32,71,
+ 111,120,101,108,32,58,32,49,55,45,55,45,50,48,50,52,0,0,71,0,111,0,120,
+ 0,101,0,108,0,0,71,111,120,101,108,0,0,86,0,101,0,114,0,115,0,105,0,111,
+ 0,110,0,32,0,49,0,46,0,48,0,46,0,48,0,0,86,101,114,115,105,111,110,32,
+ 49,46,48,46,48,0,0,71,0,111,0,120,0,101,0,108,0,0,71,111,120,101,108,0,
+ 0,0,0,2,0,0,0,0,0,0,255,181,0,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,6,0,0,0,1,0,2,1,2,1,3,1,4,20,115,118,103,47,103,108,121,112,104,115,
+ 47,109,111,117,115,101,95,108,109,98,20,115,118,103,47,103,108,121,112,
+ 104,115,47,109,111,117,115,101,95,109,109,98,20,115,118,103,47,103,108,
+ 121,112,104,115,47,109,111,117,115,101,95,114,109,98,0,0,0,0,0,0,1,255,
+ 255,0,2,0,0,0,1,0,0,0,0,226,46,194,233,0,0,0,0,226,189,15,203,0,0,0,0,
+ 226,189,15,203,
+}
+},
diff --git a/src/gui.cpp b/src/gui.cpp
index ebe548df0..42bd9e83e 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -329,27 +329,40 @@ static void ImImpl_RenderDrawLists(ImDrawData* draw_data)
GL(glDisable(GL_SCISSOR_TEST));
}
-static void load_fonts_texture()
+static void add_font(const char *uri, const ImWchar *ranges, bool mergmode)
{
ImGuiIO& io = ImGui::GetIO();
-
float scale = goxel.screen_scale;
- unsigned char* pixels;
- int width, height;
const void *data;
int data_size;
ImFontConfig conf;
+
+ conf.FontDataOwnedByAtlas = false;
+ conf.MergeMode = mergmode;
+ data = assets_get(uri, &data_size);
+ assert(data);
+ io.Fonts->AddFontFromMemoryTTF(
+ (void*)data, data_size, 14 * scale, &conf, ranges);
+}
+
+static void load_fonts_texture()
+{
+ ImGuiIO& io = ImGui::GetIO();
+
+ unsigned char* pixels;
+ int width, height;
const ImWchar ranges[] = {
0x0020, 0x00FF, // Basic Latin + Latin Supplement
0x25A0, 0x25FF, // Geometric shapes
0
};
- conf.FontDataOwnedByAtlas = false;
+ const ImWchar range_user[] = {
+ 0xE660, 0xE6FF,
+ 0
+ };
- data = assets_get("asset://data/fonts/DejaVuSans.ttf", &data_size);
- assert(data);
- io.Fonts->AddFontFromMemoryTTF(
- (void*)data, data_size, 14 * scale, &conf, ranges);
+ add_font("asset://data/fonts/DejaVuSans.ttf", ranges, false);
+ add_font("asset://data/fonts/goxel-font.ttf", range_user, true);
#if 0
conf.MergeMode = true;
diff --git a/svg/glyphs/mouse_lmb.svg b/svg/glyphs/mouse_lmb.svg
new file mode 100644
index 000000000..dba03dde2
--- /dev/null
+++ b/svg/glyphs/mouse_lmb.svg
@@ -0,0 +1,61 @@
+
+
+
+
diff --git a/svg/glyphs/mouse_mmb.svg b/svg/glyphs/mouse_mmb.svg
new file mode 100644
index 000000000..638c56e54
--- /dev/null
+++ b/svg/glyphs/mouse_mmb.svg
@@ -0,0 +1,61 @@
+
+
+
+
diff --git a/svg/glyphs/mouse_rmb.svg b/svg/glyphs/mouse_rmb.svg
new file mode 100644
index 000000000..4da99faae
--- /dev/null
+++ b/svg/glyphs/mouse_rmb.svg
@@ -0,0 +1,61 @@
+
+
+
+
diff --git a/tools/create_font.py b/tools/create_font.py
new file mode 100755
index 000000000..bdd2f3b2a
--- /dev/null
+++ b/tools/create_font.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python3
+
+# Goxel 3D voxels editor
+#
+# copyright (c) 2024-present Guillaume Chereau
+#
+# Goxel is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# Goxel is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# goxel. If not, see .
+
+# Script that generates a font file from the svg images in svg/font/
+
+import fontforge
+import glob
+import sys, os, re
+
+START_CODE = 0xE660
+
+def make_font_from_svgs(sources, output):
+ font = fontforge.font()
+ font.encoding = "UnicodeFull"
+ font.fontname = "Goxel"
+ font.familyname = "Goxel"
+ font.fullname = "Goxel"
+ font.version = "1.0.0"
+ font.weight = "Regular"
+ font.upos = -100
+ font.uwidth = 50
+ font.ascent = 850
+ font.descent = 150
+ font.em = 1000
+ for idx, file in enumerate(sorted(sources)):
+ assert file.endswith(".svg")
+ code = START_CODE + idx
+ glyph_name = file.replace(".svg", "")
+ glyph = font.createChar(code, glyph_name)
+ glyph.importOutlines(file)
+ glyph.width = 1000
+ font.generate(output)
+
+sources = glob.glob('svg/glyphs/*.svg')
+make_font_from_svgs(sources, "data/fonts/goxel-font.ttf")