PHP -> ImageMagick -> Pango with custom font

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
rlindner
Posts: 1
Joined: 2020-02-21T14:50:21-07:00
Authentication code: 1152

PHP -> ImageMagick -> Pango with custom font

Post by rlindner »

I'm trying to use a custom font in PHP with Imagick via Pango and I'm unsure how to specify the location of the font file. Can anyone help with a few example lines of PHP code showing how to render "Test String" using myfont.otf without the need for myfont.otf to be registered as a system font?

Thanks in advance!

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP -> ImageMagick -> Pango with custom font

Post by fmw42 »

I do not believe you can specify custom fonts. See https://imagemagick.org/Usage/text/#pango
Fonts
Pango can change fonts in the middle of rendering. It already does so easily for bold and italic text. However the font specification is from GTK, and as such uses a different system to ImageMagick in general.
You can find out more about fonts using GTK, by running the "gtk-demo" program, and double clicking "Pickers" and the "Text Widget".

Locked