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

Tab character is displayed #6276

Open
1 of 6 tasks
imcasper opened this issue Nov 19, 2020 · 1 comment
Open
1 of 6 tasks

Tab character is displayed #6276

imcasper opened this issue Nov 19, 2020 · 1 comment
Labels
core affecting all platforms fonts

Comments

@imcasper
Copy link

Issue details

I am creating text that contains a tab character (\u0009).
Text used in: Label.

I see good work with space characters, newline characters, etc.
But instead of a tab character, I see a rectangle (an "unknown character" marker).
I want to see only empty space.

Reproduction steps/code

I use Verdana.ttf. And roughly the following code:

	val parameters = FreeTypeFontGenerator.FreeTypeFontParameter()
	parameters.size = 16
	parameters.characters = ... + "\t" // I try manually add tab and try no add
	FreeTypeFontGenerator(Gdx.files.internal("Verdana.ttf")).generateFont(parameters)

Version of LibGDX and/or relevant dependencies

gdxVersion: '1.9.11'

Please select the affected platforms

  • Android
  • iOS
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

PS

As far as I suspect, the tab character has a non-zero height in the font (as opposed to the space character). Probably the problem is related to this. It probably makes sense to handle special characters in a special way. Probably in some fonts they may be drawn differently, or ignored.

platofrm: java (desktop app on linux)

@MrStahlfelge MrStahlfelge added core affecting all platforms fonts labels Nov 19, 2020
@tommyettinger
Copy link
Member

So... the tab character is definitely a "special" character. Probably the most helpful suggestion I can give is to replace any tabs in your Label text with the desired amount of spaces (maybe 2, 4, or 8), and hope you don't need tab stops. The problem, I think, is that tab is a control character that renders differently depending on context; text editors allow setting tab width, and word processors allow specifying tab stops. I don't think libGDX has any way of specifying either tab width or tab stops, so tab just becomes an unknown or unknowable character when rendered. This might be a limitation of FreeType or of the libGDX BitmapFont/Label code, I don't really know. The good news is that if your tabs are all in a file of the game's text (such as an I18N bundle), it should be a quick step to replace \t (the tab character itself) or \\t (an escaped tab) with, say, (four spaces). It is far from ideal, but it should look better than the unknown character glyph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core affecting all platforms fonts
Projects
None yet
Development

No branches or pull requests

3 participants