Browse Source

Fix glyph index for bitmap fonts.
Fix TextEdit glyph position rounding.

bruvzg 3 years ago
parent
commit
8c973f21ee
2 changed files with 3 additions and 3 deletions
  1. 1 1
      modules/text_server_adv/text_server_adv.cpp
  2. 2 2
      scene/gui/text_edit.cpp

+ 1 - 1
modules/text_server_adv/text_server_adv.cpp

@@ -2573,7 +2573,7 @@ int32_t TextServerAdvanced::font_get_glyph_index(RID p_font_rid, int p_size, cha
 			return FT_Get_Char_Index(fd->cache[size]->face, p_char);
 			return FT_Get_Char_Index(fd->cache[size]->face, p_char);
 		}
 		}
 	} else {
 	} else {
-		return 0;
+		return (int32_t)p_char;
 	}
 	}
 #else
 #else
 	return (int32_t)p_char;
 	return (int32_t)p_char;

+ 2 - 2
scene/gui/text_edit.cpp

@@ -1135,7 +1135,7 @@ void TextEdit::_notification(int p_what) {
 					int first_visible_char = TS->shaped_text_get_range(rid).y;
 					int first_visible_char = TS->shaped_text_get_range(rid).y;
 					int last_visible_char = TS->shaped_text_get_range(rid).x;
 					int last_visible_char = TS->shaped_text_get_range(rid).x;
 
 
-					int char_ofs = 0;
+					float char_ofs = 0;
 					if (outline_size > 0 && outline_color.a > 0) {
 					if (outline_size > 0 && outline_color.a > 0) {
 						for (int j = 0; j < gl_size; j++) {
 						for (int j = 0; j < gl_size; j++) {
 							for (int k = 0; k < glyphs[j].repeat; k++) {
 							for (int k = 0; k < glyphs[j].repeat; k++) {
@@ -1170,7 +1170,7 @@ void TextEdit::_notification(int p_what) {
 							}
 							}
 						}
 						}
 
 
-						int char_pos = char_ofs + char_margin + ofs_x;
+						float char_pos = char_ofs + char_margin + ofs_x;
 						if (char_pos >= xmargin_beg) {
 						if (char_pos >= xmargin_beg) {
 							if (highlight_matching_braces_enabled) {
 							if (highlight_matching_braces_enabled) {
 								if ((brace_open_match_line == line && brace_open_match_column == glyphs[j].start) ||
 								if ((brace_open_match_line == line && brace_open_match_column == glyphs[j].start) ||