def fromscalerdata(cls, glyphbitmap, bitDepth): """ Initializes a Format6 from glyphbitmap, which should be an object similar to ScalerInterface's 'GlyphBitmap', having 'metrics' and 'bits' attributes. """ mtx = glyphbitmap.metrics m = bigglyphmetrics.BigGlyphMetrics( height=mtx.height, width=mtx.width, horiBearingX=mtx.lo_x, horiBearingY=mtx.hi_y + 1, # convert from pixel to edge horiAdvance=mtx.i_dx) w = walker.StringWalker(glyphbitmap.bits) v = [ utilities.explodeRow(w.chunk(mtx.bpl), bitDepth, m.width) for _ in range(m.height) ] b = bitmap.Bitmap(v, lo_x=m.horiBearingX, hi_y=m.horiBearingY, bitDepth=bitDepth) r = cls(image=b, metrics=m) return r
# ----------------------------------------------------------------------------- # # Test code # if 0: def __________________(): pass if __debug__: from fontio3 import utilities _testingValues = (Format18(), Format18(metrics=bigglyphmetrics.BigGlyphMetrics( 7, 8, 1, 0, 10, -3, -1, 9), image=b'\x01' * 23)) # not real PNG data def _test(): import doctest doctest.testmod() if __name__ == "__main__": if __debug__: _test()
# # Test code # if 0: def __________________(): pass if __debug__: from fontio3 import utilities _testingValues = (Format6(), Format6(metrics=bigglyphmetrics.BigGlyphMetrics( 7, 8, 1, 0, 10, -3, -1, 9), image=bitmap.Bitmap([[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0]], lo_x=1, hi_y=0, bitDepth=1)), Format6(metrics=bigglyphmetrics.BigGlyphMetrics( 3, 3, 1, 3, 5, -1, -1, 5), image=bitmap.Bitmap( [[7, 4, 7], [4, 1, 4], [7, 4, 7]], lo_x=1,