Using Custom Font in "text"

Looking at the manual, there seems to be an option to use custom fonts in the textcommand. Would anyone point me to an example, please. Thank you.

Hmm, thanks, @Claes. And… I still don’t fully understand how I would create that font image with 256/512 characters when I have a font file, such as a .ttf.

That’s well above my pay grade…Ping @David_Tschumperle

Naaaaa/No. @David_Tschumperle needs a break. He has answered too many posts of mine recently.

Well this one will be easy : there is absolutely no support for drawing ttf fonts in G’MIC.
The text command is limited to displaying simple text (no UTF8 either), with a default font.
It’s somehow possible to use a custom font, but only defined as a list of images, not in a vectorized form.

1 Like

Thanks for the clarification, @David_Tschumperle.

There might be a solution to convert your ttf to png using imagemagick or Python here :

1 Like

That’s interesting, because we could theoretically generates the set of characters recognized by G’MIC (command fontchart) from any ttf font file.
I’ll investigate this, because that would mean having a way to support somehow different fonts in G’MIC.


And that would open a lot of possibilities too :slight_smile:
A lot of people like to play with text.
I’d love to use G’mic to generate low res fonts like in the old days of MSX or SNES, etc. from a “modern” ttf.

1 Like

That would be great. I have completed, based on your input, a command to produce a photo book that you can then directly upload to printing services, such as Blurb. The only thing missing - besides combining the individual .pdf pages to a single .pdf - is the first page, which I would like to put a title on with a “good looking” font. So, such a solution would be great. And I could imagine that - for the beginning - a standalone program to generate these images would probably already do if they can be then used by fontchart.

Also, let’s not forget that there is the “otf” font format.

`ìmagemagick``would probably be able to create the fonts along the lines (but just along the lines)

convert -font "AlBayan.ttc" -pointsize 12  -background transparent -fill black label:"b" canvas.png

What do you mean? it generates a single image with all the letters in a line?
If that’s the case, a monospace font could be split x,$N ($N being the number of letters) to isolate characters (i think, me no be “expeurte”).

There may be some errors though :

EDIT : autocrop_components , does a good job but the characters are not sorted alphabetically…
And also, this :

What are you doing Tony?

I don’t know if I’m out of topic about custom font, but on gimpchat there a member @Skinnyhouse which did develop python script for GIMP to make each letter of any font to layer (png) > Custom Font Tools Release 16 for Gimp 2.10 • GIMP Chat

If you download its R16.7z on gimpchat look for that script called

Script in GIMP when called:


Result > All the alphabet, numbers special characters like :,;[{(*&^%$#@! etc… are on a layer in just one click

I’m actually working on a way to convert a font into a G’MIC-compliant format.
My script generates a HTML page with all the letters, that is rendered into a buffer, using cutycapt, so everything can be done in a simple script.

I’ll let you know when it is usable in G’MIC.


OK, so I think I’m no that far to get something “usable” (not perfect though).
I’ve added a command font2gmz that basically tries to convert a .ttf file into a G’MIC list of rasterized characters, that you can save as a .gmz file and use in command text as a custom font.

It can be used for instance like this:

foo :
  # The two first lines do the conversion "inline" here, but it's better to store the fonts as a .gmz files.
  l[] { font2gmz PlayfairDisplay-ExtraBold.ttf,48 store font_playfair }
  l[] { font2gmz Sofia,48 store font_sofia }

  sp colorful / 2
  text. "Hello my friends! (PlayFair)",0.5~,0.25~,font_playfair,1,255
  text. "Hello my friends! (Sofia)",0.5~,0.5~,font_sofia,1,255
  text. "Hello my friends! (G'MIC default)",0.5~,0.75~,64,1,255

This renders something like this:

It’s not perfect though:

  • There are still some glitches remaining during the font conversion (see the botton of the left parenthesis for the Sofia font). That could be fixed in the future, hopefully.
  • The font conversion takes time (a few seconds), and works only if you have the cutycapt tool installed. Can be done only once though, then the corresponding font.gmz file can be used, so not a big deal I think.
  • The text command renders text with its own (very basic) algorithm, so spacing between characters can be ugly some time. For this, don’t expect so much improvements in the future. Correct text rendering with custom fonts is quite a hard task, and I won’t re-implement something that would be worse than existing specialized libraries. And at the same time, I have no time to write code to use those libraries.

Yes, this means a lot of constraints for the moment. But eh, it’s better than nothing :slight_smile:


Suggestion, maybe a new GUI item specifically for returning all available system font, and return names? I know that goes to c-koi though.

Perfect, @David_Tschumperle. Please, let uns know how we can help and test…

Looking at it… it might even be pretty simple to break text across lines as we know the width of each character (as long as we do not change fonts in the middle of the line - then it becomes a bit more complicated. However, being able to put it on ONE line, centered, would already make me very happy.