bidi.gd 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. extends Control
  2. @onready var variable_font_variation: FontVariation = $"TabContainer/Variable fonts/VariableFontPreview".get_theme_font("font")
  3. func _ready() -> void:
  4. var tree: Tree = $"TabContainer/Text direction/Tree"
  5. var root := tree.create_item()
  6. tree.set_hide_root(true)
  7. var first := tree.create_item(root)
  8. first.set_text(0, "רֵאשִׁית")
  9. var second := tree.create_item(first)
  10. second.set_text(0, "שֵׁנִי")
  11. var third := tree.create_item(second)
  12. third.set_text(0, "שְׁלִישִׁי")
  13. var fourth := tree.create_item(third)
  14. fourth.set_text(0, "fourth")
  15. func _on_Tree_item_selected() -> void:
  16. var tree: Tree = $"TabContainer/Text direction/Tree"
  17. var path := ""
  18. var item := tree.get_selected()
  19. while item != null:
  20. path = item.get_text(0) + "/" + path
  21. item = item.get_parent()
  22. $"TabContainer/Text direction/LineEditST".text = path
  23. $"TabContainer/Text direction/LineEditNoST".text = path
  24. func _on_LineEditCustomSTDst_text_changed(new_text: String) -> void:
  25. $"TabContainer/Text direction/LineEditCustomSTSource".text = new_text
  26. func _on_LineEditCustomSTSource_text_changed(new_text: String) -> void:
  27. $"TabContainer/Text direction/LineEditCustomSTDst".text = new_text
  28. func _on_LineEditCustomSTDst_tree_entered() -> void:
  29. # Refresh text to apply custom script once it's loaded.
  30. $"TabContainer/Text direction/LineEditCustomSTDst".text = $"TabContainer/Text direction/LineEditCustomSTSource".text
  31. func _on_variable_size_value_changed(value: float) -> void:
  32. $"TabContainer/Variable fonts/Variables/Size/Value".text = str(value)
  33. # This is also available on non-variable fonts.
  34. $"TabContainer/Variable fonts/VariableFontPreview".add_theme_font_size_override("font_size", value)
  35. func _on_variable_weight_value_changed(value: float) -> void:
  36. $"TabContainer/Variable fonts/Variables/Weight/Value".text = str(value)
  37. # Workaround to make the variable font axis value effective. This requires duplicating the dictionary.
  38. var dict = variable_font_variation.variation_opentype.duplicate()
  39. dict["weight"] = value
  40. variable_font_variation.variation_opentype = dict
  41. func _on_variable_slant_value_changed(value: float) -> void:
  42. $"TabContainer/Variable fonts/Variables/Slant/Value".text = str(value)
  43. # Workaround to make the variable font axis value effective. This requires duplicating the dictionary.
  44. var dict = variable_font_variation.variation_opentype.duplicate()
  45. dict["slant"] = value
  46. variable_font_variation.variation_opentype = dict
  47. func _on_variable_cursive_toggled(button_pressed: bool) -> void:
  48. $"TabContainer/Variable fonts/Variables/Cursive".button_pressed = button_pressed
  49. # Workaround to make the variable font axis value effective. This requires duplicating the dictionary.
  50. var dict = variable_font_variation.variation_opentype.duplicate()
  51. dict["custom_CRSV"] = int(button_pressed)
  52. variable_font_variation.variation_opentype = dict
  53. func _on_variable_casual_toggled(button_pressed: bool) -> void:
  54. $"TabContainer/Variable fonts/Variables/Casual".button_pressed = button_pressed
  55. # Workaround to make the variable font axis value effective. This requires duplicating the dictionary.
  56. var dict = variable_font_variation.variation_opentype.duplicate()
  57. dict["custom_CASL"] = int(button_pressed)
  58. variable_font_variation.variation_opentype = dict
  59. func _on_variable_monospace_toggled(button_pressed: bool) -> void:
  60. $"TabContainer/Variable fonts/Variables/Monospace".button_pressed = button_pressed
  61. # Workaround to make the variable font axis value effective. This requires duplicating the dictionary.
  62. var dict = variable_font_variation.variation_opentype.duplicate()
  63. dict["custom_MONO"] = int(button_pressed)
  64. variable_font_variation.variation_opentype = dict
  65. func _on_system_font_value_text_changed(new_text: String) -> void:
  66. for label in [
  67. $"TabContainer/System fonts/VBoxContainer/SansSerif/Value",
  68. $"TabContainer/System fonts/VBoxContainer/Serif/Value",
  69. $"TabContainer/System fonts/VBoxContainer/Monospace/Value",
  70. $"TabContainer/System fonts/VBoxContainer/Cursive/Value",
  71. $"TabContainer/System fonts/VBoxContainer/Fantasy/Value",
  72. $"TabContainer/System fonts/VBoxContainer/Custom/Value"
  73. ]:
  74. label.text = new_text
  75. func _on_system_font_weight_value_changed(value: float) -> void:
  76. $"TabContainer/System fonts/Weight/Value".text = str(value)
  77. for label in [
  78. $"TabContainer/System fonts/VBoxContainer/SansSerif/Value",
  79. $"TabContainer/System fonts/VBoxContainer/Serif/Value",
  80. $"TabContainer/System fonts/VBoxContainer/Monospace/Value",
  81. $"TabContainer/System fonts/VBoxContainer/Cursive/Value",
  82. $"TabContainer/System fonts/VBoxContainer/Fantasy/Value",
  83. $"TabContainer/System fonts/VBoxContainer/Custom/Value"
  84. ]:
  85. var system_font: SystemFont = label.get_theme_font("font")
  86. system_font.font_weight = value
  87. func _on_system_font_italic_toggled(button_pressed: bool) -> void:
  88. for label in [
  89. $"TabContainer/System fonts/VBoxContainer/SansSerif/Value",
  90. $"TabContainer/System fonts/VBoxContainer/Serif/Value",
  91. $"TabContainer/System fonts/VBoxContainer/Monospace/Value",
  92. $"TabContainer/System fonts/VBoxContainer/Cursive/Value",
  93. $"TabContainer/System fonts/VBoxContainer/Fantasy/Value",
  94. $"TabContainer/System fonts/VBoxContainer/Custom/Value"
  95. ]:
  96. var system_font: SystemFont = label.get_theme_font("font")
  97. system_font.font_italic = button_pressed
  98. func _on_system_font_name_text_changed(new_text: String) -> void:
  99. var system_font: SystemFont = $"TabContainer/System fonts/VBoxContainer/Custom/FontName".get_theme_font("font")
  100. system_font.font_names[0] = new_text