|
1 | 1 | module gui |
2 | 2 |
|
| 3 | +// Currently, `gg` only supports static font files like `.ttf`. If/when this |
| 4 | +// changes, support for variable fonts like those in Google fonts will be used. |
| 5 | +// |
3 | 6 | import log |
4 | 7 | import os |
5 | 8 | import os.font |
|
13 | 16 | mono string |
14 | 17 | } |
15 | 18 |
|
16 | | -pub const font_file_regular = os.join_path(os.data_dir(), 'gui_deja-vu-sans-regular.ttf') |
17 | | -pub const font_file_bold = os.join_path(os.data_dir(), 'gui_deja-vu-sans-bold.ttf') |
18 | | -pub const font_file_italic = os.join_path(os.data_dir(), 'gui_deja-vu-sans-italic.ttf') |
19 | | -pub const font_file_mono = os.join_path(os.data_dir(), 'gui_deja-vu-sans-mono.ttf') |
20 | | -pub const font_file_icon = os.join_path(os.data_dir(), 'gui_feathericon.ttf') |
| 19 | +pub const font_file_regular = os.join_path(os.data_dir(), 'v_gui_deja-vu-sans-regular.ttf') |
| 20 | +pub const font_file_bold = os.join_path(os.data_dir(), 'v_gui_deja-vu-sans-bold.ttf') |
| 21 | +pub const font_file_italic = os.join_path(os.data_dir(), 'v_gui_deja-vu-sans-italic.ttf') |
| 22 | +pub const font_file_mono = os.join_path(os.data_dir(), 'v_gui_deja-vu-sans-mono.ttf') |
| 23 | +pub const font_file_icon = os.join_path(os.data_dir(), 'v_gui_feathericon.ttf') |
21 | 24 |
|
| 25 | +// initialize_fonts ensures all required font files exist in the data directory by checking for |
| 26 | +// each font file and writing the embedded font data if not found. It writes regular, bold, |
| 27 | +// italic, mono and icon font files. |
22 | 28 | fn initialize_fonts() { |
23 | 29 | if !os.exists(font_file_regular) { |
24 | 30 | os.write_file(font_file_regular, $embed_file('assets/DejaVuSans-Regular.ttf').to_string()) or { |
@@ -75,6 +81,8 @@ fn path_variant(path string, variant font.Variant) string { |
75 | 81 | return if os.exists(vpath) { vpath } else { path } |
76 | 82 | } |
77 | 83 |
|
| 84 | +// Map of icons names to their unicode values. Describes only |
| 85 | +// the icons included in `assets/feathericon.ttf` |
78 | 86 | pub const icons_map = { |
79 | 87 | 'icon_arrow_down': icon_arrow_down |
80 | 88 | 'icon_arrow_left': icon_arrow_left |
|
0 commit comments