Re: Monospaced font problem

2007-04-02 Thread Pablo Arantes

Tobia,

Man, you're a genius! Your script solved the problem. I ran it and now
every program (including gvim, of course) recognizes Pragmata as being
monospaced.

Thank you very much.

--
Pablo

-- Forwarded message --
From: Tobia <[EMAIL PROTECTED]>
To: 'Vim mailing list' 
Date: Sun, 1 Apr 2007 13:55:46 +0200
Subject: Re: Monospaced font problem
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


Re: Monospaced font problem

2007-04-01 Thread Tobia
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] '
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()


Re: Monospaced font problem

2007-03-31 Thread A.J.Mechelynck

Pablo Arantes wrote:

Tony,

I very much suspect you're right about it: Pragmata must be lacking
the specification of being a monospaced font. Other editors besides
gvim also fail to recognize the font as a valid option. Ironically, I
was able to set the font as the default in Emacs accepts, but I'm
afraid it's too late for a change in my religious beliefs now :-)

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 wonder if there is a feasible way to
change this specification myself.

Thanks for your help,

Pablo


Well, I suppose there is, either by means of a font editor (I suppose such a 
program exists but I don't know under what name) or by binary editing (but I 
don't know what must be changed).


Another question is of course the copyright: by editing that font in such a 
way, you would quite likely be infringeing the terms of the license under 
which you got it. Not that it would matter much as long as you don't 
redistribute the modified version.



Best regards,
Tony.
--
Wethern's Law:
Assumption is the mother of all screw-ups.


Re: Monospaced font problem

2007-03-31 Thread A.J.Mechelynck

Pablo Arantes wrote:

Fellow users,

I'm using gvim 7.0 in a Windows XP SP2 box and I'm experiencing a
problem with font selection. I want to set as the default gui font a TTF
monospaced font, called Pragmata TT, but it won't show up in the list
of available fonts. I've searched the vim archives and google and
cannot figure out why it won't be listed as an option even though it *is* a
monospaced font and other TTF monospaced fonts appear in the list.

The font author could not help and provided me an OTF version that gvim
accepts, although it renders much worse than the TTF in programs where
the latter version actually works.

Thanks in advance for any tip or suggestion.



Well, maybe the code in the font itself doesn't identify it as fixed-width. 
Except in gvim versions with GTK2 GUI (which are for X11, thus not for 
native-Windows), gvim will only accept fonts that identify themselves as 
fixed-width. Apparently your Pragmata TT font doesn't. OTOH, Lucida Console 
does, although its bold Cyrillic glyphs are very slightly wider than other 
glyphs, which makes its use problematic when editing Russian.


If ":set guifont=Pragmata_TT:h12:cDEFAULT" or ":set 
guifont=Pragmata:h12:cDEFAULT" don't work, then your only choice is to use 
another font, unless you want to compile a version of gvim for Cygwin/X11 with 
GTK2 GUI; but there are other problems to that.



Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
155. You forget to eat because you're too busy surfing the net.


Re: Monospaced font problem

2007-03-31 Thread Robert Hicks

Pablo Arantes wrote:

Fellow users,

I'm using gvim 7.0 in a Windows XP SP2 box and I'm experiencing a
problem with font selection. I want to set as the default gui font a TTF
monospaced font, called Pragmata TT, but it won't show up in the list
of available fonts. I've searched the vim archives and google and
cannot figure out why it won't be listed as an option even though it *is* a
monospaced font and other TTF monospaced fonts appear in the list.

The font author could not help and provided me an OTF version that gvim
accepts, although it renders much worse than the TTF in programs where
the latter version actually works.

Thanks in advance for any tip or suggestion.


How are you setting "guifont" to use it?

Robert