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

Inconsistent behavior of Font.get_char_size for different TextServer #56348

Closed
dalexeev opened this issue Dec 30, 2021 · 2 comments · Fixed by #56649
Closed

Inconsistent behavior of Font.get_char_size for different TextServer #56348

dalexeev opened this issue Dec 30, 2021 · 2 comments · Fixed by #56649
Assignees
Milestone

Comments

@dalexeev
Copy link
Member

dalexeev commented Dec 30, 2021

Godot version

v4.0.dev.custom_build [340883636]

System information

Kubuntu 21.10

Issue description

Font.get_char_size returns different results for TextServerAdvanced and TextServerFallback (internationalization/rendering/text_driver setting).

TextServerAdvanced:

(0, 7) # Wrong width
(4.15625, 23)

TextServerFallback:

(6, 7)
(4.15625, 23)

Note that the result is different for the attached font, but not for the standard font. My font is generated by my script, which is written similar to the Image Font importer. But a different result for different TextServer is still a bug in this case.

Steps to reproduce

See the issue description and MRP.

Minimal reproduction project

get_char_size.zip

@dalexeev
Copy link
Member Author

dalexeev commented Dec 30, 2021

Related (internationalization/rendering/text_driver = Fallback)?

Peek.2021-12-30.21-02.mp4

@bruvzg
Copy link
Member

bruvzg commented Jan 7, 2022

Font.get_char_size returns different results for TextServerAdvanced

Missing return value for the bitmap font in the font_get_glyph_index.

@@ -2573,7 +2573,7 @@ int32_t TextServerAdvanced::font_get_glyph_index(RID p_font_rid, int p_size, cha
 			return FT_Get_Char_Index(fd->cache[size]->face, p_char);
 		}
 	} else {
-		return 0;
+		return (int32_t)p_char;
 	}
 #else
 	return (int32_t)p_char;

Related (internationalization/rendering/text_driver = Fallback)?

Probably unrelated, seems like a rounding error in the Fallback text server or TextEdit. I'll take a look at it on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants