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

Generating new fonts #51

Open
ronangaillard opened this issue Sep 23, 2021 · 6 comments
Open

Generating new fonts #51

ronangaillard opened this issue Sep 23, 2021 · 6 comments

Comments

@ronangaillard
Copy link
Contributor

Hi,

Thanks for your helpful project !

How do you generate new fontx fonts in c code to be used with your library ?

Thanks,
Ronan

@tuupola
Copy link
Owner

tuupola commented Sep 23, 2021

I first convert BDF fonts to FONTX and then use xxd to create the header files. I quickly hacked the conversion tools from code I found online and some blogposts. All that code is needs to be cleaned up when I have time.

https://github.com/tuupola/fontx_tools
https://linux.die.net/man/1/xxd

I also converted some public domain fonts to FONTX format using these tools. You could check the Makefile to see all the conversion steps.

https://github.com/tuupola/embedded-fonts/blob/master/Makefile
https://github.com/tuupola/embedded-fonts/tree/master/X11
https://github.com/tuupola/embedded-fonts/tree/master/misc/viznut

@tuupola
Copy link
Owner

tuupola commented Sep 23, 2021

Also I have not tried it myself but @allenck has a FONTX editor for Windows.

https://github.com/allenck/FontXEdit

@ronangaillard
Copy link
Contributor Author

Thanks for your quick and detailed answer ! :)

@ronangaillard
Copy link
Contributor Author

ronangaillard commented Oct 10, 2021

For future reference :

I convert otf fonts to bdf with otf2bdf :

otf2bdf -p 24 -o roboto.bdf RobotoMono-Regular.otf

You can also select a subset using the l option. For instance to select only digits :

otf2bdf -p 24 -l '48_57' -o roboto.bdf RobotoMono-Regular.otf

I then use fontxedit on a Windows XP VM to convert the generated bdf font to a FONTX one.

EDIT : easier solution is to use bdf2fontx to convert bdf to fontx format :

cat roboto.bdf | bdf2fontx > roboto.fnt

I then use bin2header to convert the generated FONTX font to a .h header :

bin2header roboto.fnt

@tuupola
Copy link
Owner

tuupola commented Oct 11, 2021

Thanks! I will try this myself too.

@vbenso
Copy link

vbenso commented Nov 25, 2023

Hello,
I'm having some fun with hagl in the past days.
I've followed the above instructions to generate some fonts, and got some results.
I've noticed some vertical misalignment that is probably coming from bdf2fontx.
image
This doesn't happen when using the 6x9 font that is already in hagl source, only in my generated fonts.
Fonts were generated from RobotoMono-Regular.ttf by the fontx tools from the fix-fonts branch, since I would get a malloc failure when using tools from master.

What am I doing wrong?

Thanks for any help

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

3 participants