label fails with Windows TTC TrueType font collection

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
holistone
Posts: 13
Joined: 2012-06-29T10:56:44-07:00
Authentication code: 13

label fails with Windows TTC TrueType font collection

Post by holistone »

I am using iM 6.7.7-8 on Windows 7 32-bit to create simple labels using various fonts. It seems that if I specify a font that resolves to .ttf glyphs the process works, whereas if the font resolves to a .ttc font collection it fails, even through iM seems to know about the font. A partial listing from convert -list font follows:

Code: Select all

  Font: MoolBoran
    family: MoolBoran
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: c:\windows\fonts\moolbor.ttf
  Font: MS-Gothic-&-MS-PGothic-&-MS-UI-Gothic
    family: MS Gothic & MS PGothic & MS UI Gothic
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: c:\windows\fonts\msgothic.ttc
Given the above:

Code: Select all

convert -background #000 -fill #0F0 -pointsize 64 -font MoolBoran label:hello! test.gif
works fine, while

Code: Select all

convert -background #000 -fill #0F0 -pointsize 64 -font MS-Gothic label:hello! test.gif
fails with the message: convert.exe: unable to read font `MS-Gothic' @ warning/annotate.c/RenderType/871.

Is there something I need to change to enable iM to access the TTC font collection? Is it possible I have not specified the font correctly? Any help would be appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: label fails with Windows TTC TrueType font collection

Post by fmw42 »

I am not an expert on fonts and those acceptable to IM. I know it cannot handle all font types.

see
http://www.imagemagick.org/script/comma ... s.php#font

Perhaps you need to preface your font with

TTC:path2font

as seems to be the case for other fonts.

Other than that, you may need to hear back from the IM developers for further help.
holistone
Posts: 13
Joined: 2012-06-29T10:56:44-07:00
Authentication code: 13

Re: label fails with Windows TTC TrueType font collection

Post by holistone »

The suggestion to use TTC: as a prefix had no effect, but specifying the complete path as

Code: Select all

convert -background #000 -fill #0F0 -pointsize 64 -font c:/windows/fonts/msgothic.ttc label:hello! test.gif
ran without error. The resultant image, however, has widely spaced characters, but that is perhaps a characteristic of the MS Gothic font which was designed for Japanese.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: label fails with Windows TTC TrueType font collection

Post by Bonzo »

I belive later versions of IM can use an external program for text called Pango; have a search for it on the forum.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: label fails with Windows TTC TrueType font collection

Post by fmw42 »

Bonzo wrote:I belive later versions of IM can use an external program for text called Pango; have a search for it on the forum.

see
http://www.imagemagick.org/Usage/text/#pango
holistone
Posts: 13
Joined: 2012-06-29T10:56:44-07:00
Authentication code: 13

Re: label fails with Windows TTC TrueType font collection

Post by holistone »

The link to image text handling was extremely helpful, independent of Pango http://www.imagemagick.org/Usage/text/

Some of those examples use -font mincho whereas I still need to use -font c:/windows/fonts/msmincho.ttc. Is there some setting that I am missing that allows the shorter version of the path specification for TTC font collections?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: label fails with Windows TTC TrueType font collection

Post by fmw42 »

your actual font name is either MS-Gothic-&-MS-PGothic-&-MS-UI-Gothic or msgothic. probably the former. try each of those, however. you have either used the wrong name or put a hyphen in it where it does not belong. Look at your convert -list font listing.
holistone
Posts: 13
Joined: 2012-06-29T10:56:44-07:00
Authentication code: 13

Re: label fails with Windows TTC TrueType font collection

Post by holistone »

Thanks.

-font "MS-Gothic-&-MS-PGothic-&-MS-UI-Gothic" with required quotes does work.
-font msgothic does not.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: label fails with Windows TTC TrueType font collection

Post by fmw42 »

holistone wrote:Thanks.

-font "MS-Gothic-&-MS-PGothic-&-MS-UI-Gothic" with required quotes does work.
-font msgothic does not.

Yes, that is what I expected. But is it shorter typing this way or with the path to your font with a simpler name?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: label fails with Windows TTC TrueType font collection

Post by anthony »

holistone wrote:Some of those examples use -font mincho whereas I still need to use -font c:/windows/fonts/msmincho.ttc. Is there some setting that I am missing that allows the shorter version of the path specification for TTC font collections?
You do not need to specify a path, if IM is configured to know what font files are available and where.
See the top level page of IM examples
http://www.imagemagick.org/Usage/#font

(I really should put this in a sub-page!)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
holistone
Posts: 13
Joined: 2012-06-29T10:56:44-07:00
Authentication code: 13

Re: label fails with Windows TTC TrueType font collection

Post by holistone »

As I stated at the start of the thread, I'm running WIndows 7, not Linux and have not installed Perl. iM already knows about the font and its location since it appears in the output from convert -list fonts as shown above in my first post.

My understanding based on experimentation and the comments here is that, without site specific customization, individual truetype fonts that appear in convert -list fonts output may be specified by -font followed either by:
  • the entire text following Font: enclosed in quotes or
  • by the full path and filename following glyph: on the last line of the font listing
For an individual truetype font .ttf the first option is clearly the most succinct. On the other hand, for truetype .ttc font collections, where the "name" is a concatenation of the individual names with "-&-", both choices are verbose. In the above example the msgothic.ttc file contains 3 fonts: MS-Gothic, MS-PGothic, and MS- UI-Gothic.

My expectation was that iM, like other programs using fonts installed on the system, would be able to locate the individual components of the font collection using their common name (MsGothic or MS-Gothic in the above example). It would be more consistent with common usage for iM to recognize the individual components of a font collection. Most users know the fonts on their system by their individual names, but do not know when they part of a collection.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: label fails with Windows TTC TrueType font collection

Post by anthony »

Fair enough, it is TTC and not TTF. My bad for missing that point.

However one of the main points is you can edit the IM font configuration file and make a shorter name for the font ;-)

The "Font:" part is just a name by which the font is known by IM. It is just a label that some automatic generators extract from a font, and can leave it rather verbose, as you discovered.

Most of my linux, yes linux, script does is try to clean up and junk a lot of the useless 'foundary' and other verbose crap that is in the font name extracted from the font file. (For example remove "MS-" from "MS-Gothic", and make "ArialBold" just "ArialB"), you are free to do the same thing. You just need to locate the file (whcih is also listed in "convert -list font" output, and shorten it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply