示例#1
0
def canonical_stylename(font):
    """ Returns the canonical stylename of a given font. """
    from fontbakery.utils import suffix
    from fontbakery.constants import (STATIC_STYLE_NAMES,
                                      VARFONT_SUFFIXES)
    from .shared_conditions import is_variable_font
    from fontTools.ttLib import TTFont

    # remove spaces in style names
    valid_style_suffixes = [name.replace(' ', '') for name in STATIC_STYLE_NAMES]

    filename = os.path.basename(font)
    basename = os.path.splitext(filename)[0]
    s = suffix(font)
    varfont = os.path.exists(font) and is_variable_font(TTFont(font))
    if ('-' in basename and
        (s in VARFONT_SUFFIXES and varfont)
        or (s in valid_style_suffixes and not varfont)):
        return s
def canonical_stylename(font):
  """ Returns the canonical stylename of a given font. """
  from fontbakery.utils import suffix
  from fontbakery.constants import (STATIC_STYLE_NAMES,
                                    VARFONT_SUFFIXES)
  from .shared_conditions import is_variable_font
  from fontTools.ttLib import TTFont

  # remove spaces in style names
  valid_style_suffixes = [name.replace(' ', '') for name in STATIC_STYLE_NAMES]

  filename = os.path.basename(font)
  basename = os.path.splitext(filename)[0]
  s = suffix(font)
  varfont = os.path.exists(font) and is_variable_font(TTFont(font))
  if ('-' in basename and
      (s in VARFONT_SUFFIXES and varfont)
      or (s in valid_style_suffixes and not varfont)):
    return s