diff --git a/bin/segment2.c b/bin/segment2.c index 3fd187d6..9bc8115a 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -3597,6 +3597,10 @@ ALIGNED8 static const u8 texture_font_normal_char_ca_a[] = { #include "textures/segment2/custom_font_normal_char_ca_a.ia4.inc.c" }; +ALIGNED8 static const u8 texture_font_normal_char_ca_ang[] = { +#include "textures/segment2/custom_font_normal_char_ca_ang.ia4.inc.c" +}; + ALIGNED8 static const u8 texture_font_normal_char_ca_c[] = { #include "textures/segment2/custom_font_normal_char_ca_c.ia4.inc.c" }; @@ -3637,6 +3641,10 @@ ALIGNED8 static const u8 texture_font_normal_char_ci_a[] = { #include "textures/segment2/custom_font_normal_char_ci_a.ia4.inc.c" }; +ALIGNED8 static const u8 texture_font_normal_char_ci_c[] = { +#include "textures/segment2/custom_font_normal_char_ci_c.ia4.inc.c" +}; + ALIGNED8 static const u8 texture_font_normal_char_ci_g[] = { #include "textures/segment2/custom_font_normal_char_ci_g.ia4.inc.c" }; @@ -3673,6 +3681,10 @@ ALIGNED8 static const u8 texture_font_normal_char_cu_a[] = { #include "textures/segment2/custom_font_normal_char_cu_a.ia4.inc.c" }; +ALIGNED8 static const u8 texture_font_normal_char_cu_c[] = { +#include "textures/segment2/custom_font_normal_char_cu_c.ia4.inc.c" +}; + ALIGNED8 static const u8 texture_font_normal_char_cu_g[] = { #include "textures/segment2/custom_font_normal_char_cu_g.ia4.inc.c" }; @@ -3693,6 +3705,10 @@ ALIGNED8 static const u8 texture_font_normal_char_la_a[] = { #include "textures/segment2/custom_font_normal_char_la_a.ia4.inc.c" }; +ALIGNED8 static const u8 texture_font_normal_char_la_ang[] = { +#include "textures/segment2/custom_font_normal_char_la_ang.ia4.inc.c" +}; + ALIGNED8 static const u8 texture_font_normal_char_la_c[] = { #include "textures/segment2/custom_font_normal_char_la_c.ia4.inc.c" }; @@ -3733,6 +3749,10 @@ ALIGNED8 static const u8 texture_font_normal_char_li_a[] = { #include "textures/segment2/custom_font_normal_char_li_a.ia4.inc.c" }; +ALIGNED8 static const u8 texture_font_normal_char_li_c[] = { +#include "textures/segment2/custom_font_normal_char_li_c.ia4.inc.c" +}; + ALIGNED8 static const u8 texture_font_normal_char_li_g[] = { #include "textures/segment2/custom_font_normal_char_li_g.ia4.inc.c" }; @@ -3769,6 +3789,10 @@ ALIGNED8 static const u8 texture_font_normal_char_lu_a[] = { #include "textures/segment2/custom_font_normal_char_lu_a.ia4.inc.c" }; +ALIGNED8 static const u8 texture_font_normal_char_lu_c[] = { +#include "textures/segment2/custom_font_normal_char_lu_c.ia4.inc.c" +}; + ALIGNED8 static const u8 texture_font_normal_char_lu_g[] = { #include "textures/segment2/custom_font_normal_char_lu_g.ia4.inc.c" }; @@ -3785,6 +3809,42 @@ ALIGNED8 static const u8 texture_font_normal_char_ly_u[] = { #include "textures/segment2/custom_font_normal_char_ly_u.ia4.inc.c" }; +ALIGNED8 static const u8 texture_font_normal_char_lae[] = { +#include "textures/segment2/custom_font_normal_char_lae.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_cae[] = { +#include "textures/segment2/custom_font_normal_char_cae.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_loe[] = { +#include "textures/segment2/custom_font_normal_char_loe.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_coe[] = { +#include "textures/segment2/custom_font_normal_char_coe.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_leth[] = { +#include "textures/segment2/custom_font_normal_char_leth.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_ceth[] = { +#include "textures/segment2/custom_font_normal_char_ceth.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_los[] = { +#include "textures/segment2/custom_font_normal_char_los.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_cos[] = { +#include "textures/segment2/custom_font_normal_char_cos.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_ss[] = { +#include "textures/segment2/custom_font_normal_char_ss.ia4.inc.c" +}; + ALIGNED8 static const u8 texture_font_normal_char_punc_sp_ex[] = { #include "textures/segment2/custom_font_normal_char_punc_sp_ex.ia4.inc.c" }; @@ -3892,6 +3952,7 @@ const u8* const font_normal_chars[] = { texture_font_char_us_star_filled, // DEL texture_font_normal_char_ca_a, // Á + texture_font_normal_char_ca_ang, // Å texture_font_normal_char_ca_c, //  texture_font_normal_char_ca_g, // À texture_font_normal_char_ca_t, // à @@ -3902,6 +3963,7 @@ const u8* const font_normal_chars[] = { texture_font_normal_char_ce_g, // È texture_font_normal_char_ce_u, // Ë texture_font_normal_char_ci_a, // Í + texture_font_normal_char_ci_c, // Î texture_font_normal_char_ci_g, // Ì texture_font_normal_char_ci_u, // Ï texture_font_normal_char_cn_t, // Ñ @@ -3911,12 +3973,14 @@ const u8* const font_normal_chars[] = { texture_font_normal_char_co_t, // Õ texture_font_normal_char_co_u, // Ö texture_font_normal_char_cu_a, // Ú + texture_font_normal_char_cu_c, // Û texture_font_normal_char_cu_g, // Ù texture_font_normal_char_cu_u, // Ü texture_font_normal_char_cy_a, // Ý texture_font_normal_char_cy_u, // Ÿ texture_font_normal_char_la_a, // á + texture_font_normal_char_la_ang, // å texture_font_normal_char_la_c, // â texture_font_normal_char_la_g, // à texture_font_normal_char_la_t, // ã @@ -3927,6 +3991,7 @@ const u8* const font_normal_chars[] = { texture_font_normal_char_le_g, // è texture_font_normal_char_le_u, // ë texture_font_normal_char_li_a, // í + texture_font_normal_char_li_c, // î texture_font_normal_char_li_g, // ì texture_font_normal_char_li_u, // ï texture_font_normal_char_ln_t, // ñ @@ -3936,11 +4001,22 @@ const u8* const font_normal_chars[] = { texture_font_normal_char_lo_t, // õ texture_font_normal_char_lo_u, // ö texture_font_normal_char_lu_a, // ú + texture_font_normal_char_lu_c, // û texture_font_normal_char_lu_g, // ù texture_font_normal_char_lu_u, // ü texture_font_normal_char_ly_a, // ý texture_font_normal_char_ly_u, // ÿ + texture_font_normal_char_lae, // æ + texture_font_normal_char_cae, // Æ + texture_font_normal_char_loe, // œ + texture_font_normal_char_coe, // Œ + texture_font_normal_char_leth, // ð + texture_font_normal_char_ceth, // Ð + texture_font_normal_char_los, // ø + texture_font_normal_char_cos, // Ø + texture_font_normal_char_ss, // ß + texture_font_normal_char_punc_sp_ex, // ¡ texture_font_normal_char_punc_sp_qu, // ¿ diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index c8fb2136..94169323 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -4,61 +4,78 @@ struct SmCodeGlyph { char unicode[3]; char base; + f32 width; }; struct SmCodeGlyph sSmCodeGlyphs[] = { - { "Á", 'A' }, - { "Â", 'A' }, - { "À", 'A' }, - { "Ã", 'A' }, - { "Ä", 'A' }, - { "Ç", 'C' }, - { "É", 'E' }, - { "Ê", 'E' }, - { "È", 'E' }, - { "Ë", 'E' }, - { "Í", 'I' }, - { "Ì", 'I' }, - { "Ï", 'I' }, - { "Ñ", 'N' }, - { "Ó", 'O' }, - { "Ô", 'O' }, - { "Ò", 'O' }, - { "Õ", 'O' }, - { "Ö", 'O' }, - { "Ú", 'U' }, - { "Ù", 'U' }, - { "Ü", 'U' }, - { "Ý", 'Y' }, - { "Ÿ", 'Y' }, + { "Á", 'A', 0 }, + { "Å", 'A', 0 }, + { "Â", 'A', 0 }, + { "À", 'A', 0 }, + { "Ã", 'A', 0 }, + { "Ä", 'A', 0 }, + { "Ç", 'C', 0 }, + { "É", 'E', 0 }, + { "Ê", 'E', 0 }, + { "È", 'E', 0 }, + { "Ë", 'E', 0 }, + { "Í", 'I', 0 }, + { "Î", 'I', 0 }, + { "Ì", 'I', 0 }, + { "Ï", 'I', 0 }, + { "Ñ", 'N', 0 }, + { "Ó", 'O', 0 }, + { "Ô", 'O', 0 }, + { "Ò", 'O', 0 }, + { "Õ", 'O', 0 }, + { "Ö", 'O', 0 }, + { "Ú", 'U', 0 }, + { "Û", 'U', 0 }, + { "Ù", 'U', 0 }, + { "Ü", 'U', 0 }, + { "Ý", 'Y', 0 }, + { "Ÿ", 'Y', 0 }, - { "á", 'a' }, - { "â", 'a' }, - { "à", 'a' }, - { "ã", 'a' }, - { "ä", 'a' }, - { "ç", 'c' }, - { "é", 'e' }, - { "ê", 'e' }, - { "è", 'e' }, - { "ë", 'e' }, - { "í", 'i' }, - { "ì", 'i' }, - { "ï", 'i' }, - { "ñ", 'n' }, - { "ó", 'o' }, - { "ô", 'o' }, - { "ò", 'o' }, - { "õ", 'o' }, - { "ö", 'o' }, - { "ú", 'u' }, - { "ù", 'u' }, - { "ü", 'u' }, - { "ý", 'y' }, - { "ÿ", 'y' }, + { "á", 'a', 0 }, + { "å", 'a', 0 }, + { "â", 'a', 0 }, + { "à", 'a', 0 }, + { "ã", 'a', 0 }, + { "ä", 'a', 0 }, + { "ç", 'c', 0 }, + { "é", 'e', 0 }, + { "ê", 'e', 0 }, + { "è", 'e', 0 }, + { "ë", 'e', 0 }, + { "í", 'i', 0 }, + { "î", 'i', 0 }, + { "ì", 'i', 0 }, + { "ï", 'i', 0 }, + { "ñ", 'n', 0 }, + { "ó", 'o', 0 }, + { "ô", 'o', 0 }, + { "ò", 'o', 0 }, + { "õ", 'o', 0 }, + { "ö", 'o', 0 }, + { "ú", 'u', 0 }, + { "û", 'u', 0 }, + { "ù", 'u', 0 }, + { "ü", 'u', 0 }, + { "ý", 'y', 0 }, + { "ÿ", 'y', 0 }, - { "¡", '!' }, - { "¿", '?' }, + { "æ", 'a', 0.5000f }, + { "Æ", 'a', 0.6000f }, + { "œ", 'o', 0.5000f }, + { "Œ", 'o', 0.5000f }, + { "ð", 'd', 0 }, + { "Ð", 'D', 0.4375f }, + { "ø", 'o', 0 }, + { "Ø", 'O', 0 }, + { "ß", 'S', 0 }, + + { "¡", '!', 0 }, + { "¿", '?', 0 }, }; @@ -74,6 +91,28 @@ u8 djui_font_convert_smcode_to_base(char c) { return sSmCodeGlyphs[((u8)c - 128)].base; } +void djui_font_convert_to_unicode(char* from, char* to, int length, int maxlength) { + int clen = 0; + int count = 0; + to[0] = '\0'; + while (*from != '\0' && count < length) { + count++; + if ((u8)*from < 128 || !djui_font_valid_smcode(*from)) { + clen = strlen(to); + snprintf(to + clen, maxlength - clen, "%c", *from); + from++; + continue; + } + + int i = (u8)*from - 128; + struct SmCodeGlyph* glyph = &sSmCodeGlyphs[i]; + clen = strlen(to); + snprintf(to + clen, maxlength - clen, "%s", glyph->unicode); + + from++; + } +} + void djui_font_convert_to_smcode(char* text) { size_t glyphCount = sizeof(sSmCodeGlyphs) / sizeof(sSmCodeGlyphs[0]); @@ -159,6 +198,21 @@ static void djui_font_normal_render_char(char c) { static f32 djui_font_normal_char_width(char c) { if (c == ' ') { return 0.30f; } extern const f32 font_normal_widths[]; + + if ((u8)c < 128) { + return font_normal_widths[(u8)c - '!']; + } + + size_t glyphCount = sizeof(sSmCodeGlyphs) / sizeof(sSmCodeGlyphs[0]); + u8 max = 128 + glyphCount; + if ((u8)c > max) { + return font_normal_widths[(u8)'?' - '!']; + } + + if (sSmCodeGlyphs[(u8)c - 128].width > 0) { + return sSmCodeGlyphs[(u8)c - 128].width; + } + c = djui_font_convert_smcode_to_base(c); return font_normal_widths[(u8)c - '!']; } diff --git a/src/pc/djui/djui_font.h b/src/pc/djui/djui_font.h index aff57fdb..082e8234 100644 --- a/src/pc/djui/djui_font.h +++ b/src/pc/djui/djui_font.h @@ -16,5 +16,6 @@ struct DjuiFont { extern const struct DjuiFont* gDjuiFonts[]; u8 djui_font_convert_smcode_to_base(char c); +void djui_font_convert_to_unicode(char* from, char* to, int length, int maxlength); void djui_font_convert_to_smcode(char* text); bool djui_font_valid_smcode(char c); diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index c2cbd8b7..977e82d2 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -236,7 +236,7 @@ bool djui_inputbox_on_key_down(struct DjuiBase *base, int scancode) { if (sHeldControl && (scancode == SCANCODE_C || scancode == SCANCODE_X)) { if (sel[0] != sel[1]) { char clipboardText[256] = { 0 }; - snprintf(clipboardText, fmin(256, 1 + s2 - s1), "%s", &msg[s1]); + djui_font_convert_to_unicode(&msg[s1], clipboardText, fmin(256, 1 + s2 - s1), 255); wm_api->set_clipboard_text(clipboardText); if (scancode == SCANCODE_X) { djui_inputbox_delete_selection(inputbox); diff --git a/textures/segment2/custom_font_normal_char_ca_ang.ia4.png b/textures/segment2/custom_font_normal_char_ca_ang.ia4.png new file mode 100644 index 00000000..8346cd9e Binary files /dev/null and b/textures/segment2/custom_font_normal_char_ca_ang.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_cae.ia4.png b/textures/segment2/custom_font_normal_char_cae.ia4.png new file mode 100644 index 00000000..f8f89c69 Binary files /dev/null and b/textures/segment2/custom_font_normal_char_cae.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_ceth.ia4.png b/textures/segment2/custom_font_normal_char_ceth.ia4.png new file mode 100644 index 00000000..0a0de4be Binary files /dev/null and b/textures/segment2/custom_font_normal_char_ceth.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_squ.ia4.png~ b/textures/segment2/custom_font_normal_char_ci_c.ia4.png similarity index 83% rename from textures/segment2/custom_font_normal_char_squ.ia4.png~ rename to textures/segment2/custom_font_normal_char_ci_c.ia4.png index 183ba19f..e63d8547 100644 Binary files a/textures/segment2/custom_font_normal_char_squ.ia4.png~ and b/textures/segment2/custom_font_normal_char_ci_c.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_coe.ia4.png b/textures/segment2/custom_font_normal_char_coe.ia4.png new file mode 100644 index 00000000..9fe1b666 Binary files /dev/null and b/textures/segment2/custom_font_normal_char_coe.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_cos.ia4.png b/textures/segment2/custom_font_normal_char_cos.ia4.png new file mode 100644 index 00000000..190cab73 Binary files /dev/null and b/textures/segment2/custom_font_normal_char_cos.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_cu_c.ia4.png b/textures/segment2/custom_font_normal_char_cu_c.ia4.png new file mode 100644 index 00000000..79ed515c Binary files /dev/null and b/textures/segment2/custom_font_normal_char_cu_c.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_pcc.ia4.png~ b/textures/segment2/custom_font_normal_char_la_ang.ia4.png similarity index 83% rename from textures/segment2/custom_font_normal_char_pcc.ia4.png~ rename to textures/segment2/custom_font_normal_char_la_ang.ia4.png index e82ff423..450ee909 100644 Binary files a/textures/segment2/custom_font_normal_char_pcc.ia4.png~ and b/textures/segment2/custom_font_normal_char_la_ang.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_lae.ia4.png b/textures/segment2/custom_font_normal_char_lae.ia4.png new file mode 100644 index 00000000..991770e4 Binary files /dev/null and b/textures/segment2/custom_font_normal_char_lae.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_leth.ia4.png b/textures/segment2/custom_font_normal_char_leth.ia4.png new file mode 100644 index 00000000..08c7c1b2 Binary files /dev/null and b/textures/segment2/custom_font_normal_char_leth.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_sex.ia4.png~ b/textures/segment2/custom_font_normal_char_li_c.ia4.png similarity index 85% rename from textures/segment2/custom_font_normal_char_sex.ia4.png~ rename to textures/segment2/custom_font_normal_char_li_c.ia4.png index 0df0de62..de594a94 100644 Binary files a/textures/segment2/custom_font_normal_char_sex.ia4.png~ and b/textures/segment2/custom_font_normal_char_li_c.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_loe.ia4.png b/textures/segment2/custom_font_normal_char_loe.ia4.png new file mode 100644 index 00000000..3b5b38d3 Binary files /dev/null and b/textures/segment2/custom_font_normal_char_loe.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_los.ia4.png b/textures/segment2/custom_font_normal_char_los.ia4.png new file mode 100644 index 00000000..6be1acc8 Binary files /dev/null and b/textures/segment2/custom_font_normal_char_los.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_pc.ia4.png~ b/textures/segment2/custom_font_normal_char_lu_c.ia4.png similarity index 83% rename from textures/segment2/custom_font_normal_char_pc.ia4.png~ rename to textures/segment2/custom_font_normal_char_lu_c.ia4.png index 9b5b6e4a..94b79177 100644 Binary files a/textures/segment2/custom_font_normal_char_pc.ia4.png~ and b/textures/segment2/custom_font_normal_char_lu_c.ia4.png differ diff --git a/textures/segment2/custom_font_normal_char_scn.ia4.png~ b/textures/segment2/custom_font_normal_char_scn.ia4.png~ deleted file mode 100644 index 8c1804c4..00000000 Binary files a/textures/segment2/custom_font_normal_char_scn.ia4.png~ and /dev/null differ diff --git a/textures/segment2/custom_font_normal_char_ss.ia4.png b/textures/segment2/custom_font_normal_char_ss.ia4.png new file mode 100644 index 00000000..f942adc1 Binary files /dev/null and b/textures/segment2/custom_font_normal_char_ss.ia4.png differ