[XeTeX] Finding out if a font supports a particular Unicode character and using it

Mike Maxwell maxwell at umiacs.umd.edu
Sat Jan 30 03:53:32 CET 2010


Fr. Michael Gilmary wrote:
> With version 3.1 it complains:
> 
>>  File "/Users/frmichael/bin/fontswith", line 21
>>     print "Could not open ", font_name
>>                           ^
>> SyntaxError: invalid syntax

This is indeed valid in Python v2, but not in v3, because 'print' became 
a function rather than a statement, and therefore needs parens around 
its operators.  See
    http://docs.python.org/dev/3.0/whatsnew/3.0.html
under "Print Is A Function."

> But if I use version 2.3.5, it tells me:
> 
>> File "./fontswith", line 66
>>     except Exception as d:
>>                       ^
>> SyntaxError: invalid syntax

And yes, this would be invalid in 2.3, but valid in 2.6, see
    http://docs.python.org/whatsnew/2.6.html
under Python 3.0 (which is describing Python 3 features that were 
"backported" to the last sub-versions of Python 2, i.e. to 2.6).

I haven't tried this code in Python 2.6, but at least these two errors 
under v2.3 and v3 should be OK in 2.6.

(BTW, for portability testing purposes, it is possible to turn off the 
features which were back-ported into 2.6 by using the '-3' command line 
switch.  This would help improve, if not ensure, compatibility with 2.3 
etc.  It can be pretty hard to make Python code that runs under both 
v2.X and v3, though.)
-- 
    Mike Maxwell
    What good is a universe without somebody around to look at it?
    --Robert Dicke, Princeton physicist


More information about the XeTeX mailing list