FL.objects.FontLab.FakeLab
- class FL.objects.FontLab.FakeLab
Bases:
objectThe FontLab program interface
The main class. It is used via the pre-instantiated object fl.
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.
Methods
Add(font)Add 'font' to list of opened fonts and open the Font Window for it.
BeginProgress(title, counts)Open a Progress dialog box with 'counts' number of 'ticks'.
CallCommand(commandcode)Simulate a menu or toolbar command.
Close([fontindex])Close the current or fontindex font
EditGlyph([glyphindex])Open the Glyph window for the 'glyphindex' glyph in the current font
Close the Progress dialog box.
ForSelected(function)Call function for each selected glyph in the current font.
GenerateFont(*args)Generate a Font.
Return a
Canvasfor the current Glyph Window.GetConvert(c)Copy conversion parameters from the current Glyph Window to the Canvas.
GetFileName(open_save[, suffix, filename, ...])Open a file picker dialog.
GetPathName(title, message)Show a folder picker.
GlyphToScreen(position)Converts the glyph coordinates of the point to screen coordinates in the current Glyph Window.
HitContour(p)Contour hit detection in the current Glyph Window.
LoadNamFile(namfilename)Lock(lock)Message(message[, question, okstring, ...])Show an alert message dialog box.
Open(filename[, addtolist])Open the font from file using current opening options.
OpenFont(filename)Open a VFB file, or import a font from path filename.
Random(lovalue[, hivalue])(hivalue) | (lovalue, hivalue)
Save(filename_or_fontindex[, filename])(string filename) | (int fontindex, string filename)
ScreenToGlyph(position)Converts the screen coordinates of the point to glyph coordinates in the current Glyph Window.
Select(glyphid[, value])Change a glyph's selection state.
Selected([glyphindex])Return 1 if current glyph or 'glyphindex' glyph is selected.
SetFontWindow(fontindex, position[, state])Set the window size and style for the Font Window where font 'fontindex' is shown.
SetUndo()Save the current state to the undo buffer.
TickProgress(tick)Update the Progress bar, return False if the Cancel button was pressed.
TransformGlyph(glyph, code, text)Transforms the glyph using one of the Transform actions.
Unselect()Deselect all glyphs in the current font (fast operation).
UpdateFont([fontindex])Updates current font or 'fontindex' (slow operation)
UpdateGlyph([glyphindex])Update the current glyph or 'glyphindex' glyph of the current font
UpdateRect(r)Updates the rectangle r in the current Glyph Window.
__init__()Attributes
ifontslistiglyphdeltascalepreviewnumber of opened fonts (fast operation)
number of the selected glyphs in the Font Window (fast operation)
application filename
Return the currently active font or None.
Return the currently active glyph in Font, Glyph or Metrics windows.
Return the index of the currently active font, or -1 if there is no font
Return the index of currently selected object in the Glyph Window.
Return the index of the currently active layer (master) in Glyph or Metrics windows.
Return a reference to FontLab's main window
full path to directory where running application is located
product number
serial number as appears in the About window
Return the type of the currently selected object in the Glyph Window as int.
user name as appears in the About window
application version
reference to the currently active Glyph, Font or Metrics window
- BeginProgress(title: str, counts: int) None
Open a Progress dialog box with ‘counts’ number of ‘ticks’.
- CallCommand(commandcode: int) None
Simulate a menu or toolbar command. Check WS_* constants for list of available commands.
- EditGlyph(glyphindex: int | None = None) None
Open the Glyph window for the ‘glyphindex’ glyph in the current font
- ForSelected(function: Callable[[Font, Glyph, int], None]) None
Call function for each selected glyph in the current font. The function has the following format:
function(font: Font, glyph: Glyph, glyphindex: int)
- GenerateFont(*args: Any) int
Generate a Font.
- Parameters:
- Returns:
0 on success, -1 if the font was not generated.
- Return type:
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)
- GetFileName(open_save: int, suffix: str | None = None, filename: str | None = None, filetype: str | None = None) str
Open a file picker dialog.
- Parameters:
open_save (int) – 0 for a Save dialog, 1 for an Open dialog.
suffix (str | None, optional) – The suggested file suffix. Ignored in Open dialogs. Defaults to None.
filename (str | None, optional) – The suggested file name. Defaults to None.
filetype (str | None, optional) – The suggested file type. Defaults to None.
- Returns:
The path of the selected file.
- Return type:
- GlyphToScreen(position: Point) Point
Converts the glyph coordinates of the point to screen coordinates in the current Glyph Window.
- HitContour(p: Point) tuple[int, int, float] | None
Contour hit detection in the current Glyph Window.
- Parameters:
p (Point) – The point to use for hit detection.
- Returns:
- (nodeindex, nodesubindex, hit_time), or None
if the point doesn’t hit any contour.
- Return type:
- Raises:
RuntimeError – If the current window is not a Glyph Window.
RuntimeError – If no window is open.
- Message(message: str, question: str | None = None, okstring: str | None = None, cancelstring: str | None = None) int
Show an alert message dialog box. All parameters but the first can be omitted.
- Parameters:
- Returns:
- 1 if the OK button was clicked, 2 if the Cancel button was clicked or
the window has been closed.
- Return type:
- Open(filename: str, addtolist: bool = True) None
Open the font from file using current opening options. If addtolist is True, the font is added to FontLab’s font list. The font is shown in a window.
- Parameters:
addtolist seems to be ignored; the font window is always opened. If the file at the path is already opened, it will not be opened again.
- OpenFont(filename: str) Font | None
Open a VFB file, or import a font from path filename. If successful, the Font is returned. The font is not added as a visible Window.
- Random(lovalue: float, hivalue: float | None = None) int
(hivalue) | (lovalue, hivalue)
returns random value (fast operation)
- Save(filename_or_fontindex: str | int, filename: str | None = None) None
(string filename) | (int fontindex, string filename)
Save the current or selected font using standard FontLab’s Save routine.
- ScreenToGlyph(position: Point) Point
Converts the screen coordinates of the point to glyph coordinates in the current Glyph Window.
- Select(glyphid: str | Uni | int, value: bool | None = None) None
Change a glyph’s selection state. ‘glyphid’ may be string (glyph name), Uni (Unicode index) or integer (glyph index)
- Parameters:
- Raises:
RuntimeError – If no font is opened.
- Selected(glyphindex: int | None = None) int
Return 1 if current glyph or ‘glyphindex’ glyph is selected.
- SetFontWindow(fontindex: int, position: Rect, state: int | None = None) None
Set the window size and style for the Font Window where font ‘fontindex’ is shown.
- TickProgress(tick: int) bool
Update the Progress bar, return False if the Cancel button was pressed. This is a relatively ‘expensive’ operation.
- TransformGlyph(glyph: Glyph, code: int, text: str) None
Transforms the glyph using one of the Transform actions.
Save one of Transform Range programs for reference to format of the command string.
- UpdateGlyph(glyphindex: int | None = None) None
Update the current glyph or ‘glyphindex’ glyph of the current font