当前位置: 首页>>代码示例>>Python>>正文


Python fontforge.font方法代码示例

本文整理汇总了Python中fontforge.font方法的典型用法代码示例。如果您正苦于以下问题:Python fontforge.font方法的具体用法?Python fontforge.font怎么用?Python fontforge.font使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fontforge的用法示例。


在下文中一共展示了fontforge.font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_font_max_size_info

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def _get_font_max_size_info(font, start, end):
    """return size information for biggest glyph
    :param fontforge.font font: font object
    :param int start: unicode start point
    :param int end: unicode end point
    :return GlyphSizeInfo: biggest glyph size info"""
    info = None
    for code in range(start, end + 1):
        try:
            _info = get_glyph_size_info(font[code])
            if info is None:
                info = _info
                continue
            for key in dir(_info):
                a = getattr(_info, key)
                b = getattr(info, key)
                if abs(a) > abs(b):
                    setattr(info, key, a)
        except TypeError:
            continue
    return info 
开发者ID:iij,项目名称:fontmerger,代码行数:23,代码来源:fontmerger.py

示例2: get_font_name_info

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def get_font_name_info(font):
    """return font name information
    :param fontforge.font font: a font object
    :return tuple of (font name, font family name, full name, sub-family name)"""
    family = font.familyname
    fullname = font.fullname
    sub_family = 'Regular'
    name = font.fontname
    _, fallback_style = re.match('^([^-]*).*?([^-]*(?!.*-))$', name).groups()
    try:
        sub_family_tuple_index = [x[1] for x in font.sfnt_names].index('SubFamily')
        sub_family = font.sfnt_names[2][sub_family_tuple_index]
    except IndexError:
        pass
    if sub_family == 'Regular':
        sub_family = fallback_style
    family = re.sub(r'[ _-]?{0}$'.format(sub_family), '', family, flags=re.IGNORECASE)
    fullname = re.sub(r'[ _-]?{0}$'.format(sub_family), '', fullname, flags=re.IGNORECASE)
    name = re.sub(r'[ _-]?{0}$'.format(sub_family), '', name, flags=re.IGNORECASE)
    return name, family, fullname, sub_family 
开发者ID:iij,项目名称:fontmerger,代码行数:22,代码来源:fontmerger.py

示例3: copy

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def copy(self, aParent=None):
        """Make a copy of this glyph.
        Note: the copy is not a duplicate fontlab glyph, but
        a RF RGlyph with the same outlines. The new glyph is
        not part of the fontlab font in any way. Use font.appendGlyph(glyph)
        to get it in a FontLab glyph again."""
        from robofab.objects.objectsRF import RGlyph as _RGlyph
        newGlyph = _RGlyph()
        newGlyph.appendGlyph(self)
        for attr in GLYPH_COPY_ATTRS:
            value = getattr(self, attr)
            setattr(newGlyph, attr, value)
        parent = self.getParent()
        if aParent is not None:
            newGlyph.setParent(aParent)
        elif self.getParent() is not None:
            newGlyph.setParent(self.getParent())
        return newGlyph 
开发者ID:rsms,项目名称:inter,代码行数:20,代码来源:objectsFF.py

示例4: __repr__

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def __repr__(self):
        font = "unnamed_font"
        glyph = "unnamed_glyph"
        contourIndex = "unknown_contour"
        contourParent = self.getParent()
        if contourParent is not None:
            try:
                contourIndex = `contourParent.index`
            except AttributeError: pass
            glyphParent = contourParent.getParent()
            if glyphParent is not None:
                try:
                    glyph = glyphParent.name
                except AttributeError: pass
                fontParent = glyphParent.getParent()
                if fontParent is not None:
                    try:
                        font = fontParent.info.fullName
                    except AttributeError: pass
        return "<RPoint for %s.%s[%s]>"%(font, glyph, contourIndex) 
开发者ID:rsms,项目名称:inter,代码行数:22,代码来源:objectsFF.py

示例5: save

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def save(self, path=None):
        """Save this font as sfd file.
        XXX: how to set a sfd path if is none
        """
        if path is not None:
            # trying to save it somewhere else
            _path = path
        else:
            _path = self.path
        if os.path.splitext(_path)[-1] != ".sfd":
            _path = os.path.splitext(_path)[0]+".sfd"
        if __DEBUG__:
            print "RFont.save() to", _path
        self._object.save(_path) 
开发者ID:rsms,项目名称:inter,代码行数:16,代码来源:objectsFF.py

示例6: __init__

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def __init__(self, font):
        """Font's size hints
        :param fontforge.font font: a font object"""
        self.font = font
        self._half = None
        self._full = None
        self.ascent = font.hhea_ascent
        self.descent = font.hhea_descent 
开发者ID:iij,项目名称:fontmerger,代码行数:10,代码来源:fontmerger.py

示例7: half

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def half(self):
        """returns size info for half-width font
        :return GlyphSizeInfo: glyph's size info"""
        if not self._half:
            self._half = _get_font_max_size_info(self.font, 0x23, 0x7e)
        return self._half 
开发者ID:iij,项目名称:fontmerger,代码行数:8,代码来源:fontmerger.py

示例8: full

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def full(self):
        """returns size info for full-width font
        :return: GlyphSizeInfo: glyph's size info
        """
        if not self._full:
            self._full = _get_font_max_size_info(self.font, 0xff01, 0xff5e)
        return self._full 
开发者ID:iij,项目名称:fontmerger,代码行数:9,代码来源:fontmerger.py

示例9: display_unicode_utf8

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def display_unicode_utf8(ctx, fd=sys.stdout):
    """display unicode characters as UTF-8
    :param MergingContext ctx: a merging font context
    :param file fd: display target"""
    font = fontforge.open(ctx.filename)
    unicode_range = ctx.unicode_range
    start = 0
    end = 0
    if len(unicode_range) >= 1:
        start = int(unicode_range[0], 16)
    if len(unicode_range) >= 2:
        end = int(unicode_range[1], 16)
    remap_start_point = ctx.remap_start_point
    delta = 0
    if remap_start_point is not None:
        delta = int(remap_start_point, 16) - start
    if start is 0:
        font.selection.all()
    else:
        font.selection.select(('ranges', 'unicode'), start, end)
    length = 0
    line = ''
    fd.write('{0:-^80}\n'.format(' ' + ctx.id + ' '))
    for glyph in list(font.selection.byGlyphs):
        line += unichr(glyph.encoding + delta)
        info = get_glyph_size_info(glyph)
        if info.width <= font.em / 2:
            # half width
            line += ' '
        length += 1
        if length is 40:
            fd.write(line.encode('utf-8') + '\n')
            length = 0
            line = ''
    if length > 0:
        fd.write(line.encode('utf-8') + '\n')
    fd.flush()
    font.close() 
开发者ID:iij,项目名称:fontmerger,代码行数:40,代码来源:fontmerger.py

示例10: get_height

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def get_height(font):
    """return font height
    :param fontforge.font font: a font object
    :return font height"""
    return font.hhea_ascent + abs(font.hhea_descent) 
开发者ID:iij,项目名称:fontmerger,代码行数:7,代码来源:fontmerger.py

示例11: NewFont

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def NewFont(fontPath=None):
    _font = fontforge.font()
    if __DEBUG__:
        print "NewFont", fontPath
        print "result:", _font
    return RFont(_font) 
开发者ID:rsms,项目名称:inter,代码行数:8,代码来源:objectsFF.py

示例12: __init__

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def __init__(self, font=None):
        if font is None:
            # make a new font
            pass
        else:
            self._object = font
    
    # -----------------------------------------------------------------
    #
    #   access 
开发者ID:rsms,项目名称:inter,代码行数:12,代码来源:objectsFF.py

示例13: keys

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def keys(self):
        """FF implements __iter__ for the font object - better?"""
        return [n.glyphname for n in self._object.glyphs()] 
开发者ID:rsms,项目名称:inter,代码行数:5,代码来源:objectsFF.py

示例14: getGlyph

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def getGlyph(self, glyphName):
        try:
            ffGlyph = self._object[glyphName]
        except TypeError:
            print "font.getGlyph, can't find glyphName, returning new glyph"
            return self.newGlyph(glyphName)
        glyph = RGlyph(ffGlyph)
        glyph.setParent(self)
        return glyph 
开发者ID:rsms,项目名称:inter,代码行数:11,代码来源:objectsFF.py

示例15: _get_mark

# 需要导入模块: import fontforge [as 别名]
# 或者: from fontforge import font [as 别名]
def _get_mark(self):
        """color of the glyph box in the font view. This accepts a 6 hex digit number.
        
        XXX the FL implementation accepts a 
        """
        import colorsys
        r = (self._object.color&0xff0000)>>16
        g = (self._object.color&0xff00)>>8
        g = (self._object.color&0xff)>>4
        return colorsys.rgb_to_hsv( r, g, b)[0] 
开发者ID:rsms,项目名称:inter,代码行数:12,代码来源:objectsFF.py


注:本文中的fontforge.font方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。