# `GSApplication`

The mothership. Everything starts here.

    print(App)

    <EditGlyphData.app>

class GSApplication

  `currentDocument` |
  `documents` |
  `versionString` |
  `versionNumber` |
  `buildNumber` |
  `menu` |

  `open`() |
  `showMacroWindow`() |
  `clearLog`() |
  `showNotification`() |

  Properties

  currentDocument

    The active `GSDocument` object or None.

    Type:

      `GSDocument`

        # topmost open document
        document = Glyphs.currentDocument

  documents

    An array of open `GSDocument` objects.

    Type:

      list

  defaults

    A dict like object for storing preferences. You can get and set key-value pairs.

    Please be careful with your keys. Use a prefix that uses the reverse domain name. e.g. “com.MyName.foo.bar”.

        # Check for whether or not a preference exists, because has_key() doesn't work in this PyObjC-brigde
        if App.defaults["com.MyName.foo.bar"] is None:
        # do stuff
        # Get and set values
        value = App.defaults["com.MyName.foo.bar"]
        App.defaults["com.MyName.foo.bar"] = newValue
        # Remove value
        # This will restore the default value
        del(App.defaults["com.MyName.foo.bar"])

  versionString

    String containing EditGlyphData.app’s version number. May contain letters also, like ‘2.3b’. To check for a specific version, use `versionNumber`.

    Type:

      string

  versionNumber

    EditGlyphData.app’s version number. Use this to check for version in your code.

    Type:

      float

  buildNumber

    EditGlyphData.app’s build number.

    Especially if you’re using preview builds, this number may be more important to you than the version number. The build number increases with every released build and is the most significant evidence of new EditGlyphData versions, while the version number is set arbitrarily and stays the same until the next stable release.

    Type:

      int

  menu

    Add menu items to EditGlyphDatas main menus.

    Following constants for accessing the menus are defined: `APP_MENU`, `FILE_MENU`, `EDIT_MENU`, `GLYPH_MENU`, `PATH_MENU`, `FILTER_MENU`, `VIEW_MENU`, `SCRIPT_MENU`, `WINDOW_MENU`, `HELP_MENU`

        def doStuff(sender):
        # do stuff
        newMenuItem = NSMenuItem('My menu title', doStuff)
        Glyphs.menu[EDIT_MENU].append(newMenuItem)

  Functions

  open(path[, showInterface=True])

    Opens a document

    Parameters:

      - path (str) – The path where the document is located.

      - showInterface (bool) – If a document window should be opened. Default: True

    Returns:

      The opened document object or None.

    Return type:

      `GSDocument`

  showMacroWindow()

    Opens the macro window

  clearLog()

    Deletes the content of the console in the macro window

  showNotification(title, message)

    Shows the user a notification in Mac’s Notification Center.

        App.showNotification('Export fonts', 'The export of the fonts was successful.')

# `GSDocument`

The document class

class GSDocument

  `infos` |
  `fileVersion` |
  `selectedInfos` |

  Properties

  infos

    An array of `GSGlyphInfo` objects.

        doc.infos[index]
        doc.infos[name]
        for info in Font.infos:
        ...

    Type:

      list

  fileVersion

    The file version

    Type:

      int

  selectedInfos

    A list of all selected info objects

    Type:

      list

# `GSGlyphInfo`

This contains valuable information from the glyph database.

class GSGlyphInfo

  `name` |
  `productionName` |
  `category` |
  `subCategory` |
  `marks` |
  `anchors` |
  `unicode` |
  `unicodes` |
  `unicodeLegacy` |
  `script` |
  `direction` |
  `mirror` |
  `sortName` |
  `sortNameKeep` |
  `desc` |
  `altNames` |
  `decompose` |
  `deprecated` |
  `index` |

  `generateUniName`() |

      info = GSGlyphInfo()
      info.name = "myGlyphName"

  Properties

  name

    Human-readable name (“nice name”).

    Type:

      str

  productionName

    Production name. Will return a value only if production name differs from nice name, otherwise None.

    Type:

      str

  category

    This is mostly from the UnicodeData.txt file from unicode.org. Some corrections have been made (Accents, …) e.g: “Letter”, “Number”, “Punctuation”, “Mark”, “Separator”, “Symbol” or “Other”

    Type:

      str

  subCategory

    The subCategory of the glyph. e.g. ‘Currency’, ‘Math’

    Type:

      str

  decompose

    This glyph may be composed of the glyphs returned as a list of `GSGlyphInfo` objects.

    Type:

      list

  marks

    This glyph may be combined with these accents, returned as a list of glyph names.

    Type:

      list

  anchors

    Anchors defined for this glyph, as a list of anchor names.

    Type:

      list

  unicode

    the first Unicode value. READ ONLY

    Type:

      str

  unicodes

    a unicodes values

    Type:

      list

  unicodeLegacy

    a unicode that is only stored for historic reasons and should not be used any more

    Type:

      str

  script

    Script of glyph, e.g: “latin”, “cyrillic”, “greek”.

    Type:

      str

  case

    e.g: GSUppercase, GSLowercase, GSSmallcaps, GSMinor, GSNoCase

    Type:

      int

  index

    index of glyph in database. Used for sorting in UI.

    Type:

      str

  sortName

    Alternative name of glyph used for sorting in UI.

    Type:

      str

  sortNameKeep

    Alternative name of glyph used for sorting in UI, when using ‘Keep Alternates Next to Base Glyph’ from Font Info.

    Type:

      str

  desc

    Unicode description of glyph.

    Type:

      str

  altNames

    Alternative names for glyphs that are not used, but should be recognized (e.g., for conversion to nice names).

    Type:

      str

  direction

    Writing direction.

    See Writing Directions

    Type:

      integer

        glyph.direction = GSRTL

  Functions

  generateUniName()
  sets the produciton name from the unicode
  mirror

    The corresponding unicode of the glyph that is used when in RLT

    Type:

      str

  deprecated

    If that info is deprecated

    Type:

      bool

GetSaveFile(message=None, proposedFileName=None, filetypes=None)

  Opens a file chooser dialog.

  Parameters:

    - message –

    - filetypes –

    - proposedFileName –

  Returns:

    The selected file or None

  Return type:

    str

GetOpenFile(message=None, allowsMultipleSelection=False, filetypes=None)

  Opens a file chooser dialog.

  Parameters:

    - message – A message string.

    - allowsMultipleSelection – Boolean, True if user can select more than one file

    - filetypes – list of strings indicating the filetypes, e.g., [“gif”, “pdf”]

    - path – The initial directory path

  Returns:

    The selected file or a list of file names or None

  Return type:

    str or list

GetFolder(message=None, allowsMultipleSelection=False)

  Opens a folder chooser dialog.

  Parameters:

    - message –

    - allowsMultipleSelection –

    - path –

  Returns:

    The selected folder or None

  Return type:

    str

Message(title, message, OKButton=None)

  Shows an alert panel.

  Parameters:

    - title –

    - message –

    - OKButton –

LogToConsole(message)

  Write a message to the Mac’s Console.app for debugging.

  Parameters:

    message –

LogError(message)

  Log an error message and write it to the Macro window’s output (in red).

  Parameters:

    message –

# Writing Directions

The writing directions of the Edit View.

GSBIDI

  for characters that follow the main writing direction (like punctuation)

GSLTR

  Left to Right (e.g. Latin)

GSRTL

  Right to Left (e.g. Arabic, Hebrew)

GSVertical

  Top to Bottom, Right to Left (e.g. Chinese, Japanese, Korean)

GSVerticalToRight

  Top to Bottom, Left to Right (e.g. Mongolian)