Merge pull request #98664 from bruvzg/ts_reset_subpixel_shift
[TextServer] Reset subpixel shift on blank glyphs.
This commit is contained in:
commit
fa264115ce
18 changed files with 185 additions and 6 deletions
|
|
@ -2467,6 +2467,22 @@ TextServer::SubpixelPositioning TextServerAdvanced::_font_get_subpixel_positioni
|
|||
return fd->subpixel_positioning;
|
||||
}
|
||||
|
||||
void TextServerAdvanced::_font_set_keep_rounding_remainders(const RID &p_font_rid, bool p_keep_rounding_remainders) {
|
||||
FontAdvanced *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
fd->keep_rounding_remainders = p_keep_rounding_remainders;
|
||||
}
|
||||
|
||||
bool TextServerAdvanced::_font_get_keep_rounding_remainders(const RID &p_font_rid) const {
|
||||
FontAdvanced *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL_V(fd, false);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
return fd->keep_rounding_remainders;
|
||||
}
|
||||
|
||||
void TextServerAdvanced::_font_set_embolden(const RID &p_font_rid, double p_strength) {
|
||||
FontAdvanced *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
|
@ -5195,6 +5211,7 @@ RID TextServerAdvanced::_find_sys_font_for_text(const RID &p_fdef, const String
|
|||
_font_set_force_autohinter(sysf.rid, key.force_autohinter);
|
||||
_font_set_hinting(sysf.rid, key.hinting);
|
||||
_font_set_subpixel_positioning(sysf.rid, key.subpixel_positioning);
|
||||
_font_set_keep_rounding_remainders(sysf.rid, key.keep_rounding_remainders);
|
||||
_font_set_variation_coordinates(sysf.rid, var);
|
||||
_font_set_oversampling(sysf.rid, key.oversampling);
|
||||
_font_set_embolden(sysf.rid, key.embolden);
|
||||
|
|
@ -6235,6 +6252,9 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star
|
|||
#endif
|
||||
|
||||
gl.index = glyph_info[i].codepoint;
|
||||
if ((p_sd->text[glyph_info[i].cluster] == 0x0009) || u_isblank(p_sd->text[glyph_info[i].cluster]) || is_linebreak(p_sd->text[glyph_info[i].cluster])) {
|
||||
adv_rem = 0.0; // Reset on blank.
|
||||
}
|
||||
if (gl.index != 0) {
|
||||
FontGlyph fgl;
|
||||
_ensure_glyph(fd, fss, gl.index | mod, fgl);
|
||||
|
|
@ -6256,12 +6276,16 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star
|
|||
} else {
|
||||
double full_adv = adv_rem + ((double)glyph_pos[i].x_advance / (64.0 / scale) + ea);
|
||||
gl.advance = Math::round(full_adv);
|
||||
adv_rem = full_adv - gl.advance;
|
||||
if (fd->keep_rounding_remainders) {
|
||||
adv_rem = full_adv - gl.advance;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
double full_adv = adv_rem + ((double)glyph_pos[i].y_advance / (64.0 / scale));
|
||||
gl.advance = -Math::round(full_adv);
|
||||
adv_rem = full_adv + gl.advance;
|
||||
if (fd->keep_rounding_remainders) {
|
||||
adv_rem = full_adv + gl.advance;
|
||||
}
|
||||
}
|
||||
if (p_sd->orientation == ORIENTATION_HORIZONTAL) {
|
||||
gl.y_off += _font_get_baseline_offset(gl.font_rid) * (double)(_font_get_ascent(gl.font_rid, gl.font_size) + _font_get_descent(gl.font_rid, gl.font_size));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue