diff options
author | James Godfrey-Kittle <jamesgk@google.com> | 2015-04-14 17:30:59 -0700 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk@google.com> | 2015-04-16 12:16:35 -0700 |
commit | 9c7be85eee749f620d722c8e0382bad3ed34c1b8 (patch) | |
tree | 7a955704e731626a4353f3285253c92654acdf9f /third_party/freetype-py/examples/glyph-monochrome.py | |
parent | ba03b84b90b50afd99f9688059447bc545e5c0e1 (diff) |
Remove freetype-py from repo, refer to GitHub.
Diffstat (limited to 'third_party/freetype-py/examples/glyph-monochrome.py')
-rw-r--r-- | third_party/freetype-py/examples/glyph-monochrome.py | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/third_party/freetype-py/examples/glyph-monochrome.py b/third_party/freetype-py/examples/glyph-monochrome.py deleted file mode 100644 index 3714ceb..0000000 --- a/third_party/freetype-py/examples/glyph-monochrome.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ----------------------------------------------------------------------------- -# -# FreeType high-level python API - Copyright 2011 Nicolas P. Rougier -# Distributed under the terms of the new BSD license. -# -# ----------------------------------------------------------------------------- -''' -Glyph bitmap monochrome rendring -''' -from freetype import * - -def bits(x): - data = [] - for i in range(8): - data.insert(0, int((x & 1) == 1)) - x = x >> 1 - return data - -if __name__ == '__main__': - import numpy - import matplotlib.pyplot as plt - - face = Face('./Vera.ttf') - face.set_char_size( 48*64 ) - face.load_char('S', FT_LOAD_RENDER | - FT_LOAD_TARGET_MONO ) - - bitmap = face.glyph.bitmap - width = face.glyph.bitmap.width - rows = face.glyph.bitmap.rows - pitch = face.glyph.bitmap.pitch - - data = [] - for i in range(bitmap.rows): - row = [] - for j in range(bitmap.pitch): - row.extend(bits(bitmap.buffer[i*bitmap.pitch+j])) - data.extend(row[:bitmap.width]) - Z = numpy.array(data).reshape(bitmap.rows, bitmap.width) - plt.imshow(Z, interpolation='nearest', cmap=plt.cm.gray, origin='lower') - plt.show() |