Skip to content

Commit

Permalink
Revert "Revert "[7_14] Fix crash when pasting the source code of image""
Browse files Browse the repository at this point in the history
This reverts commit e9bb42e.
  • Loading branch information
da-liii committed Nov 13, 2024
1 parent 1851c00 commit 511b59f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Graphics/Fonts/smart_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,15 @@ init_unicode_substitution () {

int
get_utf8_code (string c) {
int c_N= N (c);
if (c_N <= 2 || c_N > 6) {
// the largest unicode is U+10FFFF
return -1;
}
string uc = strict_cork_to_utf8 (c);
int pos = 0;
int code= decode_from_utf8 (uc, pos);
if (pos == N (uc)) return code;
if (pos == c_N) return code;
else return -1;
}

Expand Down
6 changes: 5 additions & 1 deletion src/Plugins/Freetype/unicode_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,11 @@ unicode_font_rep::index_glyph (string s, font_metric& rm, font_glyphs& rg) {

static bool
is_math_italic (string c) {
if (N (c) <= 2) return false;
int c_N= N (c);
if (c_N <= 2 || c_N > 6) {
// the largest unicode is U+10FFFF
return false;
}
int i = 0;
int code= decode_from_utf8 (strict_cork_to_utf8 (c), i);
if (code < 0x2100 || code > 0x1d7ff) return false;
Expand Down

0 comments on commit 511b59f

Please sign in to comment.