I have the impression that there are a lot of expectations concerning this feature
(take it easy, please!).
Some news:
-
I’ve polished my scripts to convert the fonts, so it should work OK now (so far, so good).
-
I have set a first collection of G’MIC default fonts, that is stored as a .gmz
file that is stored on the G’MIC server (currently 8MB). It contains the default fonts that G’MIC can use to draw text on images. Data file: https://gmic.eu/gmic_fonts.gmz
The new commands that are important to know are (after a $ gmic update
):
Command font
:
font "Font Name",height
generates a font with given name and requested height, and put it in cache (as a global variable). This command returns an identifier that can be used afterwards in commands text
and text_outline
to draw text on image with specified font. Like in the example below:
foo :
sp colorful / 2
# Example 1: Direct integration of 'font' in the call to the 'text_outline' (aka 'to') command:
to "Acme:\n Hello World!",0.5~,0.2~,${"font Acme,100"},2,1,64,128,255
# Example 2 : Make it in two steps.
medieval_sharp=${"font MedievalSharp,100"} # 'medieval_sharp' can be re-used several times.
to "Medieval Sharp:\n Hello World!",0.5~,0.6~,$medieval_sharp,2,1,255,255,128
# Example 3: When an invalid font name is requested, fallback to default G'MIC font.
donotexist=${"font DoNotExist,32"} # Obviously an invalid font name
to "When specifying unknown font!",0.5~,0.8~,$donotexist,2,1,255,128,255
which renders this:
This command does not render a font from a .ttf
or .otf
file. It just gets the font from the G’MIC font collection. So for now, the font name can be only one amongst { Acme | Arial | Arial Black | Cabin Sketch | Cheque | Comic Sans MS | Courier New | Georgia | Halloween | Impact | Lato | Lucida Console | Lucida Sans | MedievalSharp | Montserrat | MS Sans Serif | Oswald | Palatino Linotype | Roboto | Sofia | Tahoma | Times New Roman | Trebuchet | Verdana }.
Command font2gmz
:
Now, if you need to draw your own custom font, you’ll have to convert it as a .gmz
file before it can be used in the text
or text_outline
commands. This is what command font2gmz
is intended for.
Rendering a font can take time, especially when the font size is large. So once you’ve converted a font, you should always save it as a .gmz
file.
Step 1: Convert your font file as a .gmz
file. This rasterizes the font, so please keep in mind that the size will be unique.
$ gmic font2gmz JosefinSans-Regular.ttf,80 o JosefinSans.gmz
Step 2: Import that font in a script and use it to draw text on an image:
foo :
sp colorful / 2
l[] { JosefinSans.gmz store __josefin_sans } # Import font
to "Hello World!",0.5~,0.5~,__josefin_sans,2,1,255,0,255
which renders this:
Note that command font2gmz
requires cutycapt
to be installed for doing the font snapshot.
I’ll still have a few work to do concerning the normalization of anti-aliasing effects for fonts of different sizes.
I’m not sure I’d go much further than that!