mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Add font import flag to toggle modulation of colored glyphs.
This commit is contained in:
@@ -1442,6 +1442,24 @@ bool TextServerFallback::_font_is_force_autohinter(const RID &p_font_rid) const
|
||||
return fd->force_autohinter;
|
||||
}
|
||||
|
||||
void TextServerFallback::_font_set_modulate_color_glyphs(const RID &p_font_rid, bool p_modulate) {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
if (fd->modulate_color_glyphs != p_modulate) {
|
||||
fd->modulate_color_glyphs = p_modulate;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextServerFallback::_font_is_modulate_color_glyphs(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->modulate_color_glyphs;
|
||||
}
|
||||
|
||||
void TextServerFallback::_font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
@@ -2741,7 +2759,7 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
|
||||
if (fgl.texture_idx != -1) {
|
||||
Color modulate = p_color;
|
||||
#ifdef MODULE_FREETYPE_ENABLED
|
||||
if (!fgl.from_svg && ffsd->face && ffsd->textures[fgl.texture_idx].image.is_valid() && (ffsd->textures[fgl.texture_idx].image->get_format() == Image::FORMAT_RGBA8) && !lcd_aa && !fd->msdf) {
|
||||
if (!fd->modulate_color_glyphs && ffsd->face && ffsd->textures[fgl.texture_idx].image.is_valid() && (ffsd->textures[fgl.texture_idx].image->get_format() == Image::FORMAT_RGBA8) && !lcd_aa && !fd->msdf) {
|
||||
modulate.r = modulate.g = modulate.b = 1.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -268,6 +268,7 @@ class TextServerFallback : public TextServerExtension {
|
||||
int fixed_size = 0;
|
||||
bool force_autohinter = false;
|
||||
bool allow_system_fallback = true;
|
||||
bool modulate_color_glyphs = false;
|
||||
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
|
||||
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
|
||||
bool keep_rounding_remainders = true;
|
||||
@@ -662,6 +663,9 @@ public:
|
||||
MODBIND2(font_set_force_autohinter, const RID &, bool);
|
||||
MODBIND1RC(bool, font_is_force_autohinter, const RID &);
|
||||
|
||||
MODBIND2(font_set_modulate_color_glyphs, const RID &, bool);
|
||||
MODBIND1RC(bool, font_is_modulate_color_glyphs, const RID &);
|
||||
|
||||
MODBIND2(font_set_subpixel_positioning, const RID &, SubpixelPositioning);
|
||||
MODBIND1RC(SubpixelPositioning, font_get_subpixel_positioning, const RID &);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user