Skip to content

Commit 980e4d7

Browse files
committed
Merge pull request godotengine#90349 from bruvzg/empty_glyph_test
[TextServer] Improve empty glyph handling to allow glyphs smaller than 2px and avoid unnecessary texture updates.
2 parents 2e1f337 + 1f8387f commit 980e4d7

File tree

4 files changed

+107
-88
lines changed

4 files changed

+107
-88
lines changed

modules/text_server_adv/text_server_adv.cpp

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ void TextServerAdvanced::_generateMTSDF_threaded(void *p_td, uint32_t p_y) {
958958
}
959959
}
960960

961-
_FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(FontAdvanced *p_font_data, FontForSizeAdvanced *p_data, int p_pixel_range, int p_rect_margin, FT_Outline *outline, const Vector2 &advance) const {
961+
_FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(FontAdvanced *p_font_data, FontForSizeAdvanced *p_data, int p_pixel_range, int p_rect_margin, FT_Outline *p_outline, const Vector2 &p_advance) const {
962962
msdfgen::Shape shape;
963963

964964
shape.contours.clear();
@@ -974,13 +974,13 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(
974974
ft_functions.shift = 0;
975975
ft_functions.delta = 0;
976976

977-
int error = FT_Outline_Decompose(outline, &ft_functions, &context);
977+
int error = FT_Outline_Decompose(p_outline, &ft_functions, &context);
978978
ERR_FAIL_COND_V_MSG(error, FontGlyph(), "FreeType: Outline decomposition error: '" + String(FT_Error_String(error)) + "'.");
979979
if (!shape.contours.empty() && shape.contours.back().edges.empty()) {
980980
shape.contours.pop_back();
981981
}
982982

983-
if (FT_Outline_Get_Orientation(outline) == 1) {
983+
if (FT_Outline_Get_Orientation(p_outline) == 1) {
984984
for (int i = 0; i < (int)shape.contours.size(); ++i) {
985985
shape.contours[i].reverse();
986986
}
@@ -993,12 +993,19 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(
993993

994994
FontGlyph chr;
995995
chr.found = true;
996-
chr.advance = advance;
996+
chr.advance = p_advance;
997997

998998
if (shape.validate() && shape.contours.size() > 0) {
999999
int w = (bounds.r - bounds.l);
10001000
int h = (bounds.t - bounds.b);
10011001

1002+
if (w == 0 || h == 0) {
1003+
chr.texture_idx = -1;
1004+
chr.uv_rect = Rect2();
1005+
chr.rect = Rect2();
1006+
return chr;
1007+
}
1008+
10021009
int mw = w + p_rect_margin * 4;
10031010
int mh = h + p_rect_margin * 4;
10041011

@@ -1056,12 +1063,24 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(
10561063
#endif
10571064

10581065
#ifdef MODULE_FREETYPE_ENABLED
1059-
_FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitmap(FontForSizeAdvanced *p_data, int p_rect_margin, FT_Bitmap bitmap, int yofs, int xofs, const Vector2 &advance, bool p_bgra) const {
1060-
int w = bitmap.width;
1061-
int h = bitmap.rows;
1066+
_FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitmap(FontForSizeAdvanced *p_data, int p_rect_margin, FT_Bitmap p_bitmap, int p_yofs, int p_xofs, const Vector2 &p_advance, bool p_bgra) const {
1067+
FontGlyph chr;
1068+
chr.advance = p_advance * p_data->scale / p_data->oversampling;
1069+
chr.found = true;
1070+
1071+
int w = p_bitmap.width;
1072+
int h = p_bitmap.rows;
1073+
1074+
if (w == 0 || h == 0) {
1075+
chr.texture_idx = -1;
1076+
chr.uv_rect = Rect2();
1077+
chr.rect = Rect2();
1078+
return chr;
1079+
}
1080+
10621081
int color_size = 2;
10631082

1064-
switch (bitmap.pixel_mode) {
1083+
switch (p_bitmap.pixel_mode) {
10651084
case FT_PIXEL_MODE_MONO:
10661085
case FT_PIXEL_MODE_GRAY: {
10671086
color_size = 2;
@@ -1100,54 +1119,54 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma
11001119
for (int j = 0; j < w; j++) {
11011120
int ofs = ((i + tex_pos.y + p_rect_margin * 2) * tex.texture_w + j + tex_pos.x + p_rect_margin * 2) * color_size;
11021121
ERR_FAIL_COND_V(ofs >= tex.image->data_size(), FontGlyph());
1103-
switch (bitmap.pixel_mode) {
1122+
switch (p_bitmap.pixel_mode) {
11041123
case FT_PIXEL_MODE_MONO: {
1105-
int byte = i * bitmap.pitch + (j >> 3);
1124+
int byte = i * p_bitmap.pitch + (j >> 3);
11061125
int bit = 1 << (7 - (j % 8));
11071126
wr[ofs + 0] = 255; // grayscale as 1
1108-
wr[ofs + 1] = (bitmap.buffer[byte] & bit) ? 255 : 0;
1127+
wr[ofs + 1] = (p_bitmap.buffer[byte] & bit) ? 255 : 0;
11091128
} break;
11101129
case FT_PIXEL_MODE_GRAY:
11111130
wr[ofs + 0] = 255; // grayscale as 1
1112-
wr[ofs + 1] = bitmap.buffer[i * bitmap.pitch + j];
1131+
wr[ofs + 1] = p_bitmap.buffer[i * p_bitmap.pitch + j];
11131132
break;
11141133
case FT_PIXEL_MODE_BGRA: {
1115-
int ofs_color = i * bitmap.pitch + (j << 2);
1116-
wr[ofs + 2] = bitmap.buffer[ofs_color + 0];
1117-
wr[ofs + 1] = bitmap.buffer[ofs_color + 1];
1118-
wr[ofs + 0] = bitmap.buffer[ofs_color + 2];
1119-
wr[ofs + 3] = bitmap.buffer[ofs_color + 3];
1134+
int ofs_color = i * p_bitmap.pitch + (j << 2);
1135+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + 0];
1136+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + 1];
1137+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + 2];
1138+
wr[ofs + 3] = p_bitmap.buffer[ofs_color + 3];
11201139
} break;
11211140
case FT_PIXEL_MODE_LCD: {
1122-
int ofs_color = i * bitmap.pitch + (j * 3);
1141+
int ofs_color = i * p_bitmap.pitch + (j * 3);
11231142
if (p_bgra) {
1124-
wr[ofs + 0] = bitmap.buffer[ofs_color + 2];
1125-
wr[ofs + 1] = bitmap.buffer[ofs_color + 1];
1126-
wr[ofs + 2] = bitmap.buffer[ofs_color + 0];
1143+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + 2];
1144+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + 1];
1145+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + 0];
11271146
wr[ofs + 3] = 255;
11281147
} else {
1129-
wr[ofs + 0] = bitmap.buffer[ofs_color + 0];
1130-
wr[ofs + 1] = bitmap.buffer[ofs_color + 1];
1131-
wr[ofs + 2] = bitmap.buffer[ofs_color + 2];
1148+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + 0];
1149+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + 1];
1150+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + 2];
11321151
wr[ofs + 3] = 255;
11331152
}
11341153
} break;
11351154
case FT_PIXEL_MODE_LCD_V: {
1136-
int ofs_color = i * bitmap.pitch * 3 + j;
1155+
int ofs_color = i * p_bitmap.pitch * 3 + j;
11371156
if (p_bgra) {
1138-
wr[ofs + 0] = bitmap.buffer[ofs_color + bitmap.pitch * 2];
1139-
wr[ofs + 1] = bitmap.buffer[ofs_color + bitmap.pitch];
1140-
wr[ofs + 2] = bitmap.buffer[ofs_color + 0];
1157+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + p_bitmap.pitch * 2];
1158+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + p_bitmap.pitch];
1159+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + 0];
11411160
wr[ofs + 3] = 255;
11421161
} else {
1143-
wr[ofs + 0] = bitmap.buffer[ofs_color + 0];
1144-
wr[ofs + 1] = bitmap.buffer[ofs_color + bitmap.pitch];
1145-
wr[ofs + 2] = bitmap.buffer[ofs_color + bitmap.pitch * 2];
1162+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + 0];
1163+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + p_bitmap.pitch];
1164+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + p_bitmap.pitch * 2];
11461165
wr[ofs + 3] = 255;
11471166
}
11481167
} break;
11491168
default:
1150-
ERR_FAIL_V_MSG(FontGlyph(), "Font uses unsupported pixel format: " + String::num_int64(bitmap.pixel_mode) + ".");
1169+
ERR_FAIL_V_MSG(FontGlyph(), "Font uses unsupported pixel format: " + String::num_int64(p_bitmap.pixel_mode) + ".");
11511170
break;
11521171
}
11531172
}
@@ -1156,13 +1175,10 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma
11561175

11571176
tex.dirty = true;
11581177

1159-
FontGlyph chr;
1160-
chr.advance = advance * p_data->scale / p_data->oversampling;
11611178
chr.texture_idx = tex_pos.index;
1162-
chr.found = true;
11631179

11641180
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w + p_rect_margin * 2, h + p_rect_margin * 2);
1165-
chr.rect.position = Vector2(xofs - p_rect_margin, -yofs - p_rect_margin) * p_data->scale / p_data->oversampling;
1181+
chr.rect.position = Vector2(p_xofs - p_rect_margin, -p_yofs - p_rect_margin) * p_data->scale / p_data->oversampling;
11661182
chr.rect.size = chr.uv_rect.size * p_data->scale / p_data->oversampling;
11671183
return chr;
11681184
}
@@ -3619,9 +3635,6 @@ void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
36193635

36203636
const FontGlyph &gl = fd->cache[size]->glyph_map[index];
36213637
if (gl.found) {
3622-
if (gl.uv_rect.size.x <= 2 || gl.uv_rect.size.y <= 2) {
3623-
return; // Nothing to draw.
3624-
}
36253638
ERR_FAIL_COND(gl.texture_idx < -1 || gl.texture_idx >= fd->cache[size]->textures.size());
36263639

36273640
if (gl.texture_idx != -1) {
@@ -3730,9 +3743,6 @@ void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const R
37303743

37313744
const FontGlyph &gl = fd->cache[size]->glyph_map[index];
37323745
if (gl.found) {
3733-
if (gl.uv_rect.size.x <= 2 || gl.uv_rect.size.y <= 2) {
3734-
return; // Nothing to draw.
3735-
}
37363746
ERR_FAIL_COND(gl.texture_idx < -1 || gl.texture_idx >= fd->cache[size]->textures.size());
37373747

37383748
if (gl.texture_idx != -1) {

modules/text_server_adv/text_server_adv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,10 @@ class TextServerAdvanced : public TextServerExtension {
354354

355355
_FORCE_INLINE_ FontTexturePosition find_texture_pos_for_glyph(FontForSizeAdvanced *p_data, int p_color_size, Image::Format p_image_format, int p_width, int p_height, bool p_msdf) const;
356356
#ifdef MODULE_MSDFGEN_ENABLED
357-
_FORCE_INLINE_ FontGlyph rasterize_msdf(FontAdvanced *p_font_data, FontForSizeAdvanced *p_data, int p_pixel_range, int p_rect_margin, FT_Outline *outline, const Vector2 &advance) const;
357+
_FORCE_INLINE_ FontGlyph rasterize_msdf(FontAdvanced *p_font_data, FontForSizeAdvanced *p_data, int p_pixel_range, int p_rect_margin, FT_Outline *p_outline, const Vector2 &p_advance) const;
358358
#endif
359359
#ifdef MODULE_FREETYPE_ENABLED
360-
_FORCE_INLINE_ FontGlyph rasterize_bitmap(FontForSizeAdvanced *p_data, int p_rect_margin, FT_Bitmap bitmap, int yofs, int xofs, const Vector2 &advance, bool p_bgra) const;
360+
_FORCE_INLINE_ FontGlyph rasterize_bitmap(FontForSizeAdvanced *p_data, int p_rect_margin, FT_Bitmap p_bitmap, int p_yofs, int p_xofs, const Vector2 &p_advance, bool p_bgra) const;
361361
#endif
362362
_FORCE_INLINE_ bool _ensure_glyph(FontAdvanced *p_font_data, const Vector2i &p_size, int32_t p_glyph) const;
363363
_FORCE_INLINE_ bool _ensure_cache_for_size(FontAdvanced *p_font_data, const Vector2i &p_size) const;

modules/text_server_fb/text_server_fb.cpp

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ void TextServerFallback::_generateMTSDF_threaded(void *p_td, uint32_t p_y) {
394394
}
395395
}
396396

397-
_FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf(FontFallback *p_font_data, FontForSizeFallback *p_data, int p_pixel_range, int p_rect_margin, FT_Outline *outline, const Vector2 &advance) const {
397+
_FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf(FontFallback *p_font_data, FontForSizeFallback *p_data, int p_pixel_range, int p_rect_margin, FT_Outline *p_outline, const Vector2 &p_advance) const {
398398
msdfgen::Shape shape;
399399

400400
shape.contours.clear();
@@ -410,13 +410,13 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf(
410410
ft_functions.shift = 0;
411411
ft_functions.delta = 0;
412412

413-
int error = FT_Outline_Decompose(outline, &ft_functions, &context);
413+
int error = FT_Outline_Decompose(p_outline, &ft_functions, &context);
414414
ERR_FAIL_COND_V_MSG(error, FontGlyph(), "FreeType: Outline decomposition error: '" + String(FT_Error_String(error)) + "'.");
415415
if (!shape.contours.empty() && shape.contours.back().edges.empty()) {
416416
shape.contours.pop_back();
417417
}
418418

419-
if (FT_Outline_Get_Orientation(outline) == 1) {
419+
if (FT_Outline_Get_Orientation(p_outline) == 1) {
420420
for (int i = 0; i < (int)shape.contours.size(); ++i) {
421421
shape.contours[i].reverse();
422422
}
@@ -429,12 +429,18 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf(
429429

430430
FontGlyph chr;
431431
chr.found = true;
432-
chr.advance = advance;
432+
chr.advance = p_advance;
433433

434434
if (shape.validate() && shape.contours.size() > 0) {
435435
int w = (bounds.r - bounds.l);
436436
int h = (bounds.t - bounds.b);
437437

438+
if (w == 0 || h == 0) {
439+
chr.texture_idx = -1;
440+
chr.uv_rect = Rect2();
441+
chr.rect = Rect2();
442+
return chr;
443+
}
438444
int mw = w + p_rect_margin * 4;
439445
int mh = h + p_rect_margin * 4;
440446

@@ -491,12 +497,24 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf(
491497
#endif
492498

493499
#ifdef MODULE_FREETYPE_ENABLED
494-
_FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitmap(FontForSizeFallback *p_data, int p_rect_margin, FT_Bitmap bitmap, int yofs, int xofs, const Vector2 &advance, bool p_bgra) const {
495-
int w = bitmap.width;
496-
int h = bitmap.rows;
500+
_FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitmap(FontForSizeFallback *p_data, int p_rect_margin, FT_Bitmap p_bitmap, int p_yofs, int p_xofs, const Vector2 &p_advance, bool p_bgra) const {
501+
FontGlyph chr;
502+
chr.advance = p_advance * p_data->scale / p_data->oversampling;
503+
chr.found = true;
504+
505+
int w = p_bitmap.width;
506+
int h = p_bitmap.rows;
507+
508+
if (w == 0 || h == 0) {
509+
chr.texture_idx = -1;
510+
chr.uv_rect = Rect2();
511+
chr.rect = Rect2();
512+
return chr;
513+
}
514+
497515
int color_size = 2;
498516

499-
switch (bitmap.pixel_mode) {
517+
switch (p_bitmap.pixel_mode) {
500518
case FT_PIXEL_MODE_MONO:
501519
case FT_PIXEL_MODE_GRAY: {
502520
color_size = 2;
@@ -535,54 +553,54 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma
535553
for (int j = 0; j < w; j++) {
536554
int ofs = ((i + tex_pos.y + p_rect_margin * 2) * tex.texture_w + j + tex_pos.x + p_rect_margin * 2) * color_size;
537555
ERR_FAIL_COND_V(ofs >= tex.image->data_size(), FontGlyph());
538-
switch (bitmap.pixel_mode) {
556+
switch (p_bitmap.pixel_mode) {
539557
case FT_PIXEL_MODE_MONO: {
540-
int byte = i * bitmap.pitch + (j >> 3);
558+
int byte = i * p_bitmap.pitch + (j >> 3);
541559
int bit = 1 << (7 - (j % 8));
542560
wr[ofs + 0] = 255; // grayscale as 1
543-
wr[ofs + 1] = (bitmap.buffer[byte] & bit) ? 255 : 0;
561+
wr[ofs + 1] = (p_bitmap.buffer[byte] & bit) ? 255 : 0;
544562
} break;
545563
case FT_PIXEL_MODE_GRAY:
546564
wr[ofs + 0] = 255; // grayscale as 1
547-
wr[ofs + 1] = bitmap.buffer[i * bitmap.pitch + j];
565+
wr[ofs + 1] = p_bitmap.buffer[i * p_bitmap.pitch + j];
548566
break;
549567
case FT_PIXEL_MODE_BGRA: {
550-
int ofs_color = i * bitmap.pitch + (j << 2);
551-
wr[ofs + 2] = bitmap.buffer[ofs_color + 0];
552-
wr[ofs + 1] = bitmap.buffer[ofs_color + 1];
553-
wr[ofs + 0] = bitmap.buffer[ofs_color + 2];
554-
wr[ofs + 3] = bitmap.buffer[ofs_color + 3];
568+
int ofs_color = i * p_bitmap.pitch + (j << 2);
569+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + 0];
570+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + 1];
571+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + 2];
572+
wr[ofs + 3] = p_bitmap.buffer[ofs_color + 3];
555573
} break;
556574
case FT_PIXEL_MODE_LCD: {
557-
int ofs_color = i * bitmap.pitch + (j * 3);
575+
int ofs_color = i * p_bitmap.pitch + (j * 3);
558576
if (p_bgra) {
559-
wr[ofs + 0] = bitmap.buffer[ofs_color + 2];
560-
wr[ofs + 1] = bitmap.buffer[ofs_color + 1];
561-
wr[ofs + 2] = bitmap.buffer[ofs_color + 0];
577+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + 2];
578+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + 1];
579+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + 0];
562580
wr[ofs + 3] = 255;
563581
} else {
564-
wr[ofs + 0] = bitmap.buffer[ofs_color + 0];
565-
wr[ofs + 1] = bitmap.buffer[ofs_color + 1];
566-
wr[ofs + 2] = bitmap.buffer[ofs_color + 2];
582+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + 0];
583+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + 1];
584+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + 2];
567585
wr[ofs + 3] = 255;
568586
}
569587
} break;
570588
case FT_PIXEL_MODE_LCD_V: {
571-
int ofs_color = i * bitmap.pitch * 3 + j;
589+
int ofs_color = i * p_bitmap.pitch * 3 + j;
572590
if (p_bgra) {
573-
wr[ofs + 0] = bitmap.buffer[ofs_color + bitmap.pitch * 2];
574-
wr[ofs + 1] = bitmap.buffer[ofs_color + bitmap.pitch];
575-
wr[ofs + 2] = bitmap.buffer[ofs_color + 0];
591+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + p_bitmap.pitch * 2];
592+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + p_bitmap.pitch];
593+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + 0];
576594
wr[ofs + 3] = 255;
577595
} else {
578-
wr[ofs + 0] = bitmap.buffer[ofs_color + 0];
579-
wr[ofs + 1] = bitmap.buffer[ofs_color + bitmap.pitch];
580-
wr[ofs + 2] = bitmap.buffer[ofs_color + bitmap.pitch * 2];
596+
wr[ofs + 0] = p_bitmap.buffer[ofs_color + 0];
597+
wr[ofs + 1] = p_bitmap.buffer[ofs_color + p_bitmap.pitch];
598+
wr[ofs + 2] = p_bitmap.buffer[ofs_color + p_bitmap.pitch * 2];
581599
wr[ofs + 3] = 255;
582600
}
583601
} break;
584602
default:
585-
ERR_FAIL_V_MSG(FontGlyph(), "Font uses unsupported pixel format: " + String::num_int64(bitmap.pixel_mode) + ".");
603+
ERR_FAIL_V_MSG(FontGlyph(), "Font uses unsupported pixel format: " + String::num_int64(p_bitmap.pixel_mode) + ".");
586604
break;
587605
}
588606
}
@@ -591,13 +609,10 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma
591609

592610
tex.dirty = true;
593611

594-
FontGlyph chr;
595-
chr.advance = advance * p_data->scale / p_data->oversampling;
596612
chr.texture_idx = tex_pos.index;
597-
chr.found = true;
598613

599614
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w + p_rect_margin * 2, h + p_rect_margin * 2);
600-
chr.rect.position = Vector2(xofs - p_rect_margin, -yofs - p_rect_margin) * p_data->scale / p_data->oversampling;
615+
chr.rect.position = Vector2(p_xofs - p_rect_margin, -p_yofs - p_rect_margin) * p_data->scale / p_data->oversampling;
601616
chr.rect.size = chr.uv_rect.size * p_data->scale / p_data->oversampling;
602617
return chr;
603618
}
@@ -2567,9 +2582,6 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
25672582

25682583
const FontGlyph &gl = fd->cache[size]->glyph_map[index];
25692584
if (gl.found) {
2570-
if (gl.uv_rect.size.x <= 2 || gl.uv_rect.size.y <= 2) {
2571-
return; // Nothing to draw.
2572-
}
25732585
ERR_FAIL_COND(gl.texture_idx < -1 || gl.texture_idx >= fd->cache[size]->textures.size());
25742586

25752587
if (gl.texture_idx != -1) {
@@ -2678,9 +2690,6 @@ void TextServerFallback::_font_draw_glyph_outline(const RID &p_font_rid, const R
26782690

26792691
const FontGlyph &gl = fd->cache[size]->glyph_map[index];
26802692
if (gl.found) {
2681-
if (gl.uv_rect.size.x <= 2 || gl.uv_rect.size.y <= 2) {
2682-
return; // Nothing to draw.
2683-
}
26842693
ERR_FAIL_COND(gl.texture_idx < -1 || gl.texture_idx >= fd->cache[size]->textures.size());
26852694

26862695
if (gl.texture_idx != -1) {

0 commit comments

Comments
 (0)