[SOLVED] unable to read font `(null)'

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Neville
Posts: 7
Joined: 2012-03-13T14:22:04-07:00
Authentication code: 8675308

[SOLVED] unable to read font `(null)'

Post by Neville »

Assistance with the following would be appreciated.

$ montage '*.gif' -geometry 187x187+3+2 new.png
montage: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1120.

I am new to ImageMagick and have limited command line experience. After several hours playing I failed to get MacPorts working on my PPC with OS X 10.5.8 although I think I have installed it on other Macs without difficulty in the past. I eventually did my best to follow ImageMagick UNIX install instructions and it appeared to install and test OK yesterday. I have since installed GS and fonts although I am not sure why they are required.

If necessary I can patch files but would appreciate clear instructions concerning the likely location of the file to be patched.

Belated extra details for bug records:

ImageMagick version: 6.7.6-0
OS: Mac OS X 10.5.8
Hardware: 733 MHz PPC G4+ with 1.5 GB RAM
Last edited by Neville on 2012-03-14T10:57:26-07:00, edited 2 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: unable to read font `(null)'

Post by fmw42 »

Montage needs to be able to write text captions. It would appear that you need to install the freetype delegate library and then recompile IM.

Ghostscript is used by IM to read .ps and .pdf (vector format images)
Neville
Posts: 7
Joined: 2012-03-13T14:22:04-07:00
Authentication code: 8675308

Re: unable to read font `(null)'

Post by Neville »

Prior to my original post I Googled and indications were that my error was caused by a bug introduced at an earlier update. Are you sure that this identified bug is not the cause of my problem? The reason I ask is that reinstalling takes several hours on my Mac whereas I could patch a change of default font in seconds. Why does it not attempt to use either my system fonts or the recently installed PS fonts?

If there is not a patch which will work where do I get the 'freetype delegate library' and how do I install it?

Perhaps ImageMagick download/install instructions need an update. I followed advice for my platform which was to download IM only to be then be directed to MacPorts which, if it had ever worked, would probably have downloaded IM again. Instructions appear to lack a few critical steps which are not second nature to all users such as relocating the download and cd to that location. Would it not be better to provide wget scripts slightly modified for each platform?
Neville
Posts: 7
Joined: 2012-03-13T14:22:04-07:00
Authentication code: 8675308

[SOLVED] unable to read font `(null)'

Post by Neville »

I have now resolved this and although Fred's assistance here did not get me very far this earlier thread he contributed to was very helpful: viewtopic.php?f=3&t=18133

For the sake of others, particularly Mac users with limited Terminal experience, who end up here I will document my steps in some detail:

1 - Save this perl script as text http://www.imagemagick.org/Usage/script ... k_type_gen and change its extension to pl

2 - Open Terminal and type
chmod 755
followed by a space and then drag the perl script file to the Terminal and press return to make it executable.

3 - Drag the perl script file to the terminal and press return to run it - it only writes text to the terminal window.

4 - When the script has completed 'Export Text As' from the terminal.

5 - With a clean text editor such as TextEdit or BBEdit ensure that the first line of the exported file is:
<?xml version="1.0"?>
and the last line is:
</typemap>

6 - Change the file name to:
type.xml

7 - Put the type.xml file in a folder entitled .magick in your users Home folder - the dot will make the folder invisible so this will not be easy in the Finder - I use 'Invisibility Toggler' but there are probably many ways of doing this.

This appears to have resolved my ImageMagick font problems for the time being without the need to download anything further. I am not sure if my earlier GS and GS fonts installs were necessary but they did remove several error messages.
Neville
Posts: 7
Joined: 2012-03-13T14:22:04-07:00
Authentication code: 8675308

Re: [SOLVED] unable to read font `(null)'

Post by Neville »

Here is an improved fix for IM's inability to find fonts when ~/.magick/type.xml does not exist and IM's file at eg /usr/local/etc/ImageMagick/type.xml has no data between its <typemap> and </typemap> tags. This has been written for OS X but it can probably be applied to other platforms.

1 - Save the perl script at http://www.imagemagick.org/Usage/script ... k_type_gen as text and change its extension to pl

2 - Type 'chmod 755' in the Terminal followed by a space and then drag the perl script file to the Terminal and press return to make it executable.

3 - Drag the perl script file to the Terminal and press return to run it - it only writes text to the Terminal window.

4 - When the script has completed 'Export Text As' from the Terminal.

5 - With a clean text editor such as TextEdit or BBEdit remove any unwanted entries. In my case I removed all items with 'Developer', 'Java' or 'Volumes' in the path. Copy font details between <typemap> and </typemap>.

6 - Locate IM's type.xml file at eg /usr/local/etc/ImageMagick/ and give yourself write permission. Paste font details between the <typemap> and </typemap> tags and save.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: [SOLVED] unable to read font `(null)'

Post by anthony »

That is one way. The other methods is given in the documentation within the script itself.

For example I typically generate a font list from a specific sub-directory of my home.

Code: Select all

   find /home/user/my/font/dir/ -name '*.ttf' | \
      imagick_type_gen -f - > ~/.magick/type-myfonts.xml
I then include type-myfonts.xml in my ~/magick/type.xml file

Code: Select all

<typemap>
  <include file="type-myfonts.xml" />
</typemap>
I have other includes for other font directories in this file too, which is why I don't really want to simply overwrite it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Neville
Posts: 7
Joined: 2012-03-13T14:22:04-07:00
Authentication code: 8675308

Re: [SOLVED] unable to read font `(null)'

Post by Neville »

Thanks for your helpful input Anthony and thanks also for your excellent scripts. As well as the embedded link, which is helpful for those trying to get fonts working, I should have also included a link to your scripts index page at: http://www.imagemagick.org/Usage/scripts/

I am a little surprised that there have been several reports of 'missing' fonts over recent years especially from OS X users. Do you think there is still an install bug?

My initial need was convert 12,000 map tile gifs to 30 png images. ImageMagick appeared to be the only free software able to to do this satisfactorily on my old Mac. I only need montage without any fonts but it failed to work because montage has includes for fonts.

Do you think the developers should consider making more effort to ensure that ImageMagick has access to at least one font? Would it be practical to include one font in the installer so that much of ImageMagick would still work even if it failed to find any local fonts?

Whilst your perl script got me going it does not do a particularly good job on OS X. A quick check indicates that the fonts on my main OS are as follows:

~/Library/Fonts - zero
various locations Java VM - 8
/System/Library/Fonts - 32
/Library/Fonts - 68
/usr/local/share/ghostscript/fonts - about 392
/usr/X11/lib/X11/fonts - perhaps thousands

Your script failed to find most of the above.

The script found many fonts I would prefer not to use. I simply removed the ones with Java, Developer or Volumes in the path. If you ever rewrite the script I would advise not following /Volumes/ on OS X as it will include all partitions and attached disks. I have several attached storage disks and my main disk is split into several partitions most with working OSs - I ended up removing about 75% of the fonts the script did find.

I am sure most OS X users would prefer to keep fonts and any pointers to them away from their home directories - hence my use of /usr/local/etc/ImageMagick/type.xml rather than ~/.magick/type.xml

I don't recall having font problems with other installations. Do you know why ImageMagick has difficulties with fonts?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: [SOLVED] unable to read font `(null)'

Post by anthony »

I have no made use of X window fonts for a very very very long time. I do know however that it does require an active web server to make use of them.

Typically ttf or otf (opentype) font files is what is typically used. Though Postscript fonts can also be used though I don't recommend them.

Actually modern X window servers also often make direct use of TTF fonts too.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Neville
Posts: 7
Joined: 2012-03-13T14:22:04-07:00
Authentication code: 8675308

Re: [SOLVED] unable to read font `(null)'

Post by Neville »

As far as I can tell IM assumes that type.xml files exist on all OSs. Where can make a formal bug report about this imprudent assumption?

Your script only finds a small portion of the 45 ttf fonts at /Library/Fonts:

/Developer - 1
/Library/Fonts - 9
/System/Library/Fonts - 5
/System/Library/Frameworks/JavaVM - 16
/System/Library/Java/JavaVirtualMachines - 8
/usr/X11/lib/X11/fonts - 54
/Volumes/4-G/Library/Fonts - 2
/Volumes/4-G/System/Library/Fonts - 2
/Volumes/4-G/System/Library/Frameworks/JavaVM - 28
/Volumes/8-F/Library/Fonts - 9
/Volumes/8-F/System/Library/Fonts - 7
/Volumes/8-F/System/Library/Frameworks/JavaVM - 16
/Volumes/8-F/usr/X11/lib/X11/fonts - 54
/Volumes/20-B/System/Library/Fonts - 7
/Volumes/20-D/System/Library/Fonts - 5
/Volumes/20-E/Library/Fonts - 2
/Volumes/20-E/System/Library/Fonts - 2
/Volumes/20-E/System/Library/Frameworks/JavaVM - 28

I have since discovered that 'weekly' is broken on many versions of OS X. After a sudo locate db update the script found many more fonts but not in /Library/Fonts. Can you explain why it still only returns 9 fonts from this directory?
PacoH
Posts: 1
Joined: 2013-12-19T13:34:05-07:00
Authentication code: 6789

Re: [SOLVED] unable to read font `(null)'

Post by PacoH »

Neville wrote:Here is an improved fix for IM's inability to find fonts when ~/.magick/type.xml does not exist and IM's file at eg /usr/local/etc/ImageMagick/type.xml has no data between its <typemap> and </typemap> tags. This has been written for OS X but it can probably be applied to other platforms.

1 - Save the perl script at http://www.imagemagick.org/Usage/script ... k_type_gen as text and change its extension to pl

2 - Type 'chmod 755' in the Terminal followed by a space and then drag the perl script file to the Terminal and press return to make it executable.

3 - Drag the perl script file to the Terminal and press return to run it - it only writes text to the Terminal window.

4 - When the script has completed 'Export Text As' from the Terminal.

5 - With a clean text editor such as TextEdit or BBEdit remove any unwanted entries. In my case I removed all items with 'Developer', 'Java' or 'Volumes' in the path. Copy font details between <typemap> and </typemap>.

6 - Locate IM's type.xml file at eg /usr/local/etc/ImageMagick/ and give yourself write permission. Paste font details between the <typemap> and </typemap> tags and save.
This worked for me with some modification. When I ran the script it included even fonts in folders of regular apps. This caused the same error. What was really weird was I got an error for an app that was not 'installed' in the Applications folder but was once in my Downloads folder but long ago deleted. Huh?! So I deleted all lines for fonts in apps. I mean apps come and go and why would you even want the fonts of a particular app? BUT I still got the same error for the non-existant app AND that app and all the other ones were again added to type.xml! So I again edited it and changed permissions to 555. That worked.

BTW I just added the new lines to the existing 2 files. I had 2 type.xml files:

Code: Select all

/usr/local/Cellar/imagemagick/6.8.7-7/etc/ImageMagick-6/type.xml
/usr/local/Cellar/imagemagick/6.8.7-7/share/doc/ImageMagick-6/www/source/type.xml
I put one in

Code: Select all

/Users/user/.magick/type.xml
but it had no effect.
Neville
Posts: 7
Joined: 2012-03-13T14:22:04-07:00
Authentication code: 8675308

Re: [SOLVED] unable to read font `(null)'

Post by Neville »

What was really weird was I got an error for an app that was not 'installed' in the Applications folder
If you have OS X 10.4 or 10.5 this could be caused by regular maintenance never running as intended - see my page at:

http://links.zero.eu.org/os-x/period/
Post Reply