-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
draw_string() only renders blocks and throw thousands of errors #15023
Comments
var font = DynamicFont.new()
func _ready():
var data = DynamicFontData.new()
data.font_path = "res://freepixel.ttf"
font.font_data = data
font.size = 17
func _draw():
draw_string(font, Vector2(5, font.get_height()+5), get_name(), Color("000000"))
draw_string(font, Vector2(4, font.get_height()+4), get_name(), Color("FFFFFF")) this will fix your problem. |
I'm not sure if it's a bug. |
I see, thanks! Strange limitation but it'll have its reasons, anyone know if it's mentioned in any docs? |
well, this could technically be fixed by forcing to update cache if a char is requested, but usage is definitely not optimal at all.. |
no, nevermind, this is not a bug. you are deleting the font after using it, this is why you see those white recangles. |
That makes a lot more sense than an arbitrary restriction on resource creation during draw. |
Well, I think this could at least get a more meaningful error message. I had no idea what it means when I got it. |
I get these errors when I put Label (2D) under Viewport (in 3D scene as TextureViewport in Sprite3D). The strange thing is font is working (from Project Settings theme)... until window is resized, maximized or switched to fullscreen. After that font in Labels is forgotten? And drawn strangely, filled rectangles or some font fragments, and debugger is full of these errors. Thanks to @reduz I just put my default theme/font into Labels under Viewport and everything is working without errors even after resizing the window. Godot 3.5.stable on Linux |
This is likely a bug caused by font oversampling, which you can disable in the Project Settings as a workaround. |
Exactly, every time the engine dosen't produce a meaningful feedback, it's by definition is a bug. It's a null reference exception stemming from the source of the engine, that doesn't indicate doesn't point towards the actual root of the problem... |
Godot version:
Godot 3 e1da261
OS/device including version:
Ubuntu 16.04, Radeon HD 6450
Issue description:
When using draw_string() within _draw(), Godot draws rectangles the width and height of the letters it should be drawing instead of the actual letters. for both Dynamic and Bitmap fonts.
They always display fine inside a Label. BitmapFont seems to render fine in-game, but retains the block issue when used in-editor in a tool script, while DynamicFont has the same issue in-game.
While it draws the rectangles, it outputs thousands of copies of this error to the error log:
This is how a drawn string looks:
Steps to reproduce:
Try using draw_string() in any CanvasItem's _draw() method. Reproduction project is attached.
Example code:
Minimal reproduction project:
MinimalTTF.zip
The text was updated successfully, but these errors were encountered: