Pablo Arantes wrote:
> I contacted the author of Pragmata to share my concerns but he
> couldn't help me much in this respect. I explained him the problem but
> I'm not sure he understood it.

I emailed him too.  We share our first language, so maybe he will
understand me better.


> I wonder if there is a feasible way to change this specification myself.

I had a look at the TTF file format[1] and it's quite easy.  I have
attached a small Python script that will query, set or clear the
monospaced flag on a TTF file.  Run it with no arguments to get help.

Remember to operate on a copy of the font file and to install/uninstall
the font through Windows's Control Panel.  That is: make a copy of the
font file; set the flag on it; uninstall the currently installed font;
install the modified version; profit.


Tobia

[1]
http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html
http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6post.html
#!/usr/bin/python

import sys, getopt, struct

def get_post_off(f):
        f.seek(0)
        data = f.read(512)
        post_off = None
        for i in range(30):
                off = 12 + 16 * i
                tag = data[off : off + 4]
                if tag == 'post':
                        post_off = struct.unpack('>I', data[off + 8 : off + 
12])[0]
                        break
        if not post_off:
                raise 'ERROR: cannot find table "post" in the font directory'
        return post_off

def get_mono(f):
        post_off = get_post_off(f)
        f.seek(post_off + 12)
        mono = struct.unpack('>i', f.read(4))[0]
        return mono

def set_mono(f, n):
        post_off = get_post_off(f)
        f.seek(post_off + 12)
        f.write(struct.pack('>i', n))

if __name__ == '__main__':
        def usage():
                print 'usage: ttfmono [-su] <file.ttf>'
                print '  -s  set the monospaced flag'
                print '  -u  unset the monospaced flag'
                print '  otherwise: query the monospaced flag'
                sys.exit(1)

        opts, args = getopt.getopt(sys.argv[1:], 'su')
        opts = dict(opts)
        opt_set = '-s' in opts
        opt_unset = '-u' in opts
        if len(args) != 1: usage()
        if opt_set and opt_unset: usage()

        if opt_set or opt_unset:
                ttf_file = open(args[0], 'r+')
        else:
                ttf_file = open(args[0])
        if not ttf_file: usage()

        if opt_set:
                set_mono(ttf_file, 1)
        elif opt_unset:
                set_mono(ttf_file, 0)

        print 'monospaced flag =', get_mono(ttf_file)
        print >>sys.stderr, '(0 = variable-width, otherwise = monospaced)'
        ttf_file.close()

Reply via email to