From 29199579f780f4f66350e1962926c08b2ddcf65b Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Mon, 10 Jan 2022 10:13:22 +0200 Subject: Add sub-pixel glyph positioning support. --- editor/import/resource_importer_dynamicfont.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'editor/import/resource_importer_dynamicfont.cpp') diff --git a/editor/import/resource_importer_dynamicfont.cpp b/editor/import/resource_importer_dynamicfont.cpp index 11f563a982..42be76ba12 100644 --- a/editor/import/resource_importer_dynamicfont.cpp +++ b/editor/import/resource_importer_dynamicfont.cpp @@ -76,6 +76,9 @@ bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, co 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; + } return true; } @@ -104,6 +107,7 @@ void ResourceImporterDynamicFont::get_import_options(const String &p_path, List< r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false)); 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"), 1)); 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::BOOL, "compress"), true)); @@ -179,6 +183,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str bool autohinter = p_options["force_autohinter"]; int hinting = p_options["hinting"]; + int subpixel_positioning = p_options["subpixel_positioning"]; real_t oversampling = p_options["oversampling"]; // Load base font data. @@ -195,6 +200,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str font->set_opentype_feature_overrides(ot_ov); font->set_fixed_size(0); font->set_force_autohinter(autohinter); + font->set_subpixel_positioning((TextServer::SubpixelPositioning)subpixel_positioning); font->set_hinting((TextServer::Hinting)hinting); font->set_oversampling(oversampling); -- cgit v1.2.3