FontLab Forum
2010-09-09, 14:35:09 *
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: 'Sharp/Smooths connections' via python  (Read 2557 times)
emtype
Jr. Member
**

Karma: +0/-0
Spain Spain

Posts: 8



View Profile WWW
« on: 2009-05-26, 19:08:30 »

Hi everyone,

I have been trying to fix the sharp connections via python but I didn't find the solution.

I think that "NodeConnectionSmooth" is equivalente to: ctrl + click > connection/smooth

I tried many things like this:

Code:
from FL import *

for g in f.glyphs:
g.SelectAll()
fl.TransformGlyph(g, 15, "") # recalculate connections   >> OK
#fl.TransformGlyph(g, 40141, "") #NodeConnectionSmooth >> NO
fl.CallCommand(40141) #NodeConnectionSmooth >> NO
fl.UpdateFont()


But I can't achieve that "NodeConnectionSmootht" works, I tried with CallCommand and TransformGlyph (I don't know if it's possible with this last one...)


Thanks in advance, em.


* the script need some conditionals to be usefull...
« Last Edit: 2009-05-28, 12:39:04 by emtype » Logged
Eigi
Jr. Member
**

Karma: +4/-0
Germany Germany

Posts: 33



View Profile WWW
« Reply #1 on: 2009-05-28, 13:49:18 »

Hello,

You can do something like this to chage the alignment type of a node:
Code:
glyph = fl.glyph
for node in glyph.nodes:
if node.type == nCURVE and node.alignment != nSMOOTH:
node.alignment = nSMOOTH
fl.UpdateGlyph(fl.iglyph)

... but this doesn't move the nodes or control points. It changes the behavior of the control points if you touch them with the mouse.

If you want to move the control points to form a straight with the node, you have to do the math (and movement) yourself.

Eigi
Logged
emtype
Jr. Member
**

Karma: +0/-0
Spain Spain

Posts: 8



View Profile WWW
« Reply #2 on: 2009-05-28, 14:13:31 »

Eigi,

I had already found something similar to your script:

Code:

from robofab.world import CurrentFont

f = CurrentFont()
 
for c in f:
for contour in c:
for segment in contour:
segment.smooth = True


It's the same behavior, only change the type of node but don't change the BCPs.

Never mind, I have already been changing it manually in thousand of glyphs...

Thank you for you reply, em.
« Last Edit: 2009-05-29, 05:03:00 by emtype » Logged
Tags:
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!