Skip to content

Commit

Permalink
Add font.compact() to Python API
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlcctrlv committed Sep 8, 2020
1 parent 8d961b9 commit c5ef422
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/sphinx/scripting/python/fontforge.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4867,6 +4867,10 @@ See the :class:`selection` type for how to alter the selection.

Clears the contents of all selected glyphs

.. method:: font.compact()

Compacts the font's encoding

.. method:: font.cluster([within, max])

Moves clustered coordinates to a standard central value in all selected
Expand Down
10 changes: 10 additions & 0 deletions fontforge/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -17128,6 +17128,15 @@ return (NULL);
Py_RETURN(self);
}

static PyObject *PyFFFont_compact(PyFF_Font *self, PyObject *UNUSED(args)) {
FontViewBase *fv;
if ( CheckIfFontClosed(self) )
return (NULL);
fv = self->fv;
FVCompact(fv);
Py_RETURN(self);
}

static PyObject *PyFFFont_cut(PyFF_Font *self, PyObject *UNUSED(args)) {
FontViewBase *fv;
if ( CheckIfFontClosed(self) )
Expand Down Expand Up @@ -18047,6 +18056,7 @@ PyMethodDef PyFF_Font_methods[] = {
{ "glyphs", (PyCFunction) PyFFFont_glyphs, METH_VARARGS, "Returns an iterator over all glyphs" },
/* Selection based */
{ "clear", (PyCFunction) PyFFFont_clear, METH_NOARGS, "Clears all selected glyphs" },
{ "compact", (PyCFunction) PyFFFont_compact, METH_NOARGS, "Compacts the font's encoding" },
{ "cut", (PyCFunction) PyFFFont_cut, METH_NOARGS, "Cuts all selected glyphs" },
{ "copy", (PyCFunction) PyFFFont_copy, METH_NOARGS, "Copies all selected glyphs" },
{ "copyReference", (PyCFunction) PyFFFont_copyReference, METH_NOARGS, "Copies all selected glyphs as references" },
Expand Down

0 comments on commit c5ef422

Please sign in to comment.