FontLab Forum
2012-02-08, 21:15:44 *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to the FontLab forum, read how to use it! Update: Archives from old MSN forums are now available on our forum.
 
   Home   Help Search Calendar Downloads Tags Login Register  
Del.icio.us Digg FURL FaceBook Stumble Upon Reddit SlashDot

Pages: [1]
  Print  
Author Topic: Adding kerning classes to the font  (Read 4549 times)
mekkablue
Beta: FontLab Studio Mac
Hero Member
***

Karma: +0/-0
Austria Austria

Posts: 40



WWW
« on: 2009-04-21, 11:48:43 »

Hi, can anyone tell me why this does not work:

Code:
f = fl.font
thisclass = "_f_left: f' florin f_f fi fl f_f_i f_f_l"
f.classes.append(thisclass)

How do I append a class to fl.font.classes, which is a list of strings?
TIA, Eric.
Logged
Eigi
Beta: FontLab Studio Mac
Hero Member
***

Karma: +7/-0
Germany Germany

Posts: 55



WWW
« Reply #1 on: 2009-04-22, 04:13:48 »

Hello,

try this:
Code:
classes = list(fl.font.classes)
thisclass = "_f_left: f' florin f_f fi fl f_f_i f_f_l"
classes.append(thisclass)
fl.font.classes = classes
fl.UpdateFont(fl.ifont)
Logged
mekkablue
Beta: FontLab Studio Mac
Hero Member
***

Karma: +0/-0
Austria Austria

Posts: 40



WWW
« Reply #2 on: 2009-04-23, 17:32:49 »

Thanks, Eigi, I’ll try it.
Logged
emtype
Beta: FontLab Studio Mac
Sr. Member
***

Karma: +0/-0
Spain Spain

Posts: 8



WWW
« Reply #3 on: 2009-05-13, 11:48:41 »

Eigi,

your code works well but it create a class that don't have information about left or rigth side...

Do you know any way to import the classes file (.flc) by Python ?

thank you, em.
Logged
Eigi
Beta: FontLab Studio Mac
Hero Member
***

Karma: +7/-0
Germany Germany

Posts: 55



WWW
« Reply #4 on: 2009-05-14, 01:37:09 »

Hello,

you can use this code to set the left / right flags for kerning classes:

Code:
for class_index in range(len(fl.font.classes)):
name, content = fl.font.classes[class_index].split(':', 1)
if name.startswith('_'):         # it is a kerning class
left = 0
right = 0
if name.endswith('_left'):     # left only class
left = 1
elif name.endswith('_right'):  # right only class
right = 1
else:                          # double sided class
left = 1
right = 1
fl.font.SetClassFlags(class_index, left, right)
fl.UpdateFont(fl.ifont)

Best

Eigi
Logged
emtype
Beta: FontLab Studio Mac
Sr. Member
***

Karma: +0/-0
Spain Spain

Posts: 8



WWW
« Reply #5 on: 2009-05-14, 09:10:49 »

Eigi, you are a genious!

Now I can go and back from FontLab to Superpolator without lose this vital info.

Thank you, em.
Logged
Tags:
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!