Allow passing flags to glyph.importOutlines()

View: New views
1 Messages — Rating Filter:   Alert me  

Allow passing flags to glyph.importOutlines()

by Khaled Hosny-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm using FontForge to import a large set of MetaPost generated PS files
into font, using python scripting is handy but it lacks "Handle Erasers"
feature available in the GUI, which I need.

The attached patch allows passing optional flags to
glyph.importOutlines(), the flags are only passed to PS importing
function as it doesn't make sense for other image formats.

Regards,
 Khaled

--
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer


From fcc8ef7d86438cbfa51e4b86094d6791452c0946 Mon Sep 17 00:00:00 2001
From: Khaled Hosny <khaledhosny@...>
Date: Sat, 17 Oct 2009 19:46:20 +0200
Subject: [PATCH] Allow passing flags to glyph.importOutlines()

The flags are passed to SVImportPS only, it does't make any sense to
other image types.
---
 fontforge/python.c |   12 ++++++++++--
 htdocs/python.html |   28 ++++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/fontforge/python.c b/fontforge/python.c
index 277b25a..0ba8097 100644
--- a/fontforge/python.c
+++ b/fontforge/python.c
@@ -6035,12 +6035,20 @@ return(NULL);
 Py_RETURN( self );
 }
 
+static struct flaglist import_ps_flags[] = {
+    { "toobigwarn", sf_toobigwarn },
+    { "removeoverlap", sf_removeoverlap },
+    { "handle_eraser", sf_handle_eraser },
+    { "correctdir",  sf_correctdir },
+      NULL };
+
 static PyObject *PyFFGlyph_import(PyObject *self, PyObject *args) {
     SplineChar *sc = ((PyFF_Glyph *) self)->sc;
     char *filename;
     char *locfilename = NULL, *pt;
+    PyObject *flags;
 
-    if ( !PyArg_ParseTuple(args,"es","UTF-8",&filename) )
+    if ( !PyArg_ParseTuple(args,"es|O","UTF-8",&filename, &flags) )
 return( NULL );
     locfilename = utf82def_copy(filename);
     free(filename);
@@ -6049,7 +6057,7 @@ return( NULL );
     if ( pt==NULL ) pt=locfilename;
 
     if ( strcasecmp(pt,".eps")==0 || strcasecmp(pt,".ps")==0 || strcasecmp(pt,".art")==0 )
- SCImportPS(sc,((PyFF_Glyph *) self)->layer,locfilename,false,0);
+ SCImportPS(sc,((PyFF_Glyph *) self)->layer,locfilename,false,FlagsFromTuple(flags,import_ps_flags));
 #ifndef _NO_LIBXML
     else if ( strcasecmp(pt,".svg")==0 )
  SCImportSVG(sc,((PyFF_Glyph *) self)->layer,locfilename,NULL,0,false);
diff --git a/htdocs/python.html b/htdocs/python.html
index 1f03084..b2507c1 100644
--- a/htdocs/python.html
+++ b/htdocs/python.html
@@ -2150,10 +2150,34 @@ pen = None; # Finalize the pen. This tells FontForge
     </TR>
     <TR>
       <TD><CODE>importOutlines</CODE></TD>
-      <TD><CODE>(filename)</CODE></TD>
+      <TD><CODE>(filename,[flags])</CODE></TD>
       <TD>Uses the file's extension to determine behavior. Imports outline descriptions
  (eps, svg, glif files) into the forground layer. Imports image descriptions
- (bmp, png, xbm, etc.) into the background layer.</TD>
+ (bmp, png, xbm, etc.) into the background layer.
+ Optionally, flags can be used to control PostScript import, it'll be ignored for
+ other file types. Flags is a tuple of the following strings
+ <DL>
+  <DT>
+    toobigwarn
+  <DD>
+    Supress warning window about too big stroke width
+  <DT>
+    removeoverlap
+  <DD>
+    When FontForge detects that an expanded stroke will self-intersect, then
+    setting this flag will cause it to try to make things nice by removing the
+    intersections
+  <DT>
+    handle_eraser
+  <DD>
+    Certain programs use pens with white ink as erasers. When this flag is set,
+    FontForge will attempt to simulate that.
+  <DT>
+    correctdir
+  <DD>
+
+ </DL>
+      </TD>
     </TR>
     <TR>
       <TD><CODE><A name="g-intersect">intersect</A></CODE></TD>
--
1.6.0.4




------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Fontforge-devel mailing list
Fontforge-devel@...
https://lists.sourceforge.net/lists/listinfo/fontforge-devel

signature.asc (204 bytes) Download Attachment