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

Better options for TrueType Fonts. #75

Open
jsbeckr opened this issue May 13, 2019 · 3 comments
Open

Better options for TrueType Fonts. #75

jsbeckr opened this issue May 13, 2019 · 3 comments
Assignees

Comments

@jsbeckr
Copy link

jsbeckr commented May 13, 2019

Hey! :)

I was playing around with TrueType fonts (OpenSans, Courier New, Fira Code) on MacOS. And it seems that the font is rendered to small in comparison to the tile size.

image

tcod.tileset.set_truetype_font("data/OpenSans-Regular.ttf", 24, 24)

Is it possible to control the size of the font inside a tile?

There is also an issue with Fira Code (it doesn't render correctly). But I think that might be the custom glyphs they included in the font?

@HexDecimal HexDecimal self-assigned this May 13, 2019
@HexDecimal
Copy link
Collaborator

As far I've gotten the best option is to exclude the width (use a width of 0) of the font, then the font loader will automatically pick the width with the best fit. If you pick both a width and height then the font will be scaled down to fit without stretching it. The best results will come from fonts designed to be used as monospace fonts.

There's no options for fine tuning the font size, but now is a good time to make suggestions.

@jsbeckr
Copy link
Author

jsbeckr commented May 14, 2019

I guess if I could wish for an API I would like the following:

tcod.tileset.set_truetype_font("data/OpenSans-Regular.ttf", 24, 24, font_size=16, antialiasing=True)

It would be cool to set an anchor point for the tiles where the bounding box of the font sits. Something like upper_left, bottom_right, etc. Which could enable nice effects like distinguishing small and big items for example?

@HexDecimal HexDecimal changed the title How to use TrueType Fonts correctly? Better options for TrueType Fonts. May 25, 2019
@HexDecimal
Copy link
Collaborator

HexDecimal commented Apr 6, 2021

A new example using FreeType to generate a tileset can be found here.

This example builds the font from Python so it's easier to modify. It's recommended to use ttf.py if the tileset generated by tcod.tileset.set_truetype_font is too small or narrow.

tcod.tileset.set_truetype_font

tcod.tileset.set_truetype_font

ttf.py / FreeType screenshot

ttf.py screenshot

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

No branches or pull requests

2 participants