Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Bidi and Font Features demo for 4.0.rc4 #763

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Aug 3, 2022

  • Enable low processor mode and multiple resolution-friendly project settings for consistency with other demos.
  • Use Compatibility rendering method for better performance and compatibility.
  • Prevent screenshots from being imported as resources.

@Calinou Calinou added the update label Aug 3, 2022
@bruvzg
Copy link
Member

bruvzg commented Aug 4, 2022

OpenType feature overrides back. cc @bruvzg

It's now part of variation font, instead of control property.

@Calinou Calinou force-pushed the update-bidi-font-features-demo branch from f613d61 to fa6011c Compare January 20, 2023 09:15
@Calinou Calinou requested a review from bruvzg January 20, 2023 09:44
@Calinou Calinou marked this pull request as ready for review January 20, 2023 09:44
@Calinou Calinou changed the title Update Bidi and Font Features demo for the latest master branch Update Bidi and Font Features demo for 4.0.beta13 Jan 20, 2023
@aaronfranke aaronfranke added this to the 4.0 milestone Jan 22, 2023
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most fonts and some control properties seems to be not set, and there were some change to the BiDi override as well:

Here's a fix:

diff --git a/gui/bidi_and_font_features/bidi.tscn b/gui/bidi_and_font_features/bidi.tscn
index 37caf7ce..9727b410 100644
--- a/gui/bidi_and_font_features/bidi.tscn
+++ b/gui/bidi_and_font_features/bidi.tscn
@@ -1,8 +1,10 @@
-[gd_scene load_steps=11 format=3 uid="uid://doa7j7q1j4p4e"]
+[gd_scene load_steps=13 format=3 uid="uid://doa7j7q1j4p4e"]
 
 [ext_resource type="FontVariation" uid="uid://dewurnqemtrs" path="res://noto_font.tres" id="1"]
 [ext_resource type="Script" path="res://bidi.gd" id="2"]
+[ext_resource type="FontFile" uid="uid://dcyy0x2u3jocr" path="res://fonts/NotoSansThaiUI_Regular.ttf" id="2_plk2w"]
 [ext_resource type="Script" path="res://custom_st_parser.gd" id="3"]
+[ext_resource type="FontFile" uid="uid://61ui1kmi5tt7" path="res://fonts/NotoNaskhArabicUI_Regular.ttf" id="3_cf43x"]
 [ext_resource type="FontVariation" uid="uid://bymgwaapysw4i" path="res://lib_font.tres" id="4"]
 [ext_resource type="FontFile" uid="uid://bic5b75wmaxwj" path="res://fonts/LinLibertine_R.otf" id="5_dd4o7"]
 
@@ -42,6 +44,8 @@ layout_mode = 3
 anchors_preset = 15
 anchor_right = 1.0
 anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
 script = ExtResource("2")
 
 [node name="TabContainer" type="TabContainer" parent="."]
@@ -64,14 +68,15 @@ theme_override_font_sizes/font_size = 14
 text = "1. Line breaking and space justification."
 
 [node name="LabelTHNoBreak" type="Label" parent="TabContainer/Line breaking and justification"]
-layout_mode = 0
+layout_mode = 1
+anchors_preset = -1
 anchor_top = 0.000891266
 anchor_bottom = 0.000891266
 offset_left = 30.0
-offset_top = 69.5027
-offset_right = 988.0
-offset_bottom = 92.5027
-theme_override_fonts/font = ExtResource("1")
+offset_top = 69.4474
+offset_right = 1046.0
+offset_bottom = 92.4474
+theme_override_fonts/font = ExtResource("2_plk2w")
 theme_override_font_sizes/font_size = 14
 text = "ภาษาไทย หรือ ภาษาไทยกลาง เป็นภาษาราชการและภาษาประจำชาติของประเทศไทย ภาษาไทยเป็นภาษาในกลุ่มภาษาไทซึ่งเป็นกลุ่มย่อยของตระกูลภาษาขร้า-ไท"
 autowrap_mode = 3
@@ -80,11 +85,12 @@ autowrap_mode = 3
 layout_mode = 0
 offset_left = 30.0
 offset_top = 100.0
-offset_right = 333.0
+offset_right = 331.0
 offset_bottom = 200.0
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("2_plk2w")
 theme_override_font_sizes/font_size = 14
 text = "ภาษาไทย หรือ ภาษาไทยกลาง เป็นภาษาราชการและภาษาประจำชาติของประเทศไทย ภาษาไทยเป็นภาษาในกลุ่มภาษาไทซึ่งเป็นกลุ่มย่อยของตระกูลภาษาขร้า-ไท"
+horizontal_alignment = 3
 autowrap_mode = 3
 
 [node name="LabelJstInfo" type="Label" parent="TabContainer/Line breaking and justification"]
@@ -100,16 +106,18 @@ theme_override_font_sizes/font_size = 14
 text = "2. Kashida justification."
 
 [node name="LabelARNoJst2" type="Label" parent="TabContainer/Line breaking and justification"]
-layout_mode = 0
+layout_mode = 1
+anchors_preset = -1
 anchor_top = 0.000891266
 anchor_bottom = 0.000891266
 offset_left = 30.0
-offset_top = 248.5
-offset_right = 830.0
-offset_bottom = 271.5
-theme_override_fonts/font = ExtResource("1")
+offset_top = 248.447
+offset_right = 258.0
+offset_bottom = 271.447
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 text = "آنچ اندر وهم ناید آن شوم"
+horizontal_alignment = 3
 
 [node name="LabelARJst" type="Label" parent="TabContainer/Line breaking and justification"]
 layout_mode = 0
@@ -119,7 +127,7 @@ offset_left = 30.0
 offset_top = 273.5
 offset_right = 255.0
 offset_bottom = 296.5
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 text = "آنچ اندر وهم ناید آن شوم"
 
@@ -143,7 +151,7 @@ offset_left = 30.0
 offset_top = 60.0
 offset_right = 260.0
 offset_bottom = 90.0
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 text = "Najaf (ٱلنَّجَف‎), also known as Baniqia."
 editable = false
@@ -156,7 +164,7 @@ offset_left = 270.0
 offset_top = 60.0
 offset_right = 500.0
 offset_bottom = 90.0
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 text = "Najaf (ٱلنَّجَف‎), also known as Baniqia."
 editable = false
@@ -169,7 +177,7 @@ offset_left = 510.0
 offset_top = 60.0
 offset_right = 740.0
 offset_bottom = 90.0
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 text = "Najaf (ٱلنَّجَف‎), also known as Baniqia."
 editable = false
@@ -183,7 +191,7 @@ offset_left = 30.0
 offset_top = 99.5
 offset_right = 260.0
 offset_bottom = 129.5
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 text = "الإنجليزية أو الإنغليزية (بالإنجليزية: English)‏،"
 editable = false
@@ -196,7 +204,7 @@ offset_left = 270.0
 offset_top = 100.0
 offset_right = 500.0
 offset_bottom = 130.0
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 text = "الإنجليزية أو الإنغليزية (بالإنجليزية: English)‏،"
 editable = false
@@ -208,7 +216,7 @@ offset_left = 510.0
 offset_top = 100.0
 offset_right = 740.0
 offset_bottom = 130.0
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 text = "الإنجليزية أو الإنغليزية (بالإنجليزية: English)‏،"
 editable = false
@@ -258,7 +266,7 @@ offset_left = 582.0
 offset_top = 188.0
 offset_right = 882.0
 offset_bottom = 218.0
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 editable = false
 context_menu_enabled = false
@@ -269,7 +277,7 @@ offset_left = 582.0
 offset_top = 236.0
 offset_right = 882.0
 offset_bottom = 266.0
-theme_override_fonts/font = ExtResource("1")
+theme_override_fonts/font = ExtResource("3_cf43x")
 theme_override_font_sizes/font_size = 14
 editable = false
 context_menu_enabled = false
diff --git a/gui/bidi_and_font_features/custom_st_parser.gd b/gui/bidi_and_font_features/custom_st_parser.gd
index 3b63dc6b..02f3396a 100644
--- a/gui/bidi_and_font_features/custom_st_parser.gd
+++ b/gui/bidi_and_font_features/custom_st_parser.gd
@@ -7,8 +7,8 @@ func _structured_text_parser(args, text):
 	var count = int(tags.size())
 	output.clear()
 	for i in range(count):
-		var range1 = Vector2i(prev, prev + tags[i].length())
-		var range2 = Vector2i(prev + tags[i].length(), prev + tags[i].length() + 1)
+		var range1 = Vector3i(prev, prev + tags[i].length(), TextServer.DIRECTION_AUTO)
+		var range2 = Vector3i(prev + tags[i].length(), prev + tags[i].length() + 1, TextServer.DIRECTION_AUTO)
 		output.push_front(range1)
 		output.push_front(range2)
 		prev = prev + tags[i].length() + 1
diff --git a/gui/bidi_and_font_features/fonts/NotoNaskhArabicUI_Regular.ttf.import b/gui/bidi_and_font_features/fonts/NotoNaskhArabicUI_Regular.ttf.import
index dbd37cb3..b19a5027 100644
--- a/gui/bidi_and_font_features/fonts/NotoNaskhArabicUI_Regular.ttf.import
+++ b/gui/bidi_and_font_features/fonts/NotoNaskhArabicUI_Regular.ttf.import
@@ -24,7 +24,7 @@ hinting=1
 subpixel_positioning=1
 oversampling=0.0
 Fallbacks=null
-fallbacks=[]
+fallbacks=[Resource("res://fonts/NotoSansUI_Regular.ttf")]
 Compress=null
 compress=true
 preload=[]
diff --git a/gui/bidi_and_font_features/noto_font.tres b/gui/bidi_and_font_features/noto_font.tres
index bed946f8..a95e2afb 100644
--- a/gui/bidi_and_font_features/noto_font.tres
+++ b/gui/bidi_and_font_features/noto_font.tres
@@ -1,10 +1,3 @@
-[gd_resource type="FontVariation" load_steps=5 format=3 uid="uid://dewurnqemtrs"]
-
-[ext_resource type="FontFile" uid="uid://dcyy0x2u3jocr" path="res://fonts/NotoSansThaiUI_Regular.ttf" id="1"]
-[ext_resource type="FontFile" uid="uid://61ui1kmi5tt7" path="res://fonts/NotoNaskhArabicUI_Regular.ttf" id="2"]
-[ext_resource type="FontFile" uid="uid://cwer1pi5ka4io" path="res://fonts/NotoSansHebrew_Regular.ttf" id="3"]
-[ext_resource type="FontFile" uid="uid://ba53h385o6ips" path="res://fonts/NotoSansUI_Regular.ttf" id="4"]
+[gd_resource type="FontVariation" format=3 uid="uid://dewurnqemtrs"]
 
 [resource]
-base_font = ExtResource("1")
-fallbacks = [ExtResource("2"), ExtResource("3"), ExtResource("4")]

@Calinou Calinou force-pushed the update-bidi-font-features-demo branch from fa6011c to f5a007f Compare January 23, 2023 10:06
@Calinou Calinou requested a review from bruvzg January 26, 2023 10:06
@Calinou Calinou force-pushed the update-bidi-font-features-demo branch from f5a007f to 62fcf88 Compare February 8, 2023 15:26
@Calinou
Copy link
Member Author

Calinou commented Feb 8, 2023

Rebased and tested on 4.0.rc1. Fixed the font display in the Tree and associated LineEdits on the second tab.

@Calinou Calinou changed the title Update Bidi and Font Features demo for 4.0.beta13 Update Bidi and Font Features demo for 4.0.rc1 Feb 8, 2023
@Calinou Calinou changed the title Update Bidi and Font Features demo for 4.0.rc1 Update Bidi and Font Features demo for 4.0.rc4 Feb 24, 2023
@Calinou Calinou force-pushed the update-bidi-font-features-demo branch from 62fcf88 to 7b96d7a Compare February 24, 2023 16:51
- Enable low processor mode and multiple resolution-friendly
  project settings for consistency with other demos.
- Use Compatibility rendering method for better performance
  and compatibility.
- Prevent screenshots from being imported as resources.
@Calinou Calinou force-pushed the update-bidi-font-features-demo branch from 7b96d7a to c2626a5 Compare February 24, 2023 16:53
@Calinou Calinou merged commit fa3c247 into godotengine:4.0-dev Feb 24, 2023
@Calinou Calinou deleted the update-bidi-font-features-demo branch February 24, 2023 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants