0

I am trying to create font from single SVG files. Here the sample:

#!/usr/local/bin/fontforge
# file test.py

import fontforge;

font=fontforge.font();
glyph = font.createChar(65);
glyph.importOutlines("/home/user/guitar.svg");
# or glyph.importOutlines("~/guitar.svg");
# or glyph.importOutlines("./guitar.svg");
# or glyph.importOutlines("guitar.svg");

Any attempts to load single SVG file cause the same error:

Traceback (most recent call last):
    File "test.py", line 8, in <module>
    glyph.importOutlines("/home/user/guitar.svg");

Where am I wrong?


Environment:

file rights

ls -la /home/user/guitar.svg -rwxrwxrwx 1 user user 3728 Jun 30 20:46 guitar.svg

OS

$ uname -a Linux servername 2.6.32-431.11.2.el6.i686 #1 SMP Tue Mar 25 17:17:46 UTC 2014 i686 i686 i386 GNU/Linux

$ cat /etc/centos-release CentOS release 6.5 (Final)

Python version

$ python --version Python 2.7.7

Fontforge version

$ fontforge --version Copyright (c) 2000-2012 by George Williams. Executable based on sources from 14:57 GMT 31-Jul-2012-TtfDb. Library based on sources from 14:57 GMT 31-Jul-2012. fontforge 20120731 libfontforge 11524617


P.S. The same test is OK at Ubuntu 12.04 but the fontforge is other version

$ fontforge --version Copyright (c) 2000-2011 by George Williams. Executable based on sources from 13:48 GMT 22-Feb-2011-ML. Library based on sources from 13:48 GMT 22-Feb-2011. fontforge 20110222 libfontforge 20110222-ML

pvolyntsev
  • 141
  • 8

1 Answers1

0

Got same problem.

Inside fontforge source file Python.c the code for loading image is

    GImage *image = GImageRead(locfilename);
    int ly = ((PyFF_Glyph *) self)->layer;
    if ( image==NULL ) {
        PyErr_Format(PyExc_EnvironmentError, "Could not load image file %s", locfilename );
return(NULL);
    }

And then there is a bug in switch for SVG, just look inside GImageReader.c and try to find SVG :)

GImage *GImageRead(char * filename) {
    char *pt;

    if ( filename==NULL )
return( NULL );

    pt = strrchr(filename,'.');
    if ( pt==NULL )
    pt = "";
    if ( strmatch(pt,".bmp")==0 )
return( GImageReadBmp(filename));
    else if ( strmatch(pt,".xbm")==0 )
return( GImageReadXbm(filename));
    else if ( strmatch(pt,".xpm")==0 )
return( GImageReadXpm(filename));
#ifndef _NO_LIBTIFF
    else if ( strmatch(pt,".tiff")==0 || strmatch(pt,".tif")==0 )
return( GImageReadTiff(filename));
#endif
#ifndef _NO_LIBJPEG
    else if ( strmatch(pt,".jpeg")==0 || strmatch(pt,".jpg")==0 )
return( GImageReadJpeg(filename));
#endif
#ifndef _NO_LIBPNG
    else if ( strmatch(pt,".png")==0 )
return( GImageReadPng(filename));
#endif
#ifndef _NO_LIBUNGIF
    else if ( strmatch(pt,".gif")==0 )
return( GImageReadGif(filename));
#endif
    else if ( strmatch(pt,".ras")==0 )
return( GImageReadRas(filename));       /* Sun raster */
    else if ( strmatch(pt,".rgb")==0 )
return( GImageReadRgb(filename));       /* SGI format */

return( NULL );
}
Artur A
  • 7,115
  • 57
  • 60
  • Yes, I also checked the sources, but did not dare to change even a single line ;) So I changed the server, reinstall and upgraded fontforge – pvolyntsev Aug 15 '14 at 06:40