This commit is contained in:
Spartan322
2025-05-22 14:01:21 -04:00
441 changed files with 14189 additions and 7714 deletions

View File

@@ -3836,7 +3836,8 @@ bool TextServerFallback::_shaped_text_resize_object(const RID &p_shaped, const V
} else if (sd->preserve_invalid || (sd->preserve_control && is_control(gl.index))) {
// Glyph not found, replace with hex code box.
if (sd->orientation == ORIENTATION_HORIZONTAL) {
sd->ascent = MAX(sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y);
sd->ascent = MAX(sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y * 0.85);
sd->descent = MAX(sd->descent, get_hex_code_box_size(gl.font_size, gl.index).y * 0.15);
} else {
sd->ascent = MAX(sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5));
sd->descent = MAX(sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5));
@@ -4015,7 +4016,8 @@ RID TextServerFallback::_shaped_text_substr(const RID &p_shaped, int64_t p_start
} else if (new_sd->preserve_invalid || (new_sd->preserve_control && is_control(gl.index))) {
// Glyph not found, replace with hex code box.
if (new_sd->orientation == ORIENTATION_HORIZONTAL) {
new_sd->ascent = MAX(new_sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y);
new_sd->ascent = MAX(new_sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y * 0.85);
new_sd->descent = MAX(new_sd->descent, get_hex_code_box_size(gl.font_size, gl.index).y * 0.15);
} else {
new_sd->ascent = MAX(new_sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5));
new_sd->descent = MAX(new_sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5));
@@ -4832,7 +4834,8 @@ bool TextServerFallback::_shaped_text_shape(const RID &p_shaped) {
// Glyph not found, replace with hex code box.
if (sd->orientation == ORIENTATION_HORIZONTAL) {
gl.advance = get_hex_code_box_size(gl.font_size, gl.index).x;
sd->ascent = MAX(sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y);
sd->ascent = MAX(sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y * 0.85);
sd->descent = MAX(sd->descent, get_hex_code_box_size(gl.font_size, gl.index).y * 0.15);
} else {
gl.advance = get_hex_code_box_size(gl.font_size, gl.index).y;
sd->ascent = MAX(sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5));

View File

@@ -228,27 +228,31 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin
float svg_width, svg_height;
picture->size(&svg_width, &svg_height);
double aspect = svg_width / svg_height;
double aspect_x = (svg_width > svg_height) ? svg_width / svg_height : 1.0;
double aspect_y = (svg_width < svg_height) ? svg_height / svg_width : 1.0;
result = picture->size(embox_x * aspect, embox_y);
result = picture->size(embox_x * aspect_x, embox_y * aspect_y);
if (result != tvg::Result::Success) {
ERR_FAIL_V_MSG(FT_Err_Invalid_SVG_Document, "Failed to resize SVG document.");
}
double x_svg_to_out = (double)metrics.x_ppem / embox_x;
double y_svg_to_out = (double)metrics.y_ppem / embox_y;
double scale = double(embox_x * aspect_x) / double(svg_width);
double yoff = double(document->metrics.ascender + document->metrics.descender) / double(document->metrics.ascender);
double x_svg_to_out = (double)metrics.x_ppem / embox_x / scale;
double y_svg_to_out = (double)metrics.y_ppem / embox_y / scale;
gl_state.m.e11 = (double)document->transform.xx / (1 << 16);
gl_state.m.e12 = -(double)document->transform.xy / (1 << 16);
gl_state.m.e21 = -(double)document->transform.yx / (1 << 16);
gl_state.m.e22 = (double)document->transform.yy / (1 << 16);
gl_state.m.e13 = (double)document->delta.x / 64 * embox_x / metrics.x_ppem;
gl_state.m.e23 = -(double)document->delta.y / 64 * embox_y / metrics.y_ppem;
gl_state.m.e13 = (double)document->delta.x / 64 * embox_x / metrics.x_ppem * scale;
gl_state.m.e23 = -(double)document->delta.y / 64 * embox_y / metrics.y_ppem * scale;
gl_state.m.e31 = 0;
gl_state.m.e32 = 0;
gl_state.m.e33 = 1;
result = picture->size(embox_x * aspect * x_svg_to_out, embox_y * y_svg_to_out);
result = picture->size(embox_x * aspect_x * x_svg_to_out, embox_y * aspect_y * y_svg_to_out);
if (result != tvg::Result::Success) {
ERR_FAIL_V_MSG(FT_Err_Invalid_SVG_Document, "Failed to resize SVG document.");
}
@@ -259,8 +263,9 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin
}
picture->size(&gl_state.w, &gl_state.h);
gl_state.x = (gl_state.h - gl_state.w) / 2.0;
gl_state.y = -gl_state.h;
gl_state.x = (double(p_slot->metrics.horiAdvance) / 64.0 - gl_state.w) / 2.0;
gl_state.y = -Math::ceil(gl_state.h * yoff);
gl_state.ready = true;
}