Exemplo n.º 1
0
 def test_regular_isBold(self):
     map_family, map_style = build_stylemap_names(family_name="NotoSans",
                                                  style_name="Regular",
                                                  is_bold=True,
                                                  is_italic=False,
                                                  linked_style=None)
     self.assertEqual("NotoSans Regular", map_family)
     self.assertEqual("bold", map_style)
Exemplo n.º 2
0
 def test_bold_italic(self):
     map_family, map_style = build_stylemap_names(family_name="NotoSans",
                                                  style_name="Bold Italic",
                                                  is_bold=True,
                                                  is_italic=True,
                                                  linked_style=None)
     self.assertEqual("NotoSans", map_family)
     self.assertEqual("bold italic", map_style)
Exemplo n.º 3
0
 def test_linked_style_regular(self):
     map_family, map_style = build_stylemap_names(family_name="NotoSans",
                                                  style_name="Condensed",
                                                  is_bold=False,
                                                  is_italic=False,
                                                  linked_style="Cd")
     self.assertEqual("NotoSans Cd", map_family)
     self.assertEqual("regular", map_style)
Exemplo n.º 4
0
 def test_non_regular(self):
     map_family, map_style = build_stylemap_names(family_name="NotoSans",
                                                  style_name="ExtraBold",
                                                  is_bold=False,
                                                  is_italic=False,
                                                  linked_style=None)
     self.assertEqual("NotoSans ExtraBold", map_family)
     self.assertEqual("regular", map_style)
Exemplo n.º 5
0
    def test_incomplete_bold_italic(self):
        map_family, map_style = build_stylemap_names(
            family_name="NotoSans",
            style_name="Bold",  # will be stripped...
            is_bold=True,
            is_italic=True,
            linked_style=None)
        self.assertEqual("NotoSans", map_family)
        self.assertEqual("bold italic", map_style)

        map_family, map_style = build_stylemap_names(
            family_name="NotoSans",
            style_name="Italic",  # will be stripped...
            is_bold=True,
            is_italic=True,
            linked_style=None)
        self.assertEqual("NotoSans", map_family)
        self.assertEqual("bold italic", map_style)
Exemplo n.º 6
0
 def test_bold_italic_no_style_link(self):
     map_family, map_style = build_stylemap_names(
         family_name="NotoSans",
         style_name="Bold Italic",
         is_bold=False,  # not style-linked, despite the name
         is_italic=False,  # not style-linked, despite the name
         linked_style=None)
     self.assertEqual("NotoSans Bold Italic", map_family)
     self.assertEqual("regular", map_style)
Exemplo n.º 7
0
def add_instances_to_writer(writer, family_name, axes, instances, out_dir):
    """Add instances from Glyphs data to a MutatorMath document writer.

    Returns a list of <ufo_path, font_data> pairs, corresponding to the
    instances which will be output by the document writer. The font data is the
    Glyphs data for this instance as a dict.
    """
    ofiles = []
    for instance in instances:
        familyName, postScriptFontName, ufo_path = None, None, None
        for p in instance.customParameters:
            param, value = p.name, p.value
            if param == 'familyName':
                familyName = value
            elif param == 'postscriptFontName':
                # Glyphs uses "postscriptFontName", not "postScriptFontName"
                postScriptFontName = value
            elif param == 'fileName':
                ufo_path = os.path.join(out_dir, value + '.ufo')
        if familyName is None:
            familyName = family_name

        styleName = instance.name
        if not ufo_path:
            ufo_path = build_ufo_path(out_dir, familyName, styleName)
        ofiles.append((ufo_path, instance))
        # MutatorMath.DesignSpaceDocumentWriter iterates over the location
        # dictionary, which is non-deterministic so it can cause test failures.
        # We therefore use an OrderedDict to which we insert in axis order.
        # Since glyphsLib will switch to DesignSpaceDocument once that is
        # integrated into fonttools, it's not worth fixing upstream.
        # https://github.com/googlei18n/glyphsLib/issues/165
        location = OrderedDict()
        for axis in axes:
            location[axis] = getattr(instance, 'interpolation' + axis.title(),
                                     DEFAULT_LOCS[axis])
        styleMapFamilyName, styleMapStyleName = build_stylemap_names(
            family_name=familyName,
            style_name=styleName,
            is_bold=instance.isBold,
            is_italic=instance.isItalic,
            linked_style=instance.linkStyle,
        )
        writer.startInstance(name=' '.join((familyName, styleName)),
                             location=location,
                             familyName=familyName,
                             styleName=styleName,
                             postScriptFontName=postScriptFontName,
                             styleMapFamilyName=styleMapFamilyName,
                             styleMapStyleName=styleMapStyleName,
                             fileName=ufo_path)

        writer.writeInfo()
        writer.writeKerning()
        writer.endInstance()

    return ofiles
Exemplo n.º 8
0
 def test_linked_style_italic(self):
     map_family, map_style = build_stylemap_names(
         family_name="NotoSans",
         style_name="Condensed Italic",
         is_bold=False,
         is_italic=True,
         linked_style="Cd",
     )
     self.assertEqual("NotoSans Cd", map_family)
     self.assertEqual("italic", map_style)