# Path: Lib/glyphsLib/builder/constants.py
# GLYPHS_PREFIX = "com.schriftgestaltung."
# 
# GLYPHLIB_PREFIX = GLYPHS_PREFIX + "Glyphs."
# 
# PUBLIC_PREFIX = "public."
# 
# UFO2FT_FEATURE_WRITERS_KEY = "com.github.googlei18n.ufo2ft.featureWriters"
# 
# DEFAULT_FEATURE_WRITERS = [
#     {"class": "KernFeatureWriter", "options": {"mode": "append"}},
#     {"class": "MarkFeatureWriter", "options": {"mode": "skip"}},
# ]
# 
# DEFAULT_LAYER_NAME = PUBLIC_PREFIX + "default"


import os
import posixpath
from .constants import (
    GLYPHS_PREFIX,
    GLYPHLIB_PREFIX,
    PUBLIC_PREFIX,
    UFO2FT_FEATURE_WRITERS_KEY,
    DEFAULT_FEATURE_WRITERS,
    DEFAULT_LAYER_NAME,
)
        from glyphsLib.types import BinaryData



UFO_DATA_KEY = GLYPHLIB_PREFIX + "ufoData"
FONT_USER_DATA_KEY = GLYPHLIB_PREFIX + "fontUserData"
LAYER_LIB_KEY = GLYPHLIB_PREFIX + "layerLib"
LAYER_NAME_KEY = GLYPHLIB_PREFIX + "layerName"
GLYPH_USER_DATA_KEY = GLYPHLIB_PREFIX + "glyphUserData"
NODE_USER_DATA_KEY = GLYPHLIB_PREFIX + "nodeUserData"


def _has_manual_kern_feature(font):
    """Return true if the GSFont contains a manually written 'kern' feature."""
    return any(f for f in font.features if f.name == "kern" and not f.automatic)


def to_designspace_family_user_data(self):
    if self.use_designspace:
        for key, value in dict(self.font.userData).items():
            if _user_data_has_no_special_meaning(key):
                self.designspace.lib[key] = value

        # only write our custom ufo2ft featureWriters settings if the font
        # does have a manually written 'kern' feature; and if the lib key wasn't
        # already set in font.userData (in which case we assume the user knows
        # what she's doing).
        if (
            _has_manual_kern_feature(self.font)
            and UFO2FT_FEATURE_WRITERS_KEY not in self.designspace.lib
        ):

# Path: Lib/glyphsLib/builder/constants.py
# GLYPHS_PREFIX = "com.schriftgestaltung."
# 
# GLYPHLIB_PREFIX = GLYPHS_PREFIX + "Glyphs."
# 
# PUBLIC_PREFIX = "public."
# 
# UFO2FT_FEATURE_WRITERS_KEY = "com.github.googlei18n.ufo2ft.featureWriters"
# 
# DEFAULT_FEATURE_WRITERS = [
#     {"class": "KernFeatureWriter", "options": {"mode": "append"}},
#     {"class": "MarkFeatureWriter", "options": {"mode": "skip"}},
# ]
# 
# DEFAULT_LAYER_NAME = PUBLIC_PREFIX + "default"


# Path: Lib/glyphsLib/builder/user_data.py
import os
import posixpath
from .constants import (
    GLYPHS_PREFIX,
    GLYPHLIB_PREFIX,
    PUBLIC_PREFIX,
    UFO2FT_FEATURE_WRITERS_KEY,
    DEFAULT_FEATURE_WRITERS,
    DEFAULT_LAYER_NAME,
)
        from glyphsLib.types import BinaryData




UFO_DATA_KEY = GLYPHLIB_PREFIX + "ufoData"
FONT_USER_DATA_KEY = GLYPHLIB_PREFIX + "fontUserData"
LAYER_LIB_KEY = GLYPHLIB_PREFIX + "layerLib"
LAYER_NAME_KEY = GLYPHLIB_PREFIX + "layerName"
GLYPH_USER_DATA_KEY = GLYPHLIB_PREFIX + "glyphUserData"
NODE_USER_DATA_KEY = GLYPHLIB_PREFIX + "nodeUserData"


def _has_manual_kern_feature(font):
    """Return true if the GSFont contains a manually written 'kern' feature."""
    return any(f for f in font.features if f.name == "kern" and not f.automatic)


def to_designspace_family_user_data(self):
    if self.use_designspace:
        for key, value in dict(self.font.userData).items():
            if _user_data_has_no_special_meaning(key):
                self.designspace.lib[key] = value

        # only write our custom ufo2ft featureWriters settings if the font
        # does have a manually written 'kern' feature; and if the lib key wasn't
        # already set in font.userData (in which case we assume the user knows
        # what she's doing).
        if (
            _has_manual_kern_feature(self.font)
            and UFO2FT_FEATURE_WRITERS_KEY not in self.designspace.lib
        ):

            self.designspace.lib[UFO2FT_FEATURE_WRITERS_KEY] = DEFAULT_FEATURE_WRITERS