Add line_breaking_strictness
project setting.
This commit is contained in:
parent
d9cd011e2f
commit
e87cccefca
@ -1646,6 +1646,14 @@
|
||||
[b]Note:[/b] "ICU / HarfBuzz / Graphite" text server data includes dictionaries for Burmese, Chinese, Japanese, Khmer, Lao and Thai as well as Unicode Standard Annex #29 and Unicode Standard Annex #14 word and line breaking rules. Data is about 4 MB large.
|
||||
[b]Note:[/b] [TextServerFallback] does not use additional data.
|
||||
</member>
|
||||
<member name="internationalization/locale/line_breaking_strictness" type="int" setter="" getter="" default="0">
|
||||
Default strictness of line-breaking rules. Can be overridden by adding [code]@lb={auto,loose,normal,strict}[/code] to the language code.
|
||||
- [b]Auto[/b] ([code]0[/code]) - strictness is based on the length of the line.
|
||||
- [b]Loose[/b] ([code]1[/code]) - the least restrictive set of line-breaking rules. Typically used for short lines.
|
||||
- [b]Normal[/b] ([code]2[/code]) - the most common set of line-breaking rules.
|
||||
- [b]Strict[/b] ([code]3[/code]) - the most stringent set of line-breaking rules.
|
||||
See [url=https://www.w3.org/TR/css-text-3/#line-break-property]Line Breaking Strictness: the line-break property[/url] for more info.
|
||||
</member>
|
||||
<member name="internationalization/locale/test" type="String" setter="" getter="" default="""">
|
||||
If non-empty, this locale will be used instead of the automatically detected system locale.
|
||||
[b]Note:[/b] This setting also applies to the exported project. To only affect testing within the editor, override this setting with an [code]editor[/code] [url=$DOCS_URL/tutorials/export/feature_tags.html]feature tag[/url] for localization testing purposes.
|
||||
|
@ -2638,6 +2638,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
}
|
||||
|
||||
GLOBAL_DEF_BASIC("internationalization/locale/include_text_server_data", false);
|
||||
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "internationalization/locale/line_breaking_strictness", PROPERTY_HINT_ENUM, "Auto,Loose,Normal,Strict"), 0);
|
||||
|
||||
OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", true);
|
||||
OS::get_singleton()->_allow_layered = GLOBAL_DEF_RST("display/window/per_pixel_transparency/allowed", false);
|
||||
|
@ -6513,7 +6513,17 @@ UBreakIterator *TextServerAdvanced::_create_line_break_iterator_for_locale(const
|
||||
// Creating UBreakIterator (ubrk_open) is surprisingly costly.
|
||||
// However, cloning (ubrk_clone) is cheaper, so we keep around blueprints to accelerate creating new ones.
|
||||
|
||||
const String language = p_language.is_empty() ? TranslationServer::get_singleton()->get_tool_locale() : p_language;
|
||||
String language = p_language.is_empty() ? TranslationServer::get_singleton()->get_tool_locale() : p_language;
|
||||
if (!language.contains("@")) {
|
||||
if (lb_strictness == LB_LOOSE) {
|
||||
language += "@lb=loose";
|
||||
} else if (lb_strictness == LB_NORMAL) {
|
||||
language += "@lb=normal";
|
||||
} else if (lb_strictness == LB_STRICT) {
|
||||
language += "@lb=strict";
|
||||
}
|
||||
}
|
||||
|
||||
_THREAD_SAFE_METHOD_
|
||||
const HashMap<String, UBreakIterator *>::Iterator key_value = line_break_iterators_per_language.find(language);
|
||||
if (key_value) {
|
||||
@ -8066,12 +8076,14 @@ bool TextServerAdvanced::_is_valid_letter(uint64_t p_unicode) const {
|
||||
|
||||
void TextServerAdvanced::_update_settings() {
|
||||
lcd_subpixel_layout.set((TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout"));
|
||||
lb_strictness = (LineBreakStrictness)(int)GLOBAL_GET("internationalization/locale/line_breaking_strictness");
|
||||
}
|
||||
|
||||
TextServerAdvanced::TextServerAdvanced() {
|
||||
_insert_num_systems_lang();
|
||||
_insert_feature_sets();
|
||||
_bmp_create_font_funcs();
|
||||
_update_settings();
|
||||
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &TextServerAdvanced::_update_settings));
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,15 @@ class TextServerAdvanced : public TextServerExtension {
|
||||
HashMap<StringName, int32_t> feature_sets;
|
||||
HashMap<int32_t, FeatureInfo> feature_sets_inv;
|
||||
|
||||
enum LineBreakStrictness {
|
||||
LB_AUTO,
|
||||
LB_LOOSE,
|
||||
LB_NORMAL,
|
||||
LB_STRICT,
|
||||
};
|
||||
|
||||
SafeNumeric<TextServer::FontLCDSubpixelLayout> lcd_subpixel_layout{ TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_NONE };
|
||||
LineBreakStrictness lb_strictness = LB_AUTO;
|
||||
void _update_settings();
|
||||
|
||||
void _insert_num_systems_lang();
|
||||
|
Loading…
x
Reference in New Issue
Block a user