FontLab Forum
2012-05-22, 06:59:23 *
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: FL 5.1 export script needed  (Read 1164 times)
Meitnik
Beta: FontLab Studio Mac
Hero Member
***

Karma: +1/-0
Posts: 27


« on: 2011-10-27, 02:14:59 »

Hi,

Well done on FL 5.1.
I am seeking a simple tool that would grab the unicode point number and the name of a glyph to be exported based on the current sorting in the main font window into a text file. The save encoding menu does not do what I need at this time (only does 255 slots). I have carefully renamed and reassigned unicode private area numbers to each glyph towards creating a unique encoding that will be part of an OT font. Having to retype/copy/paste info from each glyph into a text editor is not working smart ;-) Surely a simple python tool exits that does this or can be modified to do this?

Thanks. Andrew
Logged
Adam Twardoch (FontLab)
Product and marketing manager, Fontlab Ltd.
Administrator
Hero Member
*****

Karma: +12/-4
Germany Germany

Posts: 329


FontLab Studio 5.0.4, Mac OS X 10.4.11


WWW
« Reply #1 on: 2011-10-27, 04:37:26 »

Something like this? (In the attachment.)
Logged
Luc[as]
Beta: FontLab Studio Win
Hero Member
***

Karma: +3/-0
Netherlands Netherlands

Posts: 138



WWW
« Reply #2 on: 2011-12-27, 10:11:16 »

The FontLab export Encoding button does already what Adams script does, I have never run into the limit of 255 slots. Is that a bug in a specific build? Andrew, did you try with the FontWindow in index mode? It is also possible to copy all glyphs in the font window and paste into a text editor.
The Encoding file can be used to order all the glyphs (sort by encoding) but I believe Andrew additionally needs an export .nam file, to assign private unicodes. I commisioned a programmer to make this script, and I use it a lot, but in order to use it on another computer, something needs to be installed first that I could not find easily. Adam, maybe you have a "userpath" alternative.

Code:
#FLM: save NAM file FLS5
#by Niels for Luc(as)
from userpath import getuserpath

def unitab(f):
  unis = {}
  for i in range(len(f)):
    g = f[i]
    u = g.unicodes
    for j in u:
      unis[j] = g.name
  return unis

def famname(f):
  return f.pref_family_name

def xx_uniname(f):
  vfb = f.file_name
  dot = vfb.rindex('.')
  return vfb[0:dot] + '.nam'

def uniname(f):
  return '%sMapping\\%s.nam' % (getuserpath(), famname(f))

def saveunicodes(f):
  unis = unitab(f)
  fd = file(uniname(f), "w+")
  fd.write('%%%%FONTLAB NAMETABLE: %s\n' % famname(f))
  keys = unis.keys()
  keys.sort()
  for u in keys:
    fd.write('0x%04X %s\n' % (u,unis[u]))
  fd.close()

saveunicodes(fl.font)
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!