Example #1
0
def paintGroups(font):
    if len(font.groups) > 0:
        groups_order = font.groups.keys()
        #groups_order.sort()
        colorStep = 1.0 / len(groups_order)
        color = 0
        glyphs_order = []
        print 'painting glyph groups...\n'
        for group_name in groups_order:
            glyph_names = font.groups[group_name]
            #glyph_names.sort()
            glyphs_order.extend(glyph_names)
            _R, _G, _B = hls_to_rgb(color, 0.5, 1.0)            
            for gName in glyph_names:
                if font.has_key(gName) != True:
                    font.newGlyph(gName)
                font[gName].mark = (_R, _G, _B, .5)
                font[gName].update()
            color = color + colorStep
            if color > 1:
                color = color - 1
        # set glyph order
        font.glyphOrder = []
        font.glyphOrder = glyphs_order
        print '...done.\n'
        font.update()
    else:
        print 'font has no groups.\n'
Example #2
0
def paint_groups(f, crop=False):
    """Paint the glyphs in the font according to their groups.

    If a ``groups_order`` lib is available, it is used to set the order of the glyphs in the font.

    """
    font = CurrentFont()
    if len(f.groups) > 0:
        clear_colors(f)
        count = 0
        _order = []
        if f.lib.has_key("groups_order"):
            groups = f.lib["groups_order"]
        else:
            groups = f.groups.keys()
        for group in groups:
            color_step = 1.0 / len(f.groups)
            color = color_step * count
            R, G, B = hls_to_rgb(color, 0.5, 1.0)
            for glyph_name in f.groups[group]:
                if f.has_key(glyph_name) is not True:
                    f.newGlyph(glyph_name)
                _order.append(glyph_name)
                f[glyph_name].mark = (R, G, B, 0.5)
                f[glyph_name].update()
            count += 1
        f.glyphOrder = _order
        f.update()
        if crop:
            crop_glyphset(f, _order)
    else:
        print "font has no groups.\n"
Example #3
0
def paintGroups(font):
    if len(font.groups) > 0:
        groups_order = font.groups.keys()
        #groups_order.sort()
        colorStep = 1.0 / len(groups_order)
        color = 0
        glyphs_order = []
        print 'painting glyph groups...\n'
        for group_name in groups_order:
            glyph_names = font.groups[group_name]
            #glyph_names.sort()
            glyphs_order.extend(glyph_names)
            _R, _G, _B = hls_to_rgb(color, 0.5, 1.0)
            for gName in glyph_names:
                if font.has_key(gName) != True:
                    font.newGlyph(gName)
                font[gName].mark = (_R, _G, _B, .5)
                font[gName].update()
            color = color + colorStep
            if color > 1:
                color = color - 1
        # set glyph order
        font.glyphOrder = []
        font.glyphOrder = glyphs_order
        print '...done.\n'
        font.update()
    else:
        print 'font has no groups.\n'
def paint_groups(font, crop=False):
    """Paint the glyphs in the font according to their groups.

    If a ``groups_order`` lib is available, it is used to set the order of the glyphs in the font.

    :param RFont font: The font as an RFont object.

    """
    if len(font.groups) > 0:
        clear_colors(font)
        count = 0
        _order = []
        if font.lib.has_key('groups_order'):
            groups = font.lib['groups_order']
        else:
            groups = font.groups.keys()
        for group in groups:
            color_step = 1.0 / len(font.groups)
            color = color_step * count
            R, G, B = hls_to_rgb(color, 0.5, 1.0)
            for glyph_name in font.groups[group]:
                if font.has_key(glyph_name) is not True:
                    font.newGlyph(glyph_name)
                _order.append(glyph_name)
                font[glyph_name].mark = (R, G, B, 0.3)
                font[glyph_name].update()
            count += 1
        font.glyphOrder = _order
        font.update()
        if crop:
            crop_glyphset(font, _order)
    else:
        print 'font has no groups.\n'
Example #5
0
 def paint_spacing_groups(self, side, verbose=False):
     """Paint left or right spacing groups."""
     # collect groups & glyphs to paint
     _groups_dict = get_spacing_groups(self.ufo)
     if side == 'left':
         _groups = _groups_dict['left']
     else:
         _groups = _groups_dict['right']
     # paint
     if len(_groups) > 0:
         if verbose:
             print 'painting spacing groups...'
         print
         _group_names = _groups.keys()
         clear_colors(self.ufo)
         color_step = 1.0 / len(_group_names)
         count = 0
         for group in _group_names:
             if verbose:
                 print '\tpainting group %s...' % group
             color = color_step * count
             R, G, B = hls_to_rgb(color, 0.5, 1.0)
             for glyph_name in _groups[group]:
                 if self.ufo.has_key(glyph_name):
                     self.ufo[glyph_name].mark = (R, G, B, .5)
                     self.ufo[glyph_name].update()
                 else:
                     if verbose:
                         print '\t\t%s not in font' % glyph_name
             count += 1
         self.ufo.update()
         if verbose:
             print
             print '...done.\n'
     else:
         if verbose:
             print 'there are no spacing groups to paint.\n'
Example #6
0
def paint_groups(font, crop=False, order=None):
    '''
    Paint glyphs in the font according to their groups.

    If a ``groups_order`` font lib is available, it is used to set the order of the glyphs in the font.

    font: The font as an RFont object.

    '''
    if len(font.groups) > 0:
        clear_colors(font)
        count = 0
        _order = []
        if order is not None:
            groups = order
        elif font.lib.has_key('groups_order'):
            groups = font.lib['groups_order']
        else:
            groups = font.groups.keys()
        for group in groups:
            color_step = 1.0 / len(font.groups)
            color = color_step * count
            R, G, B = hls_to_rgb(color, 0.5, 1.0)
            for glyph_name in font.groups[group]:
                if font.has_key(glyph_name) is not True:
                    font.newGlyph(glyph_name)
                _order.append(glyph_name)
                font[glyph_name].mark = (R, G, B, 0.3)
                font[glyph_name].update()
            count += 1
        # print _order
        font.glyphOrder = _order
        font.update()
        if crop:
            crop_glyphset(font, _order)
    else:
        print 'font has no groups.\n'
Example #7
0
# [h] paint glyphs

from hTools2.modules.color import hls_to_rgb

f = CurrentFont()

color_step = 1.0 / len(f)

for i, g in enumerate(f):
    hue = i * color_step
    R, G, B = hls_to_rgb(hue, 0.5, 1.0)
    g.mark = (R, G, B, .5)
    g.update()

f.update()