diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-03-11 09:31:16 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-03-11 14:02:30 +0200 |
commit | b32e8d63d8d3bfe65f6692ff15f5a82171a8bf61 (patch) | |
tree | 7a6e7a945a25a8e954e81b9e409f80188db4f2c9 /editor/import | |
parent | 1e099afc8ac420f5c97b07067e28d6309ed55ae7 (diff) |
Add options to embolden and transform font outlines to simulate bold and italic typefaces.
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/dynamic_font_import_settings.cpp | 14 | ||||
-rw-r--r-- | editor/import/resource_importer_dynamic_font.cpp | 6 |
2 files changed, 20 insertions, 0 deletions
diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index f0a2d7d553..2ecc483938 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -484,6 +484,14 @@ void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_proper if (font_preview->get_data_count() > 0) { font_preview->get_data(0)->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int()); } + } else if (p_edited_property == "embolden") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_embolden(import_settings_data->get("embolden")); + } + } else if (p_edited_property == "transform") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_transform(import_settings_data->get("transform")); + } } else if (p_edited_property == "oversampling") { if (font_preview->get_data_count() > 0) { font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling")); @@ -924,6 +932,8 @@ void DynamicFontImportSettings::_re_import() { main_settings["force_autohinter"] = import_settings_data->get("force_autohinter"); main_settings["hinting"] = import_settings_data->get("hinting"); main_settings["subpixel_positioning"] = import_settings_data->get("subpixel_positioning"); + main_settings["embolden"] = import_settings_data->get("embolden"); + main_settings["transform"] = import_settings_data->get("transform"); main_settings["oversampling"] = import_settings_data->get("oversampling"); main_settings["compress"] = import_settings_data->get("compress"); @@ -1275,6 +1285,8 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { font_preview->get_data(0)->set_force_autohinter(import_settings_data->get("force_autohinter")); font_preview->get_data(0)->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int()); font_preview->get_data(0)->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int()); + font_preview->get_data(0)->set_embolden(import_settings_data->get("embolden")); + font_preview->get_data(0)->set_transform(import_settings_data->get("transform")); font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling")); } font_preview_label->add_theme_font_override("font", font_preview); @@ -1334,6 +1346,8 @@ DynamicFontImportSettings::DynamicFontImportSettings() { options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false)); 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"), 1)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "embolden", PROPERTY_HINT_RANGE, "-2,2,0.01"), 0.f)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::TRANSFORM2D, "transform"), Transform2D())); 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::BOOL, "compress", PROPERTY_HINT_NONE, ""), false)); diff --git a/editor/import/resource_importer_dynamic_font.cpp b/editor/import/resource_importer_dynamic_font.cpp index 70fc87ea3f..077b94bb4e 100644 --- a/editor/import/resource_importer_dynamic_font.cpp +++ b/editor/import/resource_importer_dynamic_font.cpp @@ -109,6 +109,8 @@ 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, "embolden", PROPERTY_HINT_RANGE, "-2,2,0.01"), 0.f)); + r_options->push_back(ImportOption(PropertyInfo(Variant::TRANSFORM2D, "transform"), Transform2D())); 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)); @@ -186,6 +188,8 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str int hinting = p_options["hinting"]; int subpixel_positioning = p_options["subpixel_positioning"]; real_t oversampling = p_options["oversampling"]; + real_t embolden = p_options["embolden"]; + Transform2D transform = p_options["transform"]; // Load base font data. Vector<uint8_t> data = FileAccess::get_file_as_array(p_source_file); @@ -202,6 +206,8 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str font->set_fixed_size(0); font->set_force_autohinter(autohinter); font->set_subpixel_positioning((TextServer::SubpixelPositioning)subpixel_positioning); + font->set_embolden(embolden); + font->set_transform(transform); font->set_hinting((TextServer::Hinting)hinting); font->set_oversampling(oversampling); |