replace -pointsize with actual font size

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?".
Post Reply
galv
Posts: 62
Joined: 2010-05-23T17:35:59-07:00
Authentication code: 8675308

replace -pointsize with actual font size

Post by galv »

Code: Select all

convert -size 200x50 xc:transparent -font /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf -fill black -pointsize 10 -draw "text 0,10 'hello there" -trim +repage test.png
I am using that to create a transparent image out of a string given. The problem is that i don't want -pointsize, I want 10pts of the font (like in libreoffice/word that you select "Arial" and size "10 pts").
How can I do that?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: replace -pointsize with actual font size

Post by fmw42 »

I am no expert on this, but it seems to me that -pointsize 10 -font Arial is selecting the 10pt Arial font, if that font supports that pointsize. But I will defer to the IM developers. Perhaps I misunderstand you question.
galv
Posts: 62
Joined: 2010-05-23T17:35:59-07:00
Authentication code: 8675308

Re: replace -pointsize with actual font size

Post by galv »

Also how can I identify which file is exporting which font name? For example, I have the "Sans" font in my fonts list in OpenOffice Writer but I don't have a Sans.ttf in my system.

Hm, I tried in Gimp as well, if I select 10pt, it will create an image of the same size as the one that convert makes. But when I try the same font in OpenOffice Writer ("DejaVu Sans") with 10pt again, it has a different size.
:/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: replace -pointsize with actual font size

Post by fmw42 »

fonts can be different even with the same name (for example they might be drawn differently or just missing certain sizes). you would have to export the same font file to each system. I have no experience with OpenOffice Writer .
galv
Posts: 62
Joined: 2010-05-23T17:35:59-07:00
Authentication code: 8675308

Re: replace -pointsize with actual font size

Post by galv »

You can substitute "OpenOffice Writer" with "any text editor with font choosing capabilities" (like Wordpad, Word etc).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: replace -pointsize with actual font size

Post by fmw42 »

I don't think you can make a fair comparison between printed text and an image of text (or display). They use different font rending engines, antialiasing or different types of fonts as I understand it.

Anthony can give you a better explanation. So wait for him to see this and answer.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: replace -pointsize with actual font size

Post by anthony »

fmw42 wrote:I am no expert on this, but it seems to me that -pointsize 10 -font Arial is selecting the 10pt Arial font, if that font supports that pointsize. But I will defer to the IM developers. Perhaps I misunderstand you question.
That is exactly right, however it also depends on the 'density' or 'resolution' of the image. Default is 72 dpi.
making 72 points = 1 inch.

ImageMagick is a Batch processor, It does not directly associate with a specific device such as a display (typically 90 to 120 dpi) or a printer (300, 600, or in extreme cases 900 dpi). You will need to tell ImageMagick what resolution you are 'playing' with using -density.

ADDENDUM: The standard default when no device is associated is 72 dpi (coming from old physical printing, the original postscript definition, and the very ancient CRT monitors and line printers.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: replace -pointsize with actual font size

Post by anthony »

galv wrote:Also how can I identify which file is exporting which font name? For example, I have the "Sans" font in my fonts list in OpenOffice Writer but I don't have a Sans.ttf in my system.

Hm, I tried in Gimp as well, if I select 10pt, it will create an image of the same size as the one that convert makes. But when I try the same font in OpenOffice Writer ("DejaVu Sans") with 10pt again, it has a different size.
:/
The meaning of "Sans" will depend on your font setup in your window/display manager setup. Typically Gome or KDE. I have no idea what font it refers too as it seems to change every so often with new releases, or at least it did.

Again it is a matter of resolution. Gimp probably uses the same 'universal' default of 72 dpi. Open Office being a general document GUI probably looks up the resolution form the current display. That resolution is not always correct, but you can look it up yourself by using the command "xdpyinfo". You can then measure your display and combine it with the number of pixels to get the 'real' resolution of your display. There are ways of setting this, but again it varies from X window implementation to implementation.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
galv
Posts: 62
Joined: 2010-05-23T17:35:59-07:00
Authentication code: 8675308

Re: replace -pointsize with actual font size

Post by galv »

Thanks, the replies helped a lot.

Is there a way to force imagemagick to use fontconfig for the rendering of the fonts?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: replace -pointsize with actual font size

Post by fmw42 »

it is my understanding that if you install fontconfig and IM recognizes it, then IM will use that for font rending. however, I am not an expert on this. So perhaps wait for Anthony to reply

convert -list configure

the line starting with DELEGATES should show fontconfig. If so then IM knows and should be using it.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: replace -pointsize with actual font size

Post by anthony »

Sorry Fred, in this case I am not certain. The font internals are all very much a misery to me.

I would like to more more about this for my own edification, and possibly let me use X window BDF and PCF bitmap (fixed resolution) fonts, especially for small scale text in GIF and icon images (eg generate file thumbnails on the gnone file manager - nautilus). But I am not interested enough to go code diving for it.

Magick is the one to ask about font rendering and its delegation.

These days it seems that a TTF font has been created by someone for all situations, including very 'tiny text' fonts for specific small pointsizes (5,6,7 pt at 72dpi)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply