FontLab
===============================================
FontLab - class to represent FontLab program interface
===============================================
You can access members of this class using object 'fl'
CONSTRUCTOR
There is no explicit constructor for this class, use pre-initialized object 'fl'
Always use "from FL import all" at the beginning of your macro. (Expanded description)
ATTRIBUTES
font(Font) - read-only - currently active font
ifont(integer) - index of currently active font
ifontslist(integer) - index of currently selected font in the fonts list panel
glyph(Glyph) - read-only - currently active glyph in
Font, Glyph or Metrics windows
iglyph(integer) - index of currently active glyph
tobject(integer) - read-only - type of the currently selected object
in the Glyph Window
iobject(integer) - read-only - index of currently selected object in
the Glyph Window
mainwindow(integer) - read-only - reference to FontLab's main window
path(string) - read-only - full path to directory where running
application is located
filename(string) - read-only - application filename
version(string) - read-only - application version
productnumber(integer) - read-only - product number
serialnumber(string) - read-only - serial number as appears in the About window
username(string) - read-only - user name as appears in the About window
count(integer) - read-only - number of opened fonts (fast operation)
count_selected(integer) - read-only - number of the selected glyphs
in the Font Window (fast operation)
window(integer) - reference to the currently active Glyph,
Font or Metrics window
delta(Point) - delta value of current coordinate translation
in the active Glyph Window
scale(Point(float)) - scale value of current coordinate translation
in the active Glyph Window
tablet_active(boolean) - True if tablet is present and active
tablet_pressure(integer) - current tablet's pen pressure
preview(string) - contents of the preview panel (not reported by docstring)
OPERATIONS
len() - returns number of opened fonts
[] - returns Font by index
METHODS
Close() | (fontindex) - closes the current or 'fontindex' font
Open(string filename) | (string filename, boolean addtolist)
- opens the font from file using current opening options.
If 'addtolist' is True, font is added to FontLab's font list
Save(string filename) | (int fontindex, string filename)
- saves the current or selected font
using strandard FontLab's Save routine
GenerateFont(fontType, filename)
- generates Font, available font types:
ftFONTLAB - FontLab VFB font
ftTYPE1 - PC Type 1 font (binary/PFB)
ftTYPE1_MM - PC MultipleMaster font (PFB)
ftTYPE1ASCII - PC Type 1 font (ASCII/PFA)
ftTYPE1ASCII_MM - PC MultipleMaster font (ASCII/PFA)
ftTRUETYPE - PC TrueType/TT OpenType font (TTF)
ftOPENTYPE - PS OpenType (CFF-based) font (OTF)
ftMACTYPE1 - Mac Type 1 font (generates suitcase
and LWFN file, optionally AFM)
ftMACTRUETYPE - Mac TrueType font (generates suitcase)
ftMACTRUETYPE_DFONT - Mac TrueType font (generates suitcase with
resources in data fork)
(Since FL 4.52 Mac and FL 4.53 Win, this method is implemented
in the FontLab class. In FontLab 4.5 and 4.51 for Mac,
GenerateFont was a method of the Font class but
that has been deprecated. )
Add(Font font) - adds 'font' to list of opened fonts and opens
the Font Window for it
UpdateFont() | (fontindex) - updates current font or 'fontindex' (slow operation)
SetFontWindow(fontindex, Rect position, state)
- sets window size and style for Font Window
here font 'fontindex' is presented
UpdateGlyph() | (glyphindex) - updates current or 'glyphindex' glyph of the current font
EditGlyph() | (glyphindex) - opens the Glyph window for the 'glyphindex' glyph
in the current font
CallCommand(commandcode) - simulates the menu or toolbar command.
Check WS_* constants for list of available commands
Selected() | (glyphindex) - returns True if current glyph or 'glyphindex' glyph is selected
Select(glyphid) | (glyphid, value)
- changes glyph's selection state.
'glyphid' may be string (glyph name),
Uni (Unicode index) or integer (glyph index)
Unselect() - deselects all glyphs in the current font (fast operation)
Message(string message, string question, string OKstring, string Cancelstring)
- shows the alert message dialog box,
all parameters but first can be omitted
ScreenToGlyph(Point position) - converts screen coordinates to glyph
coordinates in the current Glyph Window
GlyphToScreen(Point position) - converts glyph coordinates to screen
coordinates in the current Glyph Window
UpdateRect(Rect r) - updates rectangle in the current Glyph Window
HitContour(Point p) - contour hit detection in the current Glyph Window -
returns tuple of (nodeindex, nodesubindex, hit_time)
GetCanvas() - returns Canvas for the current Glyph Window
GetConvert(Canvas c) - copies conversion parameters from the current
Glyph Window to the Canvas c
BeginProgress(string title, counts)
- opens the Progress dialog box with. 'counts' - number of 'ticks'
TickProgress(tick) - updates the Progress bar,
returns False if Cancel button was pressed.
This is relatively 'expensive' operation
EndProgress() - closes the Progress dialog box
Random(hivalue) | (lovalue, hivalue) - returns random value (fast operation)
TransformGlyph(glyph, code, text)
- transforms the glyph using one of the Transform actions.
Save one of Transform Range programs for reference to
format of the command string
ForSelected(string function_name)
- calls 'function_name' for each selected glyph in the current
font. Function has following format:
function(Font font, Glyph glyph, glyphindex)
SetUndo() - save current state to undo buffer
(this method is not reported by the docstring)