how to select a unicode range using python

markzman's picture

hey guys am a newbie in fontlab could you help me how to select a unicode range using macro?
like the "select alphanumeric", I can't figure out how it selects by unicode range.
here is the select alphanumeric codes:

fl.Unselect()

for i in range(0x41, 0x5b):
fl.Select(Uni(i))

for i in range(0x61, 0x7b):
fl.Select(Uni(i))

for i in range(0x30, 0x3A):
fl.Select(Uni(i))

fl.iglyph = 20

now how do I change this to select unicode range from Amacron to Gdotaccent?

Michel Boyer's picture

Here are a few lines from Unicode's name list

Code Name
0030 DIGIT ZERO ...
0039 DIGIT NINE

0041 LATIN CAPITAL LETTER A ...
005A LATIN CAPITAL LETTER Z

0061 LATIN SMALL LETTER A ...
007A LATIN SMALL LETTER Z

That means that 'LATIN SMALL LETTER A' is Uni(0x0061) or equivalently Uni(0x61) etc. since we may always remove zeros between 0x and the first non zero digit. Thus

range(0x0030,0x0039+1) gives 0123456789
range(0x0041,0x005A+1) gives ABCDEFGHIJKLMNOPQRSTUVWXYZ
range(0x0061,0x007A+1) gives abcdefghijklmnopqrstuvwxyz

Your code above does not select all alphanumerical characters; it selects digits, capitals letters and small letters of only the English alphabet. It could have been written

fl.Unselect()
for i in range(0x0030,0x0039+1) + range(0x0041,0x005A+1) + range(0x0061,0x007A+1):
   fl.Select(Uni(i))

From Adobe's file http://www.adobe.com/devnet/opentype/archives/glyphlist.txt Amacron is 0100 and Gdotaccent is 0120; range(0x0100,0x0120+1) is used to select that range.

Michel

Syndicate content Syndicate content