[Font] Add option to disable embedded bitmaps loading.
This commit is contained in:
parent
810f127022
commit
911fa38d3a
|
@ -601,6 +601,9 @@
|
|||
<member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
|
||||
Contents of the dynamic font source file.
|
||||
</member>
|
||||
<member name="disable_embedded_bitmaps" type="bool" setter="set_disable_embedded_bitmaps" getter="get_disable_embedded_bitmaps" default="true">
|
||||
If set to [code]true[/code], embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).
|
||||
</member>
|
||||
<member name="fixed_size" type="int" setter="set_fixed_size" getter="get_fixed_size" default="0">
|
||||
Font size, used only for the bitmap fonts.
|
||||
</member>
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
<member name="compress" type="bool" setter="" getter="" default="true">
|
||||
If [code]true[/code], uses lossless compression for the resulting font.
|
||||
</member>
|
||||
<member name="disable_embedded_bitmaps" type="bool" setter="" getter="" default="true">
|
||||
If set to [code]true[/code], embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).
|
||||
</member>
|
||||
<member name="fallbacks" type="Array" setter="" getter="" default="[]">
|
||||
List of font fallbacks to use if a glyph isn't found in this dynamic font. Fonts at the beginning of the array are attempted first, but fallback fonts that don't support the glyph's language and script are attempted last (see [member language_support] and [member script_support]). See also [member allow_system_fallback].
|
||||
</member>
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
<member name="antialiasing" type="int" setter="set_antialiasing" getter="get_antialiasing" enum="TextServer.FontAntialiasing" default="1">
|
||||
Font anti-aliasing mode.
|
||||
</member>
|
||||
<member name="disable_embedded_bitmaps" type="bool" setter="set_disable_embedded_bitmaps" getter="get_disable_embedded_bitmaps" default="true">
|
||||
If set to [code]true[/code], embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).
|
||||
</member>
|
||||
<member name="font_italic" type="bool" setter="set_font_italic" getter="get_font_italic" default="false">
|
||||
If set to [code]true[/code], italic or oblique font is preferred.
|
||||
</member>
|
||||
|
|
|
@ -144,6 +144,13 @@
|
|||
Returns the font descent (number of pixels below the baseline).
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_disable_embedded_bitmaps" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="font_rid" type="RID" />
|
||||
<description>
|
||||
Returns whether the font's embedded bitmap loading is disabled.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_embolden" qualifiers="const">
|
||||
<return type="float" />
|
||||
<param index="0" name="font_rid" type="RID" />
|
||||
|
@ -672,6 +679,14 @@
|
|||
Sets the font descent (number of pixels below the baseline).
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_set_disable_embedded_bitmaps">
|
||||
<return type="void" />
|
||||
<param index="0" name="font_rid" type="RID" />
|
||||
<param index="1" name="disable_embedded_bitmaps" type="bool" />
|
||||
<description>
|
||||
If set to [code]true[/code], embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_set_embolden">
|
||||
<return type="void" />
|
||||
<param index="0" name="font_rid" type="RID" />
|
||||
|
|
|
@ -126,6 +126,12 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="_font_get_disable_embedded_bitmaps" qualifiers="virtual const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="font_rid" type="RID" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="_font_get_embolden" qualifiers="virtual const">
|
||||
<return type="float" />
|
||||
<param index="0" name="font_rid" type="RID" />
|
||||
|
@ -588,6 +594,13 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="_font_set_disable_embedded_bitmaps" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<param index="0" name="font_rid" type="RID" />
|
||||
<param index="1" name="disable_embedded_bitmaps" type="bool" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="_font_set_embolden" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<param index="0" name="font_rid" type="RID" />
|
||||
|
|
|
@ -464,6 +464,8 @@ void DynamicFontImportSettingsDialog::_main_prop_changed(const String &p_edited_
|
|||
font_preview->set_antialiasing((TextServer::FontAntialiasing)import_settings_data->get("antialiasing").operator int());
|
||||
} else if (p_edited_property == "generate_mipmaps") {
|
||||
font_preview->set_generate_mipmaps(import_settings_data->get("generate_mipmaps"));
|
||||
} else if (p_edited_property == "disable_embedded_bitmaps") {
|
||||
font_preview->set_disable_embedded_bitmaps(import_settings_data->get("disable_embedded_bitmaps"));
|
||||
} else if (p_edited_property == "multichannel_signed_distance_field") {
|
||||
font_preview->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field"));
|
||||
_variation_selected();
|
||||
|
@ -938,6 +940,7 @@ void DynamicFontImportSettingsDialog::_re_import() {
|
|||
main_settings["face_index"] = import_settings_data->get("face_index");
|
||||
main_settings["antialiasing"] = import_settings_data->get("antialiasing");
|
||||
main_settings["generate_mipmaps"] = import_settings_data->get("generate_mipmaps");
|
||||
main_settings["disable_embedded_bitmaps"] = import_settings_data->get("disable_embedded_bitmaps");
|
||||
main_settings["multichannel_signed_distance_field"] = import_settings_data->get("multichannel_signed_distance_field");
|
||||
main_settings["msdf_pixel_range"] = import_settings_data->get("msdf_pixel_range");
|
||||
main_settings["msdf_size"] = import_settings_data->get("msdf_size");
|
||||
|
@ -1245,6 +1248,7 @@ DynamicFontImportSettingsDialog::DynamicFontImportSettingsDialog() {
|
|||
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel"), 1));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "generate_mipmaps"), false));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "disable_embedded_bitmaps"), true));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), 8));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_RANGE, "1,250,1"), 48));
|
||||
|
|
|
@ -110,6 +110,7 @@ void ResourceImporterDynamicFont::get_import_options(const String &p_path, List<
|
|||
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel"), 1));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_mipmaps"), false));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "disable_embedded_bitmaps"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), (msdf) ? true : false));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), 8));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_RANGE, "1,250,1"), 48));
|
||||
|
@ -145,6 +146,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str
|
|||
|
||||
int antialiasing = p_options["antialiasing"];
|
||||
bool generate_mipmaps = p_options["generate_mipmaps"];
|
||||
bool disable_embedded_bitmaps = p_options["disable_embedded_bitmaps"];
|
||||
bool msdf = p_options["multichannel_signed_distance_field"];
|
||||
int px_range = p_options["msdf_pixel_range"];
|
||||
int px_size = p_options["msdf_size"];
|
||||
|
@ -165,6 +167,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str
|
|||
font.instantiate();
|
||||
font->set_data(data);
|
||||
font->set_antialiasing((TextServer::FontAntialiasing)antialiasing);
|
||||
font->set_disable_embedded_bitmaps(disable_embedded_bitmaps);
|
||||
font->set_generate_mipmaps(generate_mipmaps);
|
||||
font->set_multichannel_signed_distance_field(msdf);
|
||||
font->set_msdf_pixel_range(px_range);
|
||||
|
|
|
@ -1201,7 +1201,7 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_glyph(FontAdvanced *p_font_data,
|
|||
if (p_font_data->force_autohinter) {
|
||||
flags |= FT_LOAD_FORCE_AUTOHINT;
|
||||
}
|
||||
if (outline) {
|
||||
if (outline || (p_font_data->disable_embedded_bitmaps && !FT_HAS_COLOR(fd->face))) {
|
||||
flags |= FT_LOAD_NO_BITMAP;
|
||||
} else if (FT_HAS_COLOR(fd->face)) {
|
||||
flags |= FT_LOAD_COLOR;
|
||||
|
@ -2177,6 +2177,25 @@ TextServer::FontAntialiasing TextServerAdvanced::_font_get_antialiasing(const RI
|
|||
return fd->antialiasing;
|
||||
}
|
||||
|
||||
void TextServerAdvanced::_font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) {
|
||||
FontAdvanced *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
if (fd->disable_embedded_bitmaps != p_disable_embedded_bitmaps) {
|
||||
_font_clear_cache(fd);
|
||||
fd->disable_embedded_bitmaps = p_disable_embedded_bitmaps;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextServerAdvanced::_font_get_disable_embedded_bitmaps(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->disable_embedded_bitmaps;
|
||||
}
|
||||
|
||||
void TextServerAdvanced::_font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) {
|
||||
FontAdvanced *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
@ -4997,6 +5016,7 @@ RID TextServerAdvanced::_find_sys_font_for_text(const RID &p_fdef, const String
|
|||
}
|
||||
|
||||
_font_set_antialiasing(sysf.rid, key.antialiasing);
|
||||
_font_set_disable_embedded_bitmaps(sysf.rid, key.disable_embedded_bitmaps);
|
||||
_font_set_generate_mipmaps(sysf.rid, key.mipmaps);
|
||||
_font_set_multichannel_signed_distance_field(sysf.rid, key.msdf);
|
||||
_font_set_msdf_pixel_range(sysf.rid, key.msdf_range);
|
||||
|
|
|
@ -303,6 +303,7 @@ class TextServerAdvanced : public TextServerExtension {
|
|||
Mutex mutex;
|
||||
|
||||
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
|
||||
bool disable_embedded_bitmaps = true;
|
||||
bool mipmaps = false;
|
||||
bool msdf = false;
|
||||
int msdf_range = 14;
|
||||
|
@ -559,6 +560,7 @@ class TextServerAdvanced : public TextServerExtension {
|
|||
struct SystemFontKey {
|
||||
String font_name;
|
||||
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
|
||||
bool disable_embedded_bitmaps = true;
|
||||
bool italic = false;
|
||||
bool mipmaps = false;
|
||||
bool msdf = false;
|
||||
|
@ -578,7 +580,7 @@ class TextServerAdvanced : public TextServerExtension {
|
|||
float 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) && (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) && (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 TextServerAdvanced *p_fb) {
|
||||
|
@ -587,6 +589,7 @@ class TextServerAdvanced : public TextServerExtension {
|
|||
weight = p_weight;
|
||||
stretch = p_stretch;
|
||||
antialiasing = p_fb->_font_get_antialiasing(p_font);
|
||||
disable_embedded_bitmaps = p_fb->_font_get_disable_embedded_bitmaps(p_font);
|
||||
mipmaps = p_fb->_font_get_generate_mipmaps(p_font);
|
||||
msdf = p_fb->_font_is_multichannel_signed_distance_field(p_font);
|
||||
msdf_range = p_fb->_font_get_msdf_pixel_range(p_font);
|
||||
|
@ -637,7 +640,7 @@ class TextServerAdvanced : 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), 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));
|
||||
}
|
||||
};
|
||||
mutable HashMap<SystemFontKey, SystemFontCache, SystemFontKeyHasher> system_fonts;
|
||||
|
@ -751,6 +754,9 @@ public:
|
|||
MODBIND2(font_set_antialiasing, const RID &, TextServer::FontAntialiasing);
|
||||
MODBIND1RC(TextServer::FontAntialiasing, font_get_antialiasing, const RID &);
|
||||
|
||||
MODBIND2(font_set_disable_embedded_bitmaps, const RID &, bool);
|
||||
MODBIND1RC(bool, font_get_disable_embedded_bitmaps, const RID &);
|
||||
|
||||
MODBIND2(font_set_generate_mipmaps, const RID &, bool);
|
||||
MODBIND1RC(bool, font_get_generate_mipmaps, const RID &);
|
||||
|
||||
|
|
|
@ -636,7 +636,7 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontFallback *p_font_data,
|
|||
if (p_font_data->force_autohinter) {
|
||||
flags |= FT_LOAD_FORCE_AUTOHINT;
|
||||
}
|
||||
if (outline) {
|
||||
if (outline || (p_font_data->disable_embedded_bitmaps && !FT_HAS_COLOR(fd->face))) {
|
||||
flags |= FT_LOAD_NO_BITMAP;
|
||||
} else if (FT_HAS_COLOR(fd->face)) {
|
||||
flags |= FT_LOAD_COLOR;
|
||||
|
@ -1170,6 +1170,25 @@ TextServer::FontAntialiasing TextServerFallback::_font_get_antialiasing(const RI
|
|||
return fd->antialiasing;
|
||||
}
|
||||
|
||||
void TextServerFallback::_font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
if (fd->disable_embedded_bitmaps != p_disable_embedded_bitmaps) {
|
||||
_font_clear_cache(fd);
|
||||
fd->disable_embedded_bitmaps = p_disable_embedded_bitmaps;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextServerFallback::_font_get_disable_embedded_bitmaps(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->disable_embedded_bitmaps;
|
||||
}
|
||||
|
||||
void TextServerFallback::_font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
@ -3805,6 +3824,7 @@ RID TextServerFallback::_find_sys_font_for_text(const RID &p_fdef, const String
|
|||
}
|
||||
|
||||
_font_set_antialiasing(sysf.rid, key.antialiasing);
|
||||
_font_set_disable_embedded_bitmaps(sysf.rid, key.disable_embedded_bitmaps);
|
||||
_font_set_generate_mipmaps(sysf.rid, key.mipmaps);
|
||||
_font_set_multichannel_signed_distance_field(sysf.rid, key.msdf);
|
||||
_font_set_msdf_pixel_range(sysf.rid, key.msdf_range);
|
||||
|
|
|
@ -254,6 +254,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
Mutex mutex;
|
||||
|
||||
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
|
||||
bool disable_embedded_bitmaps = true;
|
||||
bool mipmaps = false;
|
||||
bool msdf = false;
|
||||
FixedSizeScaleMode fixed_size_scale_mode = FIXED_SIZE_SCALE_DISABLE;
|
||||
|
@ -475,6 +476,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
struct SystemFontKey {
|
||||
String font_name;
|
||||
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
|
||||
bool disable_embedded_bitmaps = true;
|
||||
bool italic = false;
|
||||
bool mipmaps = false;
|
||||
bool msdf = false;
|
||||
|
@ -494,7 +496,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
float 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) && (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) && (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) {
|
||||
|
@ -503,6 +505,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
weight = p_weight;
|
||||
stretch = p_stretch;
|
||||
antialiasing = p_fb->_font_get_antialiasing(p_font);
|
||||
disable_embedded_bitmaps = p_fb->_font_get_disable_embedded_bitmaps(p_font);
|
||||
mipmaps = p_fb->_font_get_generate_mipmaps(p_font);
|
||||
msdf = p_fb->_font_is_multichannel_signed_distance_field(p_font);
|
||||
msdf_range = p_fb->_font_get_msdf_pixel_range(p_font);
|
||||
|
@ -553,7 +556,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), 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));
|
||||
}
|
||||
};
|
||||
mutable HashMap<SystemFontKey, SystemFontCache, SystemFontKeyHasher> system_fonts;
|
||||
|
@ -619,6 +622,9 @@ public:
|
|||
MODBIND2(font_set_antialiasing, const RID &, TextServer::FontAntialiasing);
|
||||
MODBIND1RC(TextServer::FontAntialiasing, font_get_antialiasing, const RID &);
|
||||
|
||||
MODBIND2(font_set_disable_embedded_bitmaps, const RID &, bool);
|
||||
MODBIND1RC(bool, font_get_disable_embedded_bitmaps, const RID &);
|
||||
|
||||
MODBIND2(font_set_generate_mipmaps, const RID &, bool);
|
||||
MODBIND1RC(bool, font_get_generate_mipmaps, const RID &);
|
||||
|
||||
|
|
|
@ -576,6 +576,7 @@ _FORCE_INLINE_ void FontFile::_ensure_rid(int p_cache_index, int p_make_linked_f
|
|||
TS->font_set_data_ptr(cache[p_cache_index], data_ptr, data_size);
|
||||
TS->font_set_antialiasing(cache[p_cache_index], antialiasing);
|
||||
TS->font_set_generate_mipmaps(cache[p_cache_index], mipmaps);
|
||||
TS->font_set_disable_embedded_bitmaps(cache[p_cache_index], disable_embedded_bitmaps);
|
||||
TS->font_set_multichannel_signed_distance_field(cache[p_cache_index], msdf);
|
||||
TS->font_set_msdf_pixel_range(cache[p_cache_index], msdf_pixel_range);
|
||||
TS->font_set_msdf_size(cache[p_cache_index], msdf_size);
|
||||
|
@ -881,6 +882,9 @@ void FontFile::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_antialiasing", "antialiasing"), &FontFile::set_antialiasing);
|
||||
ClassDB::bind_method(D_METHOD("get_antialiasing"), &FontFile::get_antialiasing);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_disable_embedded_bitmaps", "disable_embedded_bitmaps"), &FontFile::set_disable_embedded_bitmaps);
|
||||
ClassDB::bind_method(D_METHOD("get_disable_embedded_bitmaps"), &FontFile::get_disable_embedded_bitmaps);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_generate_mipmaps", "generate_mipmaps"), &FontFile::set_generate_mipmaps);
|
||||
ClassDB::bind_method(D_METHOD("get_generate_mipmaps"), &FontFile::get_generate_mipmaps);
|
||||
|
||||
|
@ -1012,6 +1016,7 @@ void FontFile::_bind_methods() {
|
|||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_data", "get_data");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "generate_mipmaps", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_generate_mipmaps", "get_generate_mipmaps");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_embedded_bitmaps", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_disable_embedded_bitmaps", "get_disable_embedded_bitmaps");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel", PROPERTY_USAGE_STORAGE), "set_antialiasing", "get_antialiasing");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "font_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_name", "get_font_name");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "style_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_style_name", "get_font_style_name");
|
||||
|
@ -1381,6 +1386,7 @@ void FontFile::reset_state() {
|
|||
|
||||
antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
|
||||
mipmaps = false;
|
||||
disable_embedded_bitmaps = true;
|
||||
msdf = false;
|
||||
force_autohinter = false;
|
||||
allow_system_fallback = true;
|
||||
|
@ -1415,6 +1421,7 @@ Error FontFile::load_bitmap_font(const String &p_path) {
|
|||
|
||||
antialiasing = TextServer::FONT_ANTIALIASING_NONE;
|
||||
mipmaps = false;
|
||||
disable_embedded_bitmaps = true;
|
||||
msdf = false;
|
||||
force_autohinter = false;
|
||||
allow_system_fallback = true;
|
||||
|
@ -2091,6 +2098,21 @@ TextServer::FontAntialiasing FontFile::get_antialiasing() const {
|
|||
return antialiasing;
|
||||
}
|
||||
|
||||
void FontFile::set_disable_embedded_bitmaps(bool p_disable_embedded_bitmaps) {
|
||||
if (disable_embedded_bitmaps != p_disable_embedded_bitmaps) {
|
||||
disable_embedded_bitmaps = p_disable_embedded_bitmaps;
|
||||
for (int i = 0; i < cache.size(); i++) {
|
||||
_ensure_rid(i);
|
||||
TS->font_set_disable_embedded_bitmaps(cache[i], disable_embedded_bitmaps);
|
||||
}
|
||||
emit_changed();
|
||||
}
|
||||
}
|
||||
|
||||
bool FontFile::get_disable_embedded_bitmaps() const {
|
||||
return disable_embedded_bitmaps;
|
||||
}
|
||||
|
||||
void FontFile::set_generate_mipmaps(bool p_generate_mipmaps) {
|
||||
if (mipmaps != p_generate_mipmaps) {
|
||||
mipmaps = p_generate_mipmaps;
|
||||
|
@ -3012,6 +3034,9 @@ void SystemFont::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_antialiasing", "antialiasing"), &SystemFont::set_antialiasing);
|
||||
ClassDB::bind_method(D_METHOD("get_antialiasing"), &SystemFont::get_antialiasing);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_disable_embedded_bitmaps", "disable_embedded_bitmaps"), &SystemFont::set_disable_embedded_bitmaps);
|
||||
ClassDB::bind_method(D_METHOD("get_disable_embedded_bitmaps"), &SystemFont::get_disable_embedded_bitmaps);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_generate_mipmaps", "generate_mipmaps"), &SystemFont::set_generate_mipmaps);
|
||||
ClassDB::bind_method(D_METHOD("get_generate_mipmaps"), &SystemFont::get_generate_mipmaps);
|
||||
|
||||
|
@ -3053,6 +3078,7 @@ void SystemFont::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_stretch", PROPERTY_HINT_RANGE, "50,200,25"), "set_font_stretch", "get_font_stretch");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel", PROPERTY_USAGE_STORAGE), "set_antialiasing", "get_antialiasing");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "generate_mipmaps"), "set_generate_mipmaps", "get_generate_mipmaps");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_embedded_bitmaps"), "set_disable_embedded_bitmaps", "get_disable_embedded_bitmaps");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_system_fallback"), "set_allow_system_fallback", "is_allow_system_fallback");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "force_autohinter"), "set_force_autohinter", "is_force_autohinter");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), "set_hinting", "get_hinting");
|
||||
|
@ -3156,6 +3182,7 @@ void SystemFont::_update_base_font() {
|
|||
// Apply font rendering settings.
|
||||
file->set_antialiasing(antialiasing);
|
||||
file->set_generate_mipmaps(mipmaps);
|
||||
file->set_disable_embedded_bitmaps(disable_embedded_bitmaps);
|
||||
file->set_force_autohinter(force_autohinter);
|
||||
file->set_allow_system_fallback(allow_system_fallback);
|
||||
file->set_hinting(hinting);
|
||||
|
@ -3199,6 +3226,7 @@ void SystemFont::reset_state() {
|
|||
stretch = 100;
|
||||
antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
|
||||
mipmaps = false;
|
||||
disable_embedded_bitmaps = true;
|
||||
force_autohinter = false;
|
||||
allow_system_fallback = true;
|
||||
hinting = TextServer::HINTING_LIGHT;
|
||||
|
@ -3272,6 +3300,20 @@ TextServer::FontAntialiasing SystemFont::get_antialiasing() const {
|
|||
return antialiasing;
|
||||
}
|
||||
|
||||
void SystemFont::set_disable_embedded_bitmaps(bool p_disable_embedded_bitmaps) {
|
||||
if (disable_embedded_bitmaps != p_disable_embedded_bitmaps) {
|
||||
disable_embedded_bitmaps = p_disable_embedded_bitmaps;
|
||||
if (base_font.is_valid()) {
|
||||
base_font->set_disable_embedded_bitmaps(disable_embedded_bitmaps);
|
||||
}
|
||||
emit_changed();
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemFont::get_disable_embedded_bitmaps() const {
|
||||
return disable_embedded_bitmaps;
|
||||
}
|
||||
|
||||
void SystemFont::set_generate_mipmaps(bool p_generate_mipmaps) {
|
||||
if (mipmaps != p_generate_mipmaps) {
|
||||
mipmaps = p_generate_mipmaps;
|
||||
|
|
|
@ -187,6 +187,7 @@ class FontFile : public Font {
|
|||
|
||||
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
|
||||
bool mipmaps = false;
|
||||
bool disable_embedded_bitmaps = true;
|
||||
bool msdf = false;
|
||||
int msdf_pixel_range = 16;
|
||||
int msdf_size = 48;
|
||||
|
@ -244,6 +245,9 @@ public:
|
|||
virtual void set_antialiasing(TextServer::FontAntialiasing p_antialiasing);
|
||||
virtual TextServer::FontAntialiasing get_antialiasing() const;
|
||||
|
||||
virtual void set_disable_embedded_bitmaps(bool p_disable_embedded_bitmaps);
|
||||
virtual bool get_disable_embedded_bitmaps() const;
|
||||
|
||||
virtual void set_generate_mipmaps(bool p_generate_mipmaps);
|
||||
virtual bool get_generate_mipmaps() const;
|
||||
|
||||
|
@ -469,6 +473,7 @@ class SystemFont : public Font {
|
|||
|
||||
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
|
||||
bool mipmaps = false;
|
||||
bool disable_embedded_bitmaps = true;
|
||||
bool force_autohinter = false;
|
||||
bool allow_system_fallback = true;
|
||||
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
|
||||
|
@ -492,6 +497,9 @@ public:
|
|||
virtual void set_antialiasing(TextServer::FontAntialiasing p_antialiasing);
|
||||
virtual TextServer::FontAntialiasing get_antialiasing() const;
|
||||
|
||||
virtual void set_disable_embedded_bitmaps(bool p_disable_embedded_bitmaps);
|
||||
virtual bool get_disable_embedded_bitmaps() const;
|
||||
|
||||
virtual void set_generate_mipmaps(bool p_generate_mipmaps);
|
||||
virtual bool get_generate_mipmaps() const;
|
||||
|
||||
|
|
|
@ -80,6 +80,9 @@ void TextServerExtension::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_font_set_antialiasing, "font_rid", "antialiasing");
|
||||
GDVIRTUAL_BIND(_font_get_antialiasing, "font_rid");
|
||||
|
||||
GDVIRTUAL_BIND(_font_set_disable_embedded_bitmaps, "font_rid", "disable_embedded_bitmaps");
|
||||
GDVIRTUAL_BIND(_font_get_disable_embedded_bitmaps, "font_rid");
|
||||
|
||||
GDVIRTUAL_BIND(_font_set_generate_mipmaps, "font_rid", "generate_mipmaps");
|
||||
GDVIRTUAL_BIND(_font_get_generate_mipmaps, "font_rid");
|
||||
|
||||
|
@ -518,6 +521,16 @@ TextServer::FontAntialiasing TextServerExtension::font_get_antialiasing(const RI
|
|||
return ret;
|
||||
}
|
||||
|
||||
void TextServerExtension::font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) {
|
||||
GDVIRTUAL_CALL(_font_set_disable_embedded_bitmaps, p_font_rid, p_disable_embedded_bitmaps);
|
||||
}
|
||||
|
||||
bool TextServerExtension::font_get_disable_embedded_bitmaps(const RID &p_font_rid) const {
|
||||
bool ret = false;
|
||||
GDVIRTUAL_CALL(_font_get_disable_embedded_bitmaps, p_font_rid, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TextServerExtension::font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) {
|
||||
GDVIRTUAL_CALL(_font_set_generate_mipmaps, p_font_rid, p_generate_mipmaps);
|
||||
}
|
||||
|
|
|
@ -128,6 +128,11 @@ public:
|
|||
GDVIRTUAL2(_font_set_antialiasing, RID, TextServer::FontAntialiasing);
|
||||
GDVIRTUAL1RC(TextServer::FontAntialiasing, _font_get_antialiasing, RID);
|
||||
|
||||
virtual void font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) override;
|
||||
virtual bool font_get_disable_embedded_bitmaps(const RID &p_font_rid) const override;
|
||||
GDVIRTUAL2(_font_set_disable_embedded_bitmaps, RID, bool);
|
||||
GDVIRTUAL1RC(bool, _font_get_disable_embedded_bitmaps, RID);
|
||||
|
||||
virtual void font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) override;
|
||||
virtual bool font_get_generate_mipmaps(const RID &p_font_rid) const override;
|
||||
GDVIRTUAL2(_font_set_generate_mipmaps, RID, bool);
|
||||
|
|
|
@ -234,6 +234,9 @@ void TextServer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("font_set_antialiasing", "font_rid", "antialiasing"), &TextServer::font_set_antialiasing);
|
||||
ClassDB::bind_method(D_METHOD("font_get_antialiasing", "font_rid"), &TextServer::font_get_antialiasing);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("font_set_disable_embedded_bitmaps", "font_rid", "disable_embedded_bitmaps"), &TextServer::font_set_disable_embedded_bitmaps);
|
||||
ClassDB::bind_method(D_METHOD("font_get_disable_embedded_bitmaps", "font_rid"), &TextServer::font_get_disable_embedded_bitmaps);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("font_set_generate_mipmaps", "font_rid", "generate_mipmaps"), &TextServer::font_set_generate_mipmaps);
|
||||
ClassDB::bind_method(D_METHOD("font_get_generate_mipmaps", "font_rid"), &TextServer::font_get_generate_mipmaps);
|
||||
|
||||
|
|
|
@ -274,6 +274,9 @@ public:
|
|||
virtual void font_set_antialiasing(const RID &p_font_rid, FontAntialiasing p_antialiasing) = 0;
|
||||
virtual FontAntialiasing font_get_antialiasing(const RID &p_font_rid) const = 0;
|
||||
|
||||
virtual void font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) = 0;
|
||||
virtual bool font_get_disable_embedded_bitmaps(const RID &p_font_rid) const = 0;
|
||||
|
||||
virtual void font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) = 0;
|
||||
virtual bool font_get_generate_mipmaps(const RID &p_font_rid) const = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue