FontLab Forum
2012-05-23, 23:47:41 *
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: How to insert a component in a glyph in a script  (Read 1885 times)
cdorje
Sr. Member
****

Karma: +0/-0
United States United States

Posts: 10


« on: 2011-06-07, 01:15:03 »

I'm a programmer, but new to python scripting. I need to write a script that inserts glyphs as a component in other glyphs. Many characters in the Tibetan font I'm making are composed of pieces that are other glyphs. Any help would be appreciated. Thanks.
Logged
Eigi
Beta: FontLab Studio Mac
Hero Member
***

Karma: +7/-0
Germany Germany

Posts: 57



WWW
« Reply #1 on: 2011-06-07, 02:25:06 »

Hello,

Code:
shift = Point(shift_x, shift_y)
scale = Point(scale_x, scale_y)
component = Component(otherGlyph.index, shift, scale)
thisGlyph.components.append(component)

does this help?

Eigi
Logged
cdorje
Sr. Member
****

Karma: +0/-0
United States United States

Posts: 10


« Reply #2 on: 2011-06-07, 10:55:55 »

Yes. Thanks so much. I didn't see the components.append() method documented anywhere. In the mean time, I discovered that RoboFab has an appendComponent() method that refers to glyphs by name rather than index. If I want to stick with FontLab's built-in python support, is there a way to refer to a component by name rather than index or a way to easily get the index of a glyph name? Thanks, David
Logged
Eigi
Beta: FontLab Studio Mac
Hero Member
***

Karma: +7/-0
Germany Germany

Posts: 57



WWW
« Reply #3 on: 2011-06-07, 11:39:13 »

Hello,

you can try this
Code:
font[glyphname].index

But it is not save because you can create multiple glyphs with the same name in the same font. This happens only when you create the glyphs via python script. The UI prevents such problems.

Eigi
Logged
cdorje
Sr. Member
****

Karma: +0/-0
United States United States

Posts: 10


« Reply #4 on: 2011-06-08, 13:32:25 »

Thanks Eigi. I'll have to put some logic in to check for existing names. I think I've got what I need now. THanks for your help.
Logged
Tags: component 
Pages: [1]
  Print  
 
Jump to:  

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