Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#26897 closed enhancement (fixed)

gd2 default fontpath for OS X

Reported by: anddam (Andrea D'Amore) Owned by: ryandesign (Ryan Schmidt)
Priority: Normal Milestone:
Component: ports Version: 1.9.1
Keywords: libgd font path Cc: mojca (Mojca Miklavec)
Port: gd2

Description

Default font path in libgd is /usr/share/fonts/truetype that is not present on standard OS X, this makes necessary to either set up GDFONTPATH or link the default directory to an actual font directory. Moreover the former doesn't work if there's no shell involved, for example when wxMaxima directly calls gnuplot to get a png plot.

The solution is to add

configure.cflags-append     -DDEFAULT_FONTPATH=\\\"/System/Library/Fonts:/Library/Fonts\\\"

to Portfile thus passing the appropriate macro to compiler.

This way programs relying on libgd will find system's fonts even if GDFONTPATH is not specified and there's no /usr/share/fonts/truetype .

This is not a bug per se but I think that a port that works out of the box rather than requiring further configuration is better.

Attachments (2)

patch-gd2.diff (369 bytes) - added by anddam (Andrea D'Amore) 10 years ago.
gd2 Portfile patch
gd2.diff (788 bytes) - added by mojca (Mojca Miklavec) 9 years ago.
Another patch from upstream (https://bitbucket.org/pierrejoye/gd-libgd/changeset/3ea283efcdaf)

Download all attachments as: .zip

Change History (13)

Changed 10 years ago by anddam (Andrea D'Amore)

Attachment: patch-gd2.diff added

gd2 Portfile patch

comment:1 Changed 10 years ago by ryandesign (Ryan Schmidt)

Sorry for neglecting this ticket. Is there a test case I can use -- a command I can run before and after applying this patch to see that it works?

comment:2 Changed 10 years ago by anddam (Andrea D'Amore)

Running:

gnuplot -e 'show fontpath'

in console without patch should show non existing paths in OS X, while with patch applied it should show system's paths.

comment:3 Changed 10 years ago by ryandesign (Ryan Schmidt)

I get:

$ gnuplot -e 'show fontpath'

	fontpath is 
	system fontpath is "/System/Library/Fonts" "/Library/Fonts" "/Users/rschmidt/Library/Fonts" 

What do you get?

Also, this problem was previously reported in #14999.

comment:4 Changed 10 years ago by anddam (Andrea D'Amore)

That's due to r76048, reverting before that revision I get

 gnuplot -e 'show fontpath'

	fontpath is 
	system fontpath is "/usr/X11R6/lib/X11/fonts/Type1" 

IIRC I was trying to configure properly gd2 in order to have all programs relying on it working properly, I eventually ended patching gnuplot because it explicitly populates its fontpath_tbl struct .

With regards to this ticket the main difference we get with and without the patch is that gd2 library ends having a path adequate to OS X or not.

Active version is patched, destrooted isn't:

gd2 $ strings work/destroot/opt/local/lib/libgd.2.dylib | grep /System
gd2 $ strings /opt/local/lib/libgd.2.dylib | grep System
/System/Library/Fonts:/Library/Fonts

comment:5 Changed 10 years ago by mbrethen@…

I agree, it should work out of the box. Arial is gnuplot's default font for making PNG files. That font is present in /Library/Fonts but gnuplot is not finding it, that's a MacPorts packaging bug. Neither did setting the GDFONTPATH variable work for wxMaxima. A way around this issue was to put 'set term png font "/Library/Fonts/Arial Unicode.ttf" 12' in the '.gnuplot' file located in my user diractory. But I spent a few hours online to sort this out.

comment:6 Changed 9 years ago by anddam (Andrea D'Amore)

Resolution: fixed
Status: newclosed

Maintainer timeout, committed r87966.

Changed 9 years ago by mojca (Mojca Miklavec)

Attachment: gd2.diff added

comment:7 Changed 9 years ago by mojca (Mojca Miklavec)

Resolution: fixed
Status: closedreopened

May I request reviewing anothe patch against current port, gd2.diff? It is an upstream patch that helps with the following problem in gnuplot:

> set term png
Terminal type set to 'png'
Could not find/open font when opening font "arial", using internal non-scalable font
Options are 'nocrop medium size 640,480 '

which I think was exactly the problem reported here (if I'm wrong, please excuse me).

Gnuplot also needs a tiny patch in addition to this to actually resolve the problem, but fixing gd is a prerequisite for a patch in gnuplot.

PS: I'm not sure if it is polite to add stuff to old & closed tickets (if it was not appropriate this time, let me know, I'll open a new report next time), but it was most likely about exactly the same issue which is still present for me. PPS: current port has wrong line numbers anyway:

--->  Applying /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/graphics/gd2/files/patch-gdft.c.diff
patching file gdft.c
Hunk #1 succeeded at 1402 (offset 39 lines).

comment:8 Changed 9 years ago by mojca (Mojca Miklavec)

Cc: mojca.miklavec.lists@… added

Cc Me!

comment:9 Changed 9 years ago by ryandesign (Ryan Schmidt)

Resolution: fixed
Status: reopenedclosed

Thanks. Reopening an old ticket is fine, if you believe the ticket was closed improperly or prematurely. In this case, I don't really understand the old issue, or the new issue, or if they're the same, so I'll defer to your judgement. I committed your patch in r92005.

comment:10 Changed 9 years ago by mojca (Mojca Miklavec)

Thank you very much for the patch. I opened a new gnuplot-specific ticket #34072 in order to collect relevant information at a single place. I need to do some more tests & debugging before proceeding, but fixing gd2 was essential for that. I really hope that gd2 will release 2.0.36 eventually ... Thanks again.

comment:11 Changed 9 years ago by ryandesign (Ryan Schmidt)

I wouldn't hold my breath... they haven't even been able to get their web site online since several years.

Note: See TracTickets for help on using tickets.