diff --git a/boredos.iso b/boredos.iso index 8240aa8..603d542 100644 Binary files a/boredos.iso and b/boredos.iso differ diff --git a/src/kernel/font_manager.c b/src/kernel/font_manager.c index aa667e4..a4ac6b3 100644 --- a/src/kernel/font_manager.c +++ b/src/kernel/font_manager.c @@ -148,7 +148,13 @@ void font_manager_render_char_scaled(ttf_font_t *font, int x, int y, char c, uin float real_scale = stbtt_ScaleForPixelHeight(info, scale); // Convert pixel size back to stbtt scale int codepoint = (unsigned char)c; - if (codepoint == 128) codepoint = 0x2014; // Unicode emdash + if (codepoint == 128) codepoint = 0x2014; // — (—) + if (codepoint == 129) codepoint = 0x2013; // – (–) + if (codepoint == 130) codepoint = 0x2022; // • (•) + if (codepoint == 131) codepoint = 0x2026; // … (…) + if (codepoint == 132) codepoint = 0x2122; // ™ (™) + if (codepoint == 133) codepoint = 0x20AC; // € (€) + if (codepoint == 134) codepoint = 0x00B7; // · (·) bitmap = stbtt_GetCodepointBitmap(info, 0, real_scale, codepoint, &w, &h, &xoff, &yoff); @@ -205,7 +211,13 @@ int font_manager_get_string_width_scaled(ttf_font_t *font, const char *s, float while (*s) { int advance, lsb; int codepoint = (unsigned char)*s; - if (codepoint == 128) codepoint = 0x2014; // Unicode emdash + if (codepoint == 128) codepoint = 0x2014; // — (—) + if (codepoint == 129) codepoint = 0x2013; // – (–) + if (codepoint == 130) codepoint = 0x2022; // • (•) + if (codepoint == 131) codepoint = 0x2026; // … (…) + if (codepoint == 132) codepoint = 0x2122; // ™ (™) + if (codepoint == 133) codepoint = 0x20AC; // € (€) + if (codepoint == 134) codepoint = 0x00B7; // · (·) stbtt_GetCodepointHMetrics(info, codepoint, &advance, &lsb); // Round per-character to match draw_string's accumulation width += (int)(advance * real_scale + 0.5f); diff --git a/src/kernel/userland/browser.c b/src/kernel/userland/browser.c index 2468930..d0e15d5 100644 --- a/src/kernel/userland/browser.c +++ b/src/kernel/userland/browser.c @@ -264,6 +264,15 @@ static int fetch_content(const char *url, char *dest_buf, int max_len, bool prog int body_len = total - (body - dest_buf); int safe_len = body_len; while (safe_len > 0 && body[safe_len - 1] != '>') safe_len--; + // Avoid splitting an HTML entity (&...;) + int check_amp = total - (body - dest_buf) - 1; + if (check_amp >= safe_len) check_amp = safe_len - 1; + int amp_pos = -1; + for (int k = 0; k < 15 && check_amp - k >= 0; k++) { + if (body[check_amp - k] == ';') break; // Complete entity + if (body[check_amp - k] == '&') { amp_pos = check_amp - k; break; } + } + if (amp_pos != -1) safe_len = amp_pos; if (safe_len > inc_parse_offset) { parse_html_incremental(body, safe_len); browser_paint(); @@ -506,8 +515,17 @@ static void decode_html_entities(char *str) { if (str_istarts_with(src, ">")) { *dst++ = '>'; src += 4; continue; } if (str_istarts_with(src, "'")) { *dst++ = '\''; src += 6; continue; } if (str_istarts_with(src, " ")) { *dst++ = ' '; src += 6; continue; } - if (str_istarts_with(src, "—")) { *dst++ = '-'; *dst++ = '-'; src += 7; continue; } - if (str_istarts_with(src, "–")) { *dst++ = '-'; src += 7; continue; } + if (str_istarts_with(src, "—")) { *dst++ = (char)128; src += 7; continue; } + if (str_istarts_with(src, "&mdash")) { *dst++ = (char)128; src += 6; continue; } // Fallback + if (str_istarts_with(src, "–")) { *dst++ = (char)129; src += 7; continue; } + if (str_istarts_with(src, "&ndash")) { *dst++ = (char)129; src += 6; continue; } + if (str_istarts_with(src, "•")) { *dst++ = (char)130; src += 6; continue; } + if (str_istarts_with(src, "&bull")) { *dst++ = (char)130; src += 5; continue; } + if (str_istarts_with(src, "…")){ *dst++ = (char)131; src += 8; continue; } + if (str_istarts_with(src, "&hellip")){ *dst++ = (char)131; src += 7; continue; } + if (str_istarts_with(src, "™")) { *dst++ = (char)132; src += 7; continue; } + if (str_istarts_with(src, "€")) { *dst++ = (char)133; src += 6; continue; } + if (str_istarts_with(src, "·")){ *dst++ = (char)134; src += 8; continue; } if (str_istarts_with(src, "‘")) { *dst++ = '\''; src += 7; continue; } if (str_istarts_with(src, "’")) { *dst++ = '\''; src += 7; continue; } if (str_istarts_with(src, "“")) { *dst++ = '\"'; src += 7; continue; } @@ -543,9 +561,15 @@ static void decode_html_entities(char *str) { val = strtol(src + 2, &end, 10); } if (end && *end == ';' && end > src + 2) { - if (val == 8216 || val == 8217) val = '\''; + if (val == 8211) val = 129; // – + else if (val == 8212) val = 128; // — + else if (val == 8226) val = 130; // • + else if (val == 8230) val = 131; // … + else if (val == 8482) val = 132; // ™ + else if (val == 8364) val = 133; // € + else if (val == 183) val = 134; // · + else if (val == 8216 || val == 8217) val = '\''; else if (val == 8220 || val == 8221) val = '\"'; - else if (val == 8211 || val == 8212) val = '-'; else if (val == 160) val = ' '; if (val > 0 && val < 256) {