Exemple #1
0
def familyNames(familyID, subFamilyID=0):
    """Convert family integers to human-readable names"""
    familyName, subFamilies = FAMILY_NAMES.get(familyID, ('RESERVED', None))
    if familyName == 'RESERVED':
        if text_log:
            text_log.warn('Font has invalid (reserved) familyID: %s', familyID)
    if subFamilies:
        subFamily = subFamilies.get(subFamilyID, 'RESERVED')
    else:
        subFamily = 'ANY'
    return (familyName, subFamily)
Exemple #2
0
def familyNames(familyID, subFamilyID=0):
    """Convert family integers to human-readable names"""
    familyName, subFamilies = FAMILY_NAMES.get(familyID, ("RESERVED", None))
    if familyName == "RESERVED":
        if text_log:
            text_log.warn("Font has invalid (reserved) familyID: %s", familyID)
    if subFamilies:
        subFamily = subFamilies.get(subFamilyID, "RESERVED")
    else:
        subFamily = "ANY"
    return (familyName, subFamily)
Exemple #3
0
def familyNames( familyID, subFamilyID=0 ):
	"""Convert family integers to human-readable names"""
	familyName, subFamilies = FAMILY_NAMES.get( familyID, ('RESERVED',None))
	if familyName == 'RESERVED':
		if text_log:
			text_log.warn( 'Font has invalid (reserved) familyID: %s', familyID )
	if subFamilies:
		subFamily = subFamilies.get(subFamilyID, 'RESERVED')
	else:
		subFamily = 'ANY'
	return (
		familyName,
		subFamily
	)
Exemple #4
0
def glyphName(font, char, encoding=None, warnOnFailure=1):
    """Retrieve the glyph name for the given character

    XXX
        Not sure what the effect of the Unicode mapping
        will be given the use of ord...
    """
    glyfName = explicitGlyph(font, char, encoding)
    if glyfName is None:
        encoding = describe.guessEncoding(font)  #KH
        cmap = font['cmap']  #KH
        table = cmap.getcmap(*encoding)  #KH
        glyfName = table.cmap.get(-1)
        if glyfName is None:
            glyfName = font['glyf'].glyphOrder[0]
            if text_log and warnOnFailure:
                text_log.warn(
                    """Unable to find glyph name for %r, in %r using first glyph in table (%r)""",
                    char, describe.shortName(font), glyfName)
    return glyfName
Exemple #5
0
def glyphName( font, char, encoding=None, warnOnFailure=1 ):
    """Retrieve the glyph name for the given character

    XXX
        Not sure what the effect of the Unicode mapping
        will be given the use of ord...
    """
    glyfName = explicitGlyph( font, char, encoding )
    if glyfName is None:
        encoding = describe.guessEncoding( font )       #KH
        cmap = font['cmap']                             #KH
        table = cmap.getcmap( *encoding )               #KH
        glyfName = table.cmap.get( -1)
        if glyfName is None:
            glyfName = font['glyf'].glyphOrder[0]
            if text_log and warnOnFailure:
                text_log.warn(
                    """Unable to find glyph name for %r, in %r using first glyph in table (%r)""",
                    char,
                    describe.shortName(font),
                    glyfName
                )
    return glyfName