Restore per font oversampling override.

This commit is contained in:
Pāvels Nadtočajevs
2025-06-19 15:05:52 +03:00
parent 8de08c7c21
commit 22e99a4901
17 changed files with 130 additions and 43 deletions

View File

@@ -651,8 +651,8 @@
<member name="opentype_feature_overrides" type="Dictionary" setter="set_opentype_feature_overrides" getter="get_opentype_feature_overrides" default="{}">
Font OpenType feature set override.
</member>
<member name="oversampling" type="float" setter="set_oversampling" getter="get_oversampling" deprecated="Use the [code skip-lint]oversampling[/code] argument of the [code skip-lint]draw_*[/code] methods instead.">
Deprecated. This property does nothing.
<member name="oversampling" type="float" setter="set_oversampling" getter="get_oversampling" default="0.0">
If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn't override the [code skip-lint]oversampling[/code] parameter of [code skip-lint]draw_*[/code] methods.
</member>
<member name="style_name" type="String" setter="set_font_style_name" getter="get_font_style_name" default="&quot;&quot;">
Font style name.

View File

@@ -66,6 +66,9 @@
<member name="opentype_features" type="Dictionary" setter="" getter="" default="{}">
The OpenType features to enable, disable or set a value for this font. This can be used to enable optional features provided by the font, such as ligatures or alternative glyphs. The list of supported OpenType features varies on a per-font basis.
</member>
<member name="oversampling" type="float" setter="" getter="" default="0.0">
If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn't override the [code skip-lint]oversampling[/code] parameter of [code skip-lint]draw_*[/code] methods.
</member>
<member name="preload" type="Array" setter="" getter="" default="[]">
The glyph ranges to prerender. This can avoid stuttering during gameplay when new characters need to be rendered, especially if [member subpixel_positioning] is enabled. The downside of using preloading is that initial project load times will increase, as well as memory usage.
</member>

View File

@@ -58,8 +58,8 @@
<member name="multichannel_signed_distance_field" type="bool" setter="set_multichannel_signed_distance_field" getter="is_multichannel_signed_distance_field" default="false">
If set to [code]true[/code], glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data.
</member>
<member name="oversampling" type="float" setter="set_oversampling" getter="get_oversampling" deprecated="Use the [code skip-lint]oversampling[/code] argument of the [code skip-lint]draw_*[/code] methods instead.">
Deprecated. This property does nothing.
<member name="oversampling" type="float" setter="set_oversampling" getter="get_oversampling" default="0.0">
If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn't override the [code skip-lint]oversampling[/code] parameter of [code skip-lint]draw_*[/code] methods.
</member>
<member name="subpixel_positioning" type="int" setter="set_subpixel_positioning" getter="get_subpixel_positioning" enum="TextServer.SubpixelPositioning" default="1">
Font glyph subpixel positioning mode. Subpixel positioning provides shaper text and better kerning for smaller font sizes, at the cost of memory usage and font rasterization speed. Use [constant TextServer.SUBPIXEL_POSITIONING_AUTO] to automatically enable it based on the font size.

View File

@@ -399,11 +399,11 @@
Returns [Dictionary] with OpenType font name strings (localized font names, version, description, license information, sample text, etc.).
</description>
</method>
<method name="font_get_oversampling" qualifiers="const" deprecated="Use [Viewport] oversampling, or the [code skip-lint]oversampling[/code] argument of the [code skip-lint]draw_*[/code] methods instead.">
<method name="font_get_oversampling" qualifiers="const">
<return type="float" />
<param index="0" name="font_rid" type="RID" />
<description>
Deprecated. This method always returns [code]1.0[/code].
Returns oversampling factor override. If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn't override the [code skip-lint]oversampling[/code] parameter of [code skip-lint]draw_*[/code] methods. Used by dynamic fonts only.
</description>
</method>
<method name="font_get_scale" qualifiers="const">
@@ -928,12 +928,12 @@
Sets font OpenType feature set override.
</description>
</method>
<method name="font_set_oversampling" deprecated="Use [Viewport] oversampling, or the [code skip-lint]oversampling[/code] argument of the [code skip-lint]draw_*[/code] methods instead.">
<method name="font_set_oversampling">
<return type="void" />
<param index="0" name="font_rid" type="RID" />
<param index="1" name="oversampling" type="float" />
<description>
Deprecated. This method does nothing.
If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn't override the [code skip-lint]oversampling[/code] parameter of [code skip-lint]draw_*[/code] methods. Used by dynamic fonts only.
</description>
</method>
<method name="font_set_scale">

View File

@@ -381,7 +381,7 @@
<return type="float" />
<param index="0" name="font_rid" type="RID" />
<description>
Returns font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only.
Returns oversampling factor override. If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn't override the [code skip-lint]oversampling[/code] parameter of [code skip-lint]draw_*[/code] methods. Used by dynamic fonts only.
</description>
</method>
<method name="_font_get_scale" qualifiers="virtual required const">
@@ -916,7 +916,7 @@
<param index="0" name="font_rid" type="RID" />
<param index="1" name="oversampling" type="float" />
<description>
Sets font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only.
If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn't override the [code skip-lint]oversampling[/code] parameter of [code skip-lint]draw_*[/code] methods. Used by dynamic fonts only.
</description>
</method>
<method name="_font_set_scale" qualifiers="virtual required">

View File

@@ -71,7 +71,7 @@ bool DynamicFontImportSettingsData::_get(const StringName &p_name, Variant &r_re
void DynamicFontImportSettingsData::_get_property_list(List<PropertyInfo> *p_list) const {
for (const List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
if (owner && owner->import_settings_data.is_valid()) {
if (owner->import_settings_data->get("multichannel_signed_distance_field") && (E->get().option.name == "size" || E->get().option.name == "outline_size")) {
if (owner->import_settings_data->get("multichannel_signed_distance_field") && (E->get().option.name == "size" || E->get().option.name == "outline_size" || E->get().option.name == "oversampling")) {
continue;
}
if (!owner->import_settings_data->get("multichannel_signed_distance_field") && (E->get().option.name == "msdf_pixel_range" || E->get().option.name == "msdf_size")) {
@@ -159,6 +159,8 @@ void DynamicFontImportSettingsDialog::_main_prop_changed(const String &p_edited_
_variations_validate();
} else if (p_edited_property == "keep_rounding_remainders") {
font_preview->set_keep_rounding_remainders(import_settings_data->get("keep_rounding_remainders"));
} else if (p_edited_property == "oversampling") {
font_preview->set_oversampling(import_settings_data->get("oversampling"));
}
}
@@ -633,6 +635,7 @@ void DynamicFontImportSettingsDialog::_re_import() {
main_settings["hinting"] = import_settings_data->get("hinting");
main_settings["subpixel_positioning"] = import_settings_data->get("subpixel_positioning");
main_settings["keep_rounding_remainders"] = import_settings_data->get("keep_rounding_remainders");
main_settings["oversampling"] = import_settings_data->get("oversampling");
main_settings["fallbacks"] = import_settings_data->get("fallbacks");
main_settings["compress"] = import_settings_data->get("compress");
@@ -944,6 +947,7 @@ void DynamicFontImportSettingsDialog::open_settings(const String &p_path) {
}
font_preview->set_subpixel_positioning((TextServer::SubpixelPositioning)font_subpixel_positioning);
font_preview->set_keep_rounding_remainders(import_settings_data->get("keep_rounding_remainders"));
font_preview->set_oversampling(import_settings_data->get("oversampling"));
}
font_preview_label->add_theme_font_override(SceneStringName(font), font_preview);
font_preview_label->add_theme_font_size_override(SceneStringName(font_size), 200 * EDSCALE);
@@ -977,6 +981,7 @@ DynamicFontImportSettingsDialog::DynamicFontImportSettingsDialog() {
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel,Auto (Except Pixel Fonts)"), 4));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "keep_rounding_remainders"), true));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::NIL, "Metadata Overrides", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP), Variant()));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::DICTIONARY, "language_support"), Dictionary()));

View File

@@ -82,6 +82,9 @@ bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, co
if (p_option == "antialiasing" && bool(p_options["multichannel_signed_distance_field"])) {
return false;
}
if (p_option == "oversampling" && bool(p_options["multichannel_signed_distance_field"])) {
return false;
}
if (p_option == "subpixel_positioning" && bool(p_options["multichannel_signed_distance_field"])) {
return false;
}
@@ -124,6 +127,7 @@ void ResourceImporterDynamicFont::get_import_options(const String &p_path, List<
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel,Auto (Except Pixel Fonts)"), 4));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "keep_rounding_remainders"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0));
r_options->push_back(ImportOption(PropertyInfo(Variant::NIL, "Fallbacks", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP), Variant()));
r_options->push_back(ImportOption(PropertyInfo(Variant::ARRAY, "fallbacks", PROPERTY_HINT_ARRAY_TYPE, MAKE_RESOURCE_TYPE_HINT("Font")), Array()));
@@ -162,6 +166,7 @@ Error ResourceImporterDynamicFont::import(ResourceUID::ID p_source_id, const Str
int hinting = p_options["hinting"];
int subpixel_positioning = p_options["subpixel_positioning"];
bool keep_rounding_remainders = p_options["keep_rounding_remainders"];
real_t oversampling = p_options["oversampling"];
Array fallbacks = p_options["fallbacks"];
// Load base font data.
@@ -183,6 +188,7 @@ Error ResourceImporterDynamicFont::import(ResourceUID::ID p_source_id, const Str
font->set_modulate_color_glyphs(modulate_color_glyphs);
font->set_allow_system_fallback(allow_system_fallback);
font->set_hinting((TextServer::Hinting)hinting);
font->set_oversampling(oversampling);
font->set_fallbacks(fallbacks);
if (subpixel_positioning == 4 /* Auto (Except Pixel Fonts) */) {

View File

@@ -2718,6 +2718,25 @@ void TextServerAdvanced::_font_set_variation_coordinates(const RID &p_font_rid,
}
}
double TextServerAdvanced::_font_get_oversampling(const RID &p_font_rid) const {
FontAdvanced *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL_V(fd, -1.0);
MutexLock lock(fd->mutex);
return fd->oversampling_override;
}
void TextServerAdvanced::_font_set_oversampling(const RID &p_font_rid, double p_oversampling) {
FontAdvanced *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);
MutexLock lock(fd->mutex);
if (fd->oversampling_override != p_oversampling) {
_font_clear_cache(fd);
fd->oversampling_override = p_oversampling;
}
}
Dictionary TextServerAdvanced::_font_get_variation_coordinates(const RID &p_font_rid) const {
FontAdvanced *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL_V(fd, Dictionary());
@@ -3902,7 +3921,9 @@ void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
bool viewport_oversampling = false;
float oversampling_factor = p_oversampling;
if (p_oversampling <= 0.0) {
if (vp_oversampling > 0.0) {
if (fd->oversampling_override > 0.0) {
oversampling_factor = fd->oversampling_override;
} else if (vp_oversampling > 0.0) {
oversampling_factor = vp_oversampling;
viewport_oversampling = true;
} else {
@@ -4046,7 +4067,9 @@ void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const R
bool viewport_oversampling = false;
float oversampling_factor = p_oversampling;
if (p_oversampling <= 0.0) {
if (vp_oversampling > 0.0) {
if (fd->oversampling_override > 0.0) {
oversampling_factor = fd->oversampling_override;
} else if (vp_oversampling > 0.0) {
oversampling_factor = vp_oversampling;
viewport_oversampling = true;
} else {

View File

@@ -344,6 +344,7 @@ class TextServerAdvanced : public TextServerExtension {
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
bool keep_rounding_remainders = true;
Dictionary variation_coordinates;
double oversampling_override = 0.0;
double embolden = 0.0;
Transform2D transform;
@@ -849,6 +850,9 @@ public:
MODBIND2(font_set_variation_coordinates, const RID &, const Dictionary &);
MODBIND1RC(Dictionary, font_get_variation_coordinates, const RID &);
MODBIND2(font_set_oversampling, const RID &, double);
MODBIND1RC(double, font_get_oversampling, const RID &);
MODBIND2(font_set_hinting, const RID &, TextServer::Hinting);
MODBIND1RC(TextServer::Hinting, font_get_hinting, const RID &);

View File

@@ -1693,6 +1693,25 @@ void TextServerFallback::_font_set_variation_coordinates(const RID &p_font_rid,
}
}
double TextServerFallback::_font_get_oversampling(const RID &p_font_rid) const {
FontFallback *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL_V(fd, -1.0);
MutexLock lock(fd->mutex);
return fd->oversampling_override;
}
void TextServerFallback::_font_set_oversampling(const RID &p_font_rid, double p_oversampling) {
FontFallback *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);
MutexLock lock(fd->mutex);
if (fd->oversampling_override != p_oversampling) {
_font_clear_cache(fd);
fd->oversampling_override = p_oversampling;
}
}
Dictionary TextServerFallback::_font_get_variation_coordinates(const RID &p_font_rid) const {
FontFallback *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL_V(fd, Dictionary());
@@ -2815,7 +2834,9 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
bool viewport_oversampling = false;
float oversampling_factor = p_oversampling;
if (p_oversampling <= 0.0) {
if (vp_oversampling > 0.0) {
if (fd->oversampling_override > 0.0) {
oversampling_factor = fd->oversampling_override;
} else if (vp_oversampling > 0.0) {
oversampling_factor = vp_oversampling;
viewport_oversampling = true;
} else {
@@ -2959,7 +2980,9 @@ void TextServerFallback::_font_draw_glyph_outline(const RID &p_font_rid, const R
bool viewport_oversampling = false;
float oversampling_factor = p_oversampling;
if (p_oversampling <= 0.0) {
if (vp_oversampling > 0.0) {
if (fd->oversampling_override > 0.0) {
oversampling_factor = fd->oversampling_override;
} else if (vp_oversampling > 0.0) {
oversampling_factor = vp_oversampling;
viewport_oversampling = true;
} else {

View File

@@ -283,6 +283,7 @@ class TextServerFallback : public TextServerExtension {
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
bool keep_rounding_remainders = true;
Dictionary variation_coordinates;
double oversampling_override = 0.0;
double embolden = 0.0;
Transform2D transform;
@@ -704,6 +705,9 @@ public:
MODBIND2(font_set_variation_coordinates, const RID &, const Dictionary &);
MODBIND1RC(Dictionary, font_get_variation_coordinates, const RID &);
MODBIND2(font_set_oversampling, const RID &, double);
MODBIND1RC(double, font_get_oversampling, const RID &);
MODBIND2(font_set_hinting, const RID &, TextServer::Hinting);
MODBIND1RC(TextServer::Hinting, font_get_hinting, const RID &);

View File

@@ -607,6 +607,7 @@ _FORCE_INLINE_ void FontFile::_ensure_rid(int p_cache_index, int p_make_linked_f
TS->font_set_hinting(cache[p_cache_index], hinting);
TS->font_set_subpixel_positioning(cache[p_cache_index], subpixel_positioning);
TS->font_set_keep_rounding_remainders(cache[p_cache_index], keep_rounding_remainders);
TS->font_set_oversampling(cache[p_cache_index], oversampling_override);
}
}
}
@@ -941,13 +942,9 @@ void FontFile::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_keep_rounding_remainders", "keep_rounding_remainders"), &FontFile::set_keep_rounding_remainders);
ClassDB::bind_method(D_METHOD("get_keep_rounding_remainders"), &FontFile::get_keep_rounding_remainders);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_oversampling", "oversampling"), &FontFile::set_oversampling);
ClassDB::bind_method(D_METHOD("get_oversampling"), &FontFile::get_oversampling);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_NONE, "", 0), "set_oversampling", "get_oversampling");
#endif
ClassDB::bind_method(D_METHOD("get_cache_count"), &FontFile::get_cache_count);
ClassDB::bind_method(D_METHOD("clear_cache"), &FontFile::clear_cache);
ClassDB::bind_method(D_METHOD("remove_cache", "cache_index"), &FontFile::remove_cache);
@@ -1066,6 +1063,7 @@ void FontFile::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_fixed_size", "get_fixed_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_size_scale_mode", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_fixed_size_scale_mode", "get_fixed_size_scale_mode");
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "opentype_feature_overrides", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_opentype_feature_overrides", "get_opentype_feature_overrides");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_oversampling", "get_oversampling");
}
void FontFile::_validate_property(PropertyInfo &p_property) const {
@@ -1426,6 +1424,7 @@ void FontFile::reset_state() {
hinting = TextServer::HINTING_LIGHT;
subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_DISABLED;
keep_rounding_remainders = true;
oversampling_override = 0.0;
msdf_pixel_range = 14;
msdf_size = 128;
fixed_size = 0;
@@ -2339,6 +2338,21 @@ bool FontFile::get_keep_rounding_remainders() const {
return keep_rounding_remainders;
}
void FontFile::set_oversampling(real_t p_oversampling) {
if (oversampling_override != p_oversampling) {
oversampling_override = p_oversampling;
for (int i = 0; i < cache.size(); i++) {
_ensure_rid(i);
TS->font_set_oversampling(cache[i], oversampling_override);
}
emit_changed();
}
}
real_t FontFile::get_oversampling() const {
return oversampling_override;
}
RID FontFile::find_variation(const Dictionary &p_variation_coordinates, int p_face_index, float p_strength, Transform2D p_transform, int p_spacing_top, int p_spacing_bottom, int p_spacing_space, int p_spacing_glyph, float p_baseline_offset) const {
// Find existing variation cache.
const Dictionary &supported_coords = get_supported_variation_list();
@@ -3129,13 +3143,9 @@ void SystemFont::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_msdf_size", "msdf_size"), &SystemFont::set_msdf_size);
ClassDB::bind_method(D_METHOD("get_msdf_size"), &SystemFont::get_msdf_size);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_oversampling", "oversampling"), &SystemFont::set_oversampling);
ClassDB::bind_method(D_METHOD("get_oversampling"), &SystemFont::get_oversampling);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_NONE, "", 0), "set_oversampling", "get_oversampling");
#endif
ClassDB::bind_method(D_METHOD("get_font_names"), &SystemFont::get_font_names);
ClassDB::bind_method(D_METHOD("set_font_names", "names"), &SystemFont::set_font_names);
@@ -3160,6 +3170,7 @@ void SystemFont::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field"), "set_multichannel_signed_distance_field", "is_multichannel_signed_distance_field");
ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_pixel_range"), "set_msdf_pixel_range", "get_msdf_pixel_range");
ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_size"), "set_msdf_size", "get_msdf_size");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "oversampling"), "set_oversampling", "get_oversampling");
}
void SystemFont::_update_rids() const {
@@ -3263,6 +3274,7 @@ void SystemFont::_update_base_font() {
file->set_hinting(hinting);
file->set_subpixel_positioning(subpixel_positioning);
file->set_keep_rounding_remainders(keep_rounding_remainders);
file->set_oversampling(oversampling_override);
file->set_multichannel_signed_distance_field(msdf);
file->set_msdf_pixel_range(msdf_pixel_range);
file->set_msdf_size(msdf_size);
@@ -3307,6 +3319,7 @@ void SystemFont::reset_state() {
hinting = TextServer::HINTING_LIGHT;
subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_DISABLED;
keep_rounding_remainders = true;
oversampling_override = 0.0;
msdf = false;
Font::reset_state();
@@ -3487,6 +3500,20 @@ bool SystemFont::get_keep_rounding_remainders() const {
return keep_rounding_remainders;
}
void SystemFont::set_oversampling(real_t p_oversampling) {
if (oversampling_override != p_oversampling) {
oversampling_override = p_oversampling;
if (base_font.is_valid()) {
base_font->set_oversampling(oversampling_override);
}
emit_changed();
}
}
real_t SystemFont::get_oversampling() const {
return oversampling_override;
}
void SystemFont::set_multichannel_signed_distance_field(bool p_msdf) {
if (msdf != p_msdf) {
msdf = p_msdf;

View File

@@ -203,6 +203,7 @@ class FontFile : public Font {
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
bool keep_rounding_remainders = true;
double oversampling_override = 0.0;
#ifndef DISABLE_DEPRECATED
real_t bmp_height = 0.0;
@@ -291,10 +292,8 @@ public:
virtual void set_keep_rounding_remainders(bool p_keep_rounding_remainders);
virtual bool get_keep_rounding_remainders() const;
#ifndef DISABLE_DEPRECATED
virtual void set_oversampling(real_t p_oversampling) {}
virtual real_t get_oversampling() const { return 1.0; }
#endif
virtual void set_oversampling(real_t p_oversampling);
virtual real_t get_oversampling() const;
// Cache.
virtual RID find_variation(const Dictionary &p_variation_coordinates, int p_face_index = 0, float p_strength = 0.0, Transform2D p_transform = Transform2D(), int p_spacing_top = 0, int p_spacing_bottom = 0, int p_spacing_space = 0, int p_spacing_glyph = 0, float p_baseline_offset = 0.0) const override;
@@ -495,6 +494,7 @@ class SystemFont : public Font {
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
bool keep_rounding_remainders = true;
double oversampling_override = 0.0;
bool msdf = false;
int msdf_pixel_range = 16;
int msdf_size = 48;
@@ -538,10 +538,8 @@ public:
virtual void set_keep_rounding_remainders(bool p_keep_rounding_remainders);
virtual bool get_keep_rounding_remainders() const;
#ifndef DISABLE_DEPRECATED
virtual void set_oversampling(real_t p_oversampling) {}
virtual real_t get_oversampling() const { return 1.0; }
#endif
virtual void set_oversampling(real_t p_oversampling);
virtual real_t get_oversampling() const;
virtual void set_multichannel_signed_distance_field(bool p_msdf);
virtual bool is_multichannel_signed_distance_field() const;

View File

@@ -756,15 +756,15 @@ Dictionary TextServerExtension::font_get_variation_coordinates(const RID &p_font
return ret;
}
#ifndef DISABLE_DEPRECATED
void TextServerExtension::font_set_oversampling(const RID &p_font_rid, double p_oversampling) {
// NOP
GDVIRTUAL_CALL(_font_set_oversampling, p_font_rid, p_oversampling);
}
double TextServerExtension::font_get_oversampling(const RID &p_font_rid) const {
return 1.0;
double ret = -1.0;
GDVIRTUAL_CALL(_font_get_oversampling, p_font_rid, ret);
return ret;
}
#endif
TypedArray<Vector2i> TextServerExtension::font_get_size_cache_list(const RID &p_font_rid) const {
TypedArray<Vector2i> ret;

View File

@@ -221,12 +221,10 @@ public:
GDVIRTUAL2(_font_set_variation_coordinates, RID, Dictionary);
GDVIRTUAL1RC(Dictionary, _font_get_variation_coordinates, RID);
#ifndef DISABLE_DEPRECATED
virtual void font_set_oversampling(const RID &p_font_rid, double p_oversampling) override;
virtual double font_get_oversampling(const RID &p_font_rid) const override;
GDVIRTUAL2(_font_set_oversampling, RID, double);
GDVIRTUAL1RC(double, _font_get_oversampling, RID);
#endif
virtual TypedArray<Vector2i> font_get_size_cache_list(const RID &p_font_rid) const override;
virtual void font_clear_size_cache(const RID &p_font_rid) override;

View File

@@ -293,10 +293,8 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("font_set_variation_coordinates", "font_rid", "variation_coordinates"), &TextServer::font_set_variation_coordinates);
ClassDB::bind_method(D_METHOD("font_get_variation_coordinates", "font_rid"), &TextServer::font_get_variation_coordinates);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("font_set_oversampling", "font_rid", "oversampling"), &TextServer::font_set_oversampling);
ClassDB::bind_method(D_METHOD("font_get_oversampling", "font_rid"), &TextServer::font_get_oversampling);
#endif
ClassDB::bind_method(D_METHOD("font_get_size_cache_list", "font_rid"), &TextServer::font_get_size_cache_list);
ClassDB::bind_method(D_METHOD("font_clear_size_cache", "font_rid"), &TextServer::font_clear_size_cache);

View File

@@ -352,10 +352,8 @@ public:
virtual void font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) = 0;
virtual Dictionary font_get_variation_coordinates(const RID &p_font_rid) const = 0;
#ifndef DISABLE_DEPRECATED
virtual void font_set_oversampling(const RID &p_font_rid, double p_oversampling) {}
virtual double font_get_oversampling(const RID &p_font_rid) const { return 1.0; }
#endif
virtual void font_set_oversampling(const RID &p_font_rid, double p_oversampling) = 0;
virtual double font_get_oversampling(const RID &p_font_rid) const = 0;
virtual TypedArray<Vector2i> font_get_size_cache_list(const RID &p_font_rid) const = 0;
virtual void font_clear_size_cache(const RID &p_font_rid) = 0;