mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-05-05 16:44:50 -04:00
Change font size
This commit is contained in:
parent
6d3ba287dd
commit
1897c62eb4
3 changed files with 33 additions and 3 deletions
|
@ -422,11 +422,18 @@ left_text_tool={
|
|||
right_text_tool={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":true,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
cut={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
enter={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[locale]
|
||||
|
||||
|
|
|
@ -3,10 +3,19 @@ extends "res://src/Tools/Base.gd"
|
|||
|
||||
var text_edit : TextEdit
|
||||
var text_edit_pos := Vector2.ZERO
|
||||
var text_size := 16
|
||||
|
||||
onready var font_data : DynamicFontData = preload("res://assets/fonts/Roboto-Regular.ttf")
|
||||
onready var font := DynamicFont.new()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
font.font_data = font_data
|
||||
font.size = text_size
|
||||
|
||||
|
||||
func _input(event : InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
if event.is_action_pressed("enter"):
|
||||
text_to_pixels()
|
||||
|
||||
|
||||
|
@ -53,7 +62,7 @@ func text_to_pixels() -> void:
|
|||
var texture = ImageTexture.new()
|
||||
texture.create_from_image(current_cel)
|
||||
VisualServer.canvas_item_add_texture_rect(ci_rid, Rect2(Vector2(0, 0), size), texture)
|
||||
var font : Font = load("res://assets/fonts/Roboto-Regular.tres")
|
||||
|
||||
font.draw(ci_rid, text_edit_pos, text_edit.text, tool_slot.color)
|
||||
|
||||
VisualServer.viewport_set_update_mode(vp, VisualServer.VIEWPORT_UPDATE_ONCE)
|
||||
|
@ -74,3 +83,8 @@ func text_to_pixels() -> void:
|
|||
|
||||
text_edit.queue_free()
|
||||
text_edit = null
|
||||
|
||||
|
||||
func _on_TextSizeSpinBox_value_changed(value : int) -> void:
|
||||
text_size = value
|
||||
font.size = text_size
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://src/Tools/Text.gd" type="Script" id=2]
|
||||
|
||||
|
||||
[node name="ToolOptions" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
|
@ -19,3 +18,13 @@ margin_bottom = 30.0
|
|||
visible = false
|
||||
margin_top = 18.0
|
||||
margin_bottom = 35.0
|
||||
|
||||
[node name="TextSizeSpinBox" type="SpinBox" parent="." index="4"]
|
||||
margin_top = 18.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 42.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = 1.0
|
||||
max_value = 128.0
|
||||
value = 16.0
|
||||
[connection signal="value_changed" from="TextSizeSpinBox" to="." method="_on_TextSizeSpinBox_value_changed"]
|
||||
|
|
Loading…
Add table
Reference in a new issue