[MacPorts] #34072: gnuplot & gd: Could not find/open font when opening font "arial"

MacPorts noreply at macports.org
Mon Apr 16 02:08:01 PDT 2012


#34072: gnuplot & gd: Could not find/open font when opening font "arial"
--------------------------------------------+-------------------------------
 Reporter:  mojca.miklavec.lists@…          |       Owner:  macports-tickets@…                   
     Type:  defect                          |      Status:  new                                  
 Priority:  Normal                          |   Milestone:                                       
Component:  ports                           |     Version:  2.0.4                                
 Keywords:                                  |        Port:  gnuplot                              
--------------------------------------------+-------------------------------
 When running gnuplot with png terminal, it still reports problems:
 {{{
 > set term png
 Terminal type set to 'png'
 Could not find/open font when opening font "arial", using internal non-
 scalable font
 }}}
 (I plan to look into the issue and do some more extensive tests, I would
 only like to collect all the problems & pointers at a single place and
 make sure that I don't forget about it. Of course anyone is welcome to
 help.)

 Related tickets: #26897, #14999, r76048

 Gnuplot uses the following trick on Windows (and could do something
 similar on Mac OS X; I'm not sure if it is the right way to do that or if
 it is better to make sure that fontconfig works properly):

 {{{
 #ifdef _Windows
     /* Set the default search path for fonts to something useful. */
     if (getenv("GDFONTPATH") == NULL) {
         const char fonts[] = "\\fonts";
         char *windir = getenv("windir");
         if (windir) {
         char *gdfontpath = (char *)
             gp_alloc(strlen(windir) + strlen(fonts) + 1, "GDFONTPATH");
         if (gdfontpath) {
            strcpy(gdfontpath, windir);
            strcat(gdfontpath, fonts);
            SetEnvironmentVariable("GDFONTPATH", gdfontpath);
            free(gdfontpath);
         }
         }
     }
 #endif
 }}}

 That might (to some extent) avoid the need to patch gd2 with
 DEFAULT_FONTPATH, see #26897, even though I'm not sure if gnuplot is the
 only program that has problems with GD's "bad defaults". Gnuplot's "show
 fontpath" sometimes reports font path inside /usr/X11R6/ only.

 Ethan Merritt suggested the following patch (see
 http://comments.gmane.org/gmane.comp.graphics.gnuplot.devel/8477):

 {{{
 /* First try the old GDFONTPATH mechanism for locating fonts */
         gdFTUseFontConfig(0);
         err = gdImageStringFT(NULL, &brect[0], 0,
                 png_state.ttffont, (double)png_state.default_ttfsize,
                 0.0, 0, 0, "test");

         /* If that didn't work, try again using fontconfig mechanism */
         if (err && gdFTUseFontConfig(1)) {
             err = gdImageStringFT(NULL, &brect[0], 0,
                 png_state.ttffont, (double)png_state.default_ttfsize,
                 0.0, 0, 0, "test");
             fprintf(stderr,"fontconfig %s font %s\n",
                 err ? "did not find" : "found",
                 png_state.ttffont);
         }

         /* If we still haven't found the font, punt to the internal non-
 TTF default set */
         if (err) {
             fprintf(stderr,"%s when opening font \"%s\", using internal
 non-scalable font\n",
                         err, png_state.ttffont);
         }
 }}}

 but doesn't want to include it into Gnuplot until GD 2.0.36 with a fix
 (see #26897) gets released. Citing him:

 > There seem to be bugs in the libgd function gdFTUseFontConfig(), in that
 > once you turn it on you can never turn it off again.  Unless that is
 fixed,
 > it means that gnuplot scripts using a mixture of self-supplied fonts and
 > fontconfig-installed fonts will fail.   That would break most of my
 > web tools, for example, which provide private font files.

 Since MacPorts now has the necessary patch in gd2 (r92005), we could fix
 gnuplot in MacPorts before the patch is included in gnuplot upstream. But
 I would like to do some additional testing with both PostScript and GD
 (png) terminals before committing anything.

 I would also like to understand better the exact consequences of patch
 r76048. If it is needed and if it is the right way to specify font paths
 without recursive search, it should be included upstream. Else we need to
 figure out what exactly is needed to avoid the problem that the patch was
 trying to solve in the first place.

-- 
Ticket URL: <https://trac.macports.org/ticket/34072>
MacPorts <http://www.macports.org/>
Ports system for Mac OS


More information about the macports-tickets mailing list