MCPcopy Create free account
hub / github.com/PageBot/PageBot / nameMatch

Method nameMatch

Lib/pagebot/fonttoolbox/objects/font.py:647–668  ·  view source on GitHub ↗

Answers level of matching between pattern and the font file name or font.info.fullName. Pattern can be a single string or a list of string. >>> from pagebot.fonttoolbox.fontpaths import getTestFontsPath >>> path = getTestFontsPath() + '/google/roboto/Roboto-Black.ttf

(self, pattern)

Source from the content-addressed store, hash-verified

645 return self.info.familyName != font.info.familyName or self.info.styleName != font.info.styleName
646
647 def nameMatch(self, pattern):
648 """Answers level of matching between pattern and the font file name or
649 font.info.fullName. Pattern can be a single string or a list of
650 string.
651
652 >>> from pagebot.fonttoolbox.fontpaths import getTestFontsPath
653 >>> path = getTestFontsPath() + '/google/roboto/Roboto-Black.ttf'
654 >>> font = getFont(path)
655 >>> font.nameMatch('Black')
656 1.0
657 >>> font.nameMatch('Blackish')
658 0
659 >>> font.nameMatch(('Roboto', 'Black'))
660 1.0
661 """
662 fontName = path2FontName(self.path)
663 if not isinstance(pattern, (list, tuple)):
664 pattern = [pattern]
665 for part in pattern:
666 if not part in fontName:# or part in self.info.fullName):
667 return 0
668 return 1.0
669
670 def weightMatch(self, weight):
671 """Answers level of matching for the (abbreviated) weight name or

Callers 1

matchMethod · 0.95

Calls 1

path2FontNameFunction · 0.90

Tested by

no test coverage detected