Page 1 of 1

replace -pointsize with actual font size

Posted: 2011-05-13T10:58:58-07:00
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?

Re: replace -pointsize with actual font size

Posted: 2011-05-13T11:19:32-07:00
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.

Re: replace -pointsize with actual font size

Posted: 2011-05-13T11:40:42-07:00
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.
:/

Re: replace -pointsize with actual font size

Posted: 2011-05-13T12:21:08-07:00
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 .

Re: replace -pointsize with actual font size

Posted: 2011-05-13T12:30:10-07:00
by galv
You can substitute "OpenOffice Writer" with "any text editor with font choosing capabilities" (like Wordpad, Word etc).

Re: replace -pointsize with actual font size

Posted: 2011-05-13T12:40:36-07:00
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.

Re: replace -pointsize with actual font size

Posted: 2011-05-15T05:20:22-07:00
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.

Re: replace -pointsize with actual font size

Posted: 2011-05-15T05:22:36-07:00
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.

Re: replace -pointsize with actual font size

Posted: 2011-05-19T11:18:45-07:00
by galv
Thanks, the replies helped a lot.

Is there a way to force imagemagick to use fontconfig for the rendering of the fonts?

Re: replace -pointsize with actual font size

Posted: 2011-05-19T12:47:47-07:00
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.

Re: replace -pointsize with actual font size

Posted: 2011-05-19T16:50:35-07:00
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)