def find(self, pair, default=0): """ This will find the value for **pair** even if **pair** is not specifically defined. For example: You have a group named `public.kern1.A` with the contents `["A", "Aacute"]` and you have a group named `public.kern2.C` with the contents `["C", "Ccedilla"]`. The only defined kerning is `("public.kern1.A", public.kern2.C) = 100`. If you use this method to find the value for `("A", "Ccedilla")` you will get `100`. """ from defcon.errors import DefconError font = self.font if font is None: raise DefconError("The find method requires a parent font.") glyphToFirstGroup = font.groups.getRepresentation( "defcon.groups.kerningGlyphToSide1Group") glyphToSecondGroup = font.groups.getRepresentation( "defcon.groups.kerningGlyphToSide2Group") return lookupKerningValue(pair, self, font.groups, fallback=default, glyphToFirstGroup=glyphToFirstGroup, glyphToSecondGroup=glyphToSecondGroup)
def _find(self, pair, default=None): """ This is the environment implementation of :attr:`BaseKerning.find`. This must return an :ref:`type-int-float` or `default`. """ from fontTools.ufoLib.kerning import lookupKerningValue font = self.font groups = font.groups return lookupKerningValue(pair, self, groups, fallback=default)
def find(self, pair, default=0): """ This will find the value for **pair** even if **pair** is not specifically defined. For example: You have a group named `public.kern1.A` with the contents `["A", "Aacute"]` and you have a group named `public.kern2.C` with the contents `["C", "Ccedilla"]`. The only defined kerning is `("public.kern1.A", public.kern2.C) = 100`. If you use this method to find the value for `("A", "Ccedilla")` you will get `100`. """ from defcon.errors import DefconError font = self.font if font is None: raise DefconError("The find method requires a parent font.") glyphToFirstGroup = font.groups.getRepresentation("defcon.groups.kerningGlyphToSide1Group") glyphToSecondGroup = font.groups.getRepresentation("defcon.groups.kerningGlyphToSide2Group") return lookupKerningValue(pair, self, font.groups, fallback=default, glyphToFirstGroup=glyphToFirstGroup, glyphToSecondGroup=glyphToSecondGroup)