[TextServer] Reset subpixel shift on blank glyphs and import option to enable/disable it.
This commit is contained in:
@ -1468,6 +1468,22 @@ TextServer::SubpixelPositioning TextServerFallback::_font_get_subpixel_positioni
|
||||
return fd->subpixel_positioning;
|
||||
}
|
||||
|
||||
void TextServerFallback::_font_set_keep_rounding_remainders(const RID &p_font_rid, bool p_keep_rounding_remainders) {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
fd->keep_rounding_remainders = p_keep_rounding_remainders;
|
||||
}
|
||||
|
||||
bool TextServerFallback::_font_get_keep_rounding_remainders(const RID &p_font_rid) const {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL_V(fd, false);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
return fd->keep_rounding_remainders;
|
||||
}
|
||||
|
||||
void TextServerFallback::_font_set_embolden(const RID &p_font_rid, double p_strength) {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
@ -4007,6 +4023,7 @@ RID TextServerFallback::_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);
|
||||
|
||||
@ -270,6 +270,7 @@ class TextServerFallback : public TextServerExtension {
|
||||
bool allow_system_fallback = true;
|
||||
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
|
||||
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
|
||||
bool keep_rounding_remainders = true;
|
||||
Dictionary variation_coordinates;
|
||||
double oversampling = 0.0;
|
||||
double embolden = 0.0;
|
||||
@ -495,6 +496,7 @@ class TextServerFallback : public TextServerExtension {
|
||||
int fixed_size = 0;
|
||||
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
|
||||
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
|
||||
bool keep_rounding_remainders = true;
|
||||
Dictionary variation_coordinates;
|
||||
double oversampling = 0.0;
|
||||
double embolden = 0.0;
|
||||
@ -503,7 +505,7 @@ class TextServerFallback : public TextServerExtension {
|
||||
double baseline_offset = 0.0;
|
||||
|
||||
bool operator==(const SystemFontKey &p_b) const {
|
||||
return (font_name == p_b.font_name) && (antialiasing == p_b.antialiasing) && (italic == p_b.italic) && (disable_embedded_bitmaps == p_b.disable_embedded_bitmaps) && (mipmaps == p_b.mipmaps) && (msdf == p_b.msdf) && (force_autohinter == p_b.force_autohinter) && (weight == p_b.weight) && (stretch == p_b.stretch) && (msdf_range == p_b.msdf_range) && (msdf_source_size == p_b.msdf_source_size) && (fixed_size == p_b.fixed_size) && (hinting == p_b.hinting) && (subpixel_positioning == p_b.subpixel_positioning) && (variation_coordinates == p_b.variation_coordinates) && (oversampling == p_b.oversampling) && (embolden == p_b.embolden) && (transform == p_b.transform) && (extra_spacing[SPACING_TOP] == p_b.extra_spacing[SPACING_TOP]) && (extra_spacing[SPACING_BOTTOM] == p_b.extra_spacing[SPACING_BOTTOM]) && (extra_spacing[SPACING_SPACE] == p_b.extra_spacing[SPACING_SPACE]) && (extra_spacing[SPACING_GLYPH] == p_b.extra_spacing[SPACING_GLYPH]) && (baseline_offset == p_b.baseline_offset);
|
||||
return (font_name == p_b.font_name) && (antialiasing == p_b.antialiasing) && (italic == p_b.italic) && (disable_embedded_bitmaps == p_b.disable_embedded_bitmaps) && (mipmaps == p_b.mipmaps) && (msdf == p_b.msdf) && (force_autohinter == p_b.force_autohinter) && (weight == p_b.weight) && (stretch == p_b.stretch) && (msdf_range == p_b.msdf_range) && (msdf_source_size == p_b.msdf_source_size) && (fixed_size == p_b.fixed_size) && (hinting == p_b.hinting) && (subpixel_positioning == p_b.subpixel_positioning) && (keep_rounding_remainders == p_b.keep_rounding_remainders) && (variation_coordinates == p_b.variation_coordinates) && (oversampling == p_b.oversampling) && (embolden == p_b.embolden) && (transform == p_b.transform) && (extra_spacing[SPACING_TOP] == p_b.extra_spacing[SPACING_TOP]) && (extra_spacing[SPACING_BOTTOM] == p_b.extra_spacing[SPACING_BOTTOM]) && (extra_spacing[SPACING_SPACE] == p_b.extra_spacing[SPACING_SPACE]) && (extra_spacing[SPACING_GLYPH] == p_b.extra_spacing[SPACING_GLYPH]) && (baseline_offset == p_b.baseline_offset);
|
||||
}
|
||||
|
||||
SystemFontKey(const String &p_font_name, bool p_italic, int p_weight, int p_stretch, RID p_font, const TextServerFallback *p_fb) {
|
||||
@ -521,6 +523,7 @@ class TextServerFallback : public TextServerExtension {
|
||||
force_autohinter = p_fb->_font_is_force_autohinter(p_font);
|
||||
hinting = p_fb->_font_get_hinting(p_font);
|
||||
subpixel_positioning = p_fb->_font_get_subpixel_positioning(p_font);
|
||||
keep_rounding_remainders = p_fb->_font_get_keep_rounding_remainders(p_font);
|
||||
variation_coordinates = p_fb->_font_get_variation_coordinates(p_font);
|
||||
oversampling = p_fb->_font_get_oversampling(p_font);
|
||||
embolden = p_fb->_font_get_embolden(p_font);
|
||||
@ -563,7 +566,7 @@ class TextServerFallback : public TextServerExtension {
|
||||
hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_SPACE], hash);
|
||||
hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_GLYPH], hash);
|
||||
hash = hash_murmur3_one_double(p_a.baseline_offset, hash);
|
||||
return hash_fmix32(hash_murmur3_one_32(((int)p_a.mipmaps) | ((int)p_a.msdf << 1) | ((int)p_a.italic << 2) | ((int)p_a.force_autohinter << 3) | ((int)p_a.hinting << 4) | ((int)p_a.subpixel_positioning << 8) | ((int)p_a.antialiasing << 12) | ((int)p_a.disable_embedded_bitmaps << 14), hash));
|
||||
return hash_fmix32(hash_murmur3_one_32(((int)p_a.mipmaps) | ((int)p_a.msdf << 1) | ((int)p_a.italic << 2) | ((int)p_a.force_autohinter << 3) | ((int)p_a.hinting << 4) | ((int)p_a.subpixel_positioning << 8) | ((int)p_a.antialiasing << 12) | ((int)p_a.disable_embedded_bitmaps << 14) | ((int)p_a.keep_rounding_remainders << 15), hash));
|
||||
}
|
||||
};
|
||||
mutable HashMap<SystemFontKey, SystemFontCache, SystemFontKeyHasher> system_fonts;
|
||||
@ -659,6 +662,9 @@ public:
|
||||
MODBIND2(font_set_subpixel_positioning, const RID &, SubpixelPositioning);
|
||||
MODBIND1RC(SubpixelPositioning, font_get_subpixel_positioning, const RID &);
|
||||
|
||||
MODBIND2(font_set_keep_rounding_remainders, const RID &, bool);
|
||||
MODBIND1RC(bool, font_get_keep_rounding_remainders, const RID &);
|
||||
|
||||
MODBIND2(font_set_embolden, const RID &, double);
|
||||
MODBIND1RC(double, font_get_embolden, const RID &);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user