Added 15 more characters

This commit is contained in:
MysterD 2023-03-28 16:14:48 -07:00
parent ccbe0a186b
commit 3a8fa721ac
20 changed files with 182 additions and 51 deletions

View File

@ -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, // ¿

View File

@ -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 - '!'];
}

View File

@ -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);

View File

@ -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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 B

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 B

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B