Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tool
- extends Label # on preview label
- export var texture:Texture # contains
- export var font:BitmapFont # saves into it if not new
- export var glyphSize: = Vector2(16,16)
- export var symbolsInTexture: = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890?!;:- '
- export (bool) var cut:bool = false setget set_cut
- func set_cut(value:bool)->void:
- if !value:
- return
- update()
- func update()->void:
- font.clear()
- var size:Vector2 = texture.get_size()
- font.add_texture(texture)
- font.height = glyphSize.y
- var width:int = size.x / glyphSize.x
- var x = 0
- var y = 0
- var rect = Rect2(Vector2(0.0,0.0), glyphSize)
- for i in symbol_string.length():
- var c = symbol_string[i]
- x = i % width
- y = i / width
- rect.position = glyphSize * Vector2(x,y)
- print(c.to_utf8()[0])
- font.add_char(c.to_utf8()[0], 0, rect)
- font.update_changes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement