|
@@ -118,7 +118,7 @@ void ResourceImporterDynamicFont::get_import_options(const String &p_path, List<
|
|
|
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "allow_system_fallback"), true));
|
|
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "allow_system_fallback"), true));
|
|
|
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false));
|
|
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, "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::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::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0));
|
|
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::NIL, "Fallbacks", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP), Variant()));
|
|
@@ -176,11 +176,44 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str
|
|
|
font->set_fixed_size(0);
|
|
font->set_fixed_size(0);
|
|
|
font->set_force_autohinter(autohinter);
|
|
font->set_force_autohinter(autohinter);
|
|
|
font->set_allow_system_fallback(allow_system_fallback);
|
|
font->set_allow_system_fallback(allow_system_fallback);
|
|
|
- font->set_subpixel_positioning((TextServer::SubpixelPositioning)subpixel_positioning);
|
|
|
|
|
font->set_hinting((TextServer::Hinting)hinting);
|
|
font->set_hinting((TextServer::Hinting)hinting);
|
|
|
font->set_oversampling(oversampling);
|
|
font->set_oversampling(oversampling);
|
|
|
font->set_fallbacks(fallbacks);
|
|
font->set_fallbacks(fallbacks);
|
|
|
|
|
|
|
|
|
|
+ if (subpixel_positioning == 4 /* Auto (Except Pixel Fonts) */) {
|
|
|
|
|
+ PackedInt32Array glyphs = TS->font_get_supported_glyphs(font->get_rids()[0]);
|
|
|
|
|
+ bool is_pixel = true;
|
|
|
|
|
+ for (int32_t gl : glyphs) {
|
|
|
|
|
+ Dictionary ct = TS->font_get_glyph_contours(font->get_rids()[0], 16, gl);
|
|
|
|
|
+ PackedInt32Array contours = ct["contours"];
|
|
|
|
|
+ PackedVector3Array points = ct["points"];
|
|
|
|
|
+ int prev_start = 0;
|
|
|
|
|
+ for (int i = 0; i < contours.size(); i++) {
|
|
|
|
|
+ for (int j = prev_start; j <= contours[i]; j++) {
|
|
|
|
|
+ int next_point = (j < contours[i]) ? (j + 1) : prev_start;
|
|
|
|
|
+ if ((points[j].z != TextServer::CONTOUR_CURVE_TAG_ON) || (!Math::is_equal_approx(points[j].x, points[next_point].x) && !Math::is_equal_approx(points[j].y, points[next_point].y))) {
|
|
|
|
|
+ is_pixel = false;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ prev_start = contours[i] + 1;
|
|
|
|
|
+ if (!is_pixel) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!is_pixel) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (is_pixel && !glyphs.is_empty()) {
|
|
|
|
|
+ print_line(vformat("%s: Pixel font detected, disabling subpixel positioning.", p_source_file));
|
|
|
|
|
+ subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_DISABLED;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ font->set_subpixel_positioning((TextServer::SubpixelPositioning)subpixel_positioning);
|
|
|
|
|
+
|
|
|
Dictionary langs = p_options["language_support"];
|
|
Dictionary langs = p_options["language_support"];
|
|
|
for (int i = 0; i < langs.size(); i++) {
|
|
for (int i = 0; i < langs.size(); i++) {
|
|
|
String key = langs.get_key_at_index(i);
|
|
String key = langs.get_key_at_index(i);
|