Using Custom Font in "text"

Good morning! I have installed g’mic from the development branch and played a bit with the fonts. The functionality implemented by @David_Tschumperle is great, so thank you.

As I want to use this for generating a book cover, I have tried it on a larger image and what you see is quite some pixelation (text "Acme:\n Hello World!",0.5~,0.2~,${"font Acme,500"},2,1,64,128,255).

If I understand @David_Tschumperle, the font is generated by grabbing the pixels from the screen and turning them into individual images. Can you share some more insights how the .gmz for a font must look like, so perhaps I can also spend some time trying to find another - non-screen-grab - way of generating them.

No surprise for me.
The default fonts in G’MIC are rendered with heights 24,32,64 and 128.
If you specify a font height larger than 128, then the font is interpolated and interpolation artefacts appear.

Two solutions that can be imagined at this point:

1 - Rip your own font with font2gmz , and specify a large height (500 in your case).

2 - Or, hope that someone smart enough in this forum designs a pretty cool font upscaling algorithm that could be integrated in command font (that could be an interesting challenge BTW).

Last posted posted itself somehow too early.

@David_Tschumperle can you share how the font file for the individual characters has to look like, please. Something like https://github.com/sl2/TTF-to-PNG might be a good starting point to create the font images directly. I probably have some time to give it a try.

Or, when looking at the Python script above, perhaps even simpler… convert -font Caprasimo-Regular.ttf -pointsize 500 -background "rgba(0,0,0,0)" "label:A" A.png as ImageMagick is probably available on many operating systems

I’ve tried something simple for doing this, but this seems to work reasonnably well.
Maybe you can try to update your stdlib ($ gmic update) and see if that works for you.

Yes, @David_Tschumperle, that looks much better! Thanks a lot.

Can you still share how a generated font file should look like?

Moinchen, Helmut!

Perhaps you may find something of interest in this old post: GEGL Gold Text Plugin • GIMP Chat

And perhaps this: Gimp - Bevel & Emboss Schrift | rgb-labs.com

MfG
Claes in Lund, Schweden

Here is my selection for the default G’MIC font.
There are 32 fonts, with different styles:

Still work to do on command font and other stuffs.
I’m not gonna experiment much more on this, as I have a lot of work to do at the lab!

EDIT: Filter “Visible Watermark” has been updated:

2 Likes

I was already wondering where you take the time to work on this. Thanks again for all your time and effort, @David_Tschumperle

1 Like

To add: A not very good-looking solution that uses ImageMagick:

exec 1,"convert -background transparent -fill blue -font Caprasimo-Regular.ttf  -pointsize 300 'label:Sample Text' _image.png"
i _image.png 
imagealpha[0] [1],0.5~,0.5~ keep[0]

Did not manage to turn the `exec``command into a pipe… and have to learn how to use parameters with a command.

Am I the only one with difficulty getting colors correct?

$ sp cat text[-1] HELLO,.5~,.5~,${\"font Acme,200\"},1,50,60,8

Looks like a bug indeed.

Height doesn’t correspond to pixel height. That’s another issue, but I didn’t want to mention that as you have a lot of work on the lab.

OK, so the bug has been introduced in G’MIC 3.3.1_pre.
It does not happen on current stable version 3.3.0.

The height does correspond to the maximal height of a font character. It is not the height of each character independently (of course, you don’t want a , to have the same height as a A).

1 Like

I’ll build new pre-releases packages with the fix tonight.

Terrible artifact here:

#@cli foo:
foo:
4096,256 
text[-1] HELLO,.5~,.5~,${"font Impact,392"},1,1 

I’m using this for the Revolt Wall Generator. Which means that I have to use this big of a height as the base text should at least be 256 px big.

I’ve tried to make this a bit cleaner in the font command.
But, as I said before, the defauilt fonts in G’MIC are currently stored with a max height of 128px, which means asking for something bigger will create interpolation artefacts, no matter what I do in the font command.

To be more clear: Do not expect something clean unless you convert your own (large) font with command font2gmz.

The font rendering method in G’MIC is quite basic. It’s already quite a miracle I’ve been able to add the possibility to use custom fonts for having a bit of diversity.

For large fonts:

$ gmic font2gmz my_font.ttf,500 o font500.gmz

and then

foo :  
  0 t. "Hello World!",0,0,${"font font500.gmz,500"},1,255

CutyCapt really needs an X server to work if I interpret the manual correctly. Is there any other way of doing it, e.g., with a more off the shelf tool, which is available on more platforms? I am more than happy to look at it if anyone shows me how the the font500.gmz resulting from a TTF looks like.

Can we have something like persistent_font for GUI? Once loaded, it stays in memory for use later instead of loading .gmz all over again.

Ok, I installed cutycapt on Windows, and installed VcXsrv Server which is supposedly a X-Server on Windows. I set cutycapt into path, launched VcXsrv, and used font2gmz command, it does not work.

There is a html file here though on temp.

I can only advocate one more time that I believe we should use common available software to convert the font files, such as TTF, to gmz and not rely on software to do screen scaping. One example being Imagemagick. I am happy to help but need to understand how the gmz file must look like.