Try bounding indices in bdf->glyphs by bdf->glyphcnt in order to avoid crashes.
Add additional guards copied from @tshinnic.
Map U. F. O. version values to the native FontForge version string.
Preserve glif names.
Stop reversing the order of references and anchors when importing U. F. O..
Add multi-layer U. F. O. output.
Avoid exporting the default background layer if it's completely empty and was not listed in the input U. F. O..
Make lib data in U. F. O. glyphs layer-specific.
Fix a few problems revealed during testing.
Merge branch 'master' into ufo_fontinfo_missing_entries_1
Python 3 compatibility error: font.printSample()

In FontForge built with Python 3, script API font.printSample() would
reject calls displaying error messages such as:
      TypeError: expected bytes, str found
for any of the arguments accepting strings - the initial, third and
fourth arguments.

This problem not seen running FontForge built with Python 2.

The code had never been converted to be compatible with Python 3, and
was still using PyBytes_* routines to handle strings.  Changed to use
PyArg_ParseTuple() to handle required and optional arguments, while
checking argument types and counts.

Fixed a small gotcha about for reference counting and the use of
PySequence_GetItem().  Also improved the user-directed error messages
for problems with input arguments.

Thoroughly tested with all variations on argument types and counts.
(~280 lines of Python code to test API signature)
Python 3 compatibility: glyph.getPosSub() glyph.removePosSub()

In FontForge built with Python 3, script APIs glyph.getPosSub()
and glyph.removePosSub() would reject all calls displaying error
messages such as:
      TypeError: expected bytes, str found

This problem not seen running FontForge built with Python 2.

The code had never been converted to be compatible with Python 3, and
was still using PyBytes_* routines to handle strings.  Changed to use
PyArg_ParseTuple() to handle the single argument.

Tested with variations on argument types and counts.  API _function_
was not tested.
Python API fails: font.size_feature (getter)

When full 'size' information is present for a font (the 5 value tuple), then
    data = font.size_feature
would fail with an internally-generated Python exception complaining:
      IndexError: tuple assignment index out of range

The code was calling PyTuple_SetItem() using the wrong variable to index into
the new tuple.

This API was unlikely to have ever worked when full 'size' information
was present.  When language info was absent, then only a single value
'design_size' was correctly returned using a different code path.

However, this GPOS 'size' feature apparently had little industry acceptance,
and so not working was likely not a problem...?

Tested with several different 'size' values as set during testing of the setter.
Python API fails: font.size_feature (setter)

Fixed errors:

  Replaced Python2-correct usage of PyBytes_AsString() with the version
  compatibility macros PYGETSTR() and ENDPYGETSTR().  This fixed this
  error seen under Python 3 on second string of (lang,name) pair:
          TypeError: expected bytes, str found

  Checking for whether argument/sub-arguments were the expected tuple or
  list used the check for 'sequences'.  A string is also a sequence,
  making for strange error messages on user goofs.  Changed to check more
  specifically for list or tuple types.

Other changes:

  Improved some error messages from problems with user calling arguments.

  Desire was to allow caller to request that the 'size' value should be
  deleted.  Apparently the existing coded check was only for use of
        del font.size_feature
  Added ability to say
        font.size_feature = None

  Added Py_DECREF()s to pair with PySequence_GetItem() calls as documented
  by Python, but unfortunately not everyplace needed in this code.

However, this GPOS 'size' feature apparently had little industry acceptance,
and so problems with it was likely not a problem...?
Fix a problem with dropped references.
Add more bitmap guards.
Remove a duplicate call to BCPrepareForOutput.
Python: minor -Wall complaints

Fix two "unused variable" warnings by removing those declarations.
Python 3 compatibilty error: glyph.glyphclass setter

In FontForge built with Python 3, script API glyph.glyphclass=...
would reject calls to set a new glyph class name string, with error:
      TypeError: expected bytes, str found

This problem not seen running FontForge built with Python 2.

The code had not been converted to be compatible with Python 3 strings
and was still using the Python 2-compatible PyBytes_* APIs.

Tested with variations on argument types and values.
Handle missing references in U. F. O. when there is no previous reference.