Python matplotlib.ft2font() Examples
The following are 6 code examples for showing how to use matplotlib.ft2font(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: neural-network-animation Author: miloharper File: test_mathtext.py License: MIT License | 5 votes |
def test_fontinfo(): import matplotlib.font_manager as font_manager import matplotlib.ft2font as ft2font fontpath = font_manager.findfont("Bitstream Vera Sans") font = ft2font.FT2Font(fontpath) table = font.get_sfnt_table("head") assert table['version'] == (1, 0)
Example 2
Project: python3_ios Author: holzschu File: test_mathtext.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_fontinfo(): import matplotlib.font_manager as font_manager import matplotlib.ft2font as ft2font fontpath = font_manager.findfont("DejaVu Sans") font = ft2font.FT2Font(fontpath) table = font.get_sfnt_table("head") assert table['version'] == (1, 0)
Example 3
Project: coffeegrindsize Author: jgagneastro File: test_mathtext.py License: MIT License | 5 votes |
def test_fontinfo(): import matplotlib.font_manager as font_manager import matplotlib.ft2font as ft2font fontpath = font_manager.findfont("DejaVu Sans") font = ft2font.FT2Font(fontpath) table = font.get_sfnt_table("head") assert table['version'] == (1, 0)
Example 4
Project: twitter-stock-recommendation Author: alvarobartt File: test_mathtext.py License: MIT License | 5 votes |
def test_fontinfo(): import matplotlib.font_manager as font_manager import matplotlib.ft2font as ft2font fontpath = font_manager.findfont("DejaVu Sans") font = ft2font.FT2Font(fontpath) table = font.get_sfnt_table("head") assert table['version'] == (1, 0)
Example 5
Project: Computable Author: ktraunmueller File: backend_pdf.py License: MIT License | 4 votes |
def createType1Descriptor(self, t1font, fontfile): # Create and write the font descriptor and the font file # of a Type-1 font fontdescObject = self.reserveObject('font descriptor') fontfileObject = self.reserveObject('font file') italic_angle = t1font.prop['ItalicAngle'] fixed_pitch = t1font.prop['isFixedPitch'] flags = 0 if fixed_pitch: flags |= 1 << 0 # fixed width if 0: flags |= 1 << 1 # TODO: serif if 1: flags |= 1 << 2 # TODO: symbolic (most TeX fonts are) else: flags |= 1 << 5 # non-symbolic if italic_angle: flags |= 1 << 6 # italic if 0: flags |= 1 << 16 # TODO: all caps if 0: flags |= 1 << 17 # TODO: small caps if 0: flags |= 1 << 18 # TODO: force bold ft2font = FT2Font(str(fontfile)) descriptor = { 'Type': Name('FontDescriptor'), 'FontName': Name(t1font.prop['FontName']), 'Flags': flags, 'FontBBox': ft2font.bbox, 'ItalicAngle': italic_angle, 'Ascent': ft2font.ascender, 'Descent': ft2font.descender, 'CapHeight': 1000, # TODO: find this out 'XHeight': 500, # TODO: this one too 'FontFile': fontfileObject, 'FontFamily': t1font.prop['FamilyName'], 'StemV': 50, # TODO # (see also revision 3874; but not all TeX distros have AFM files!) #'FontWeight': a number where 400 = Regular, 700 = Bold } self.writeObject(fontdescObject, descriptor) self.beginStream(fontfileObject.id, None, { 'Length1': len(t1font.parts[0]), 'Length2': len(t1font.parts[1]), 'Length3': 0 }) self.currentstream.write(t1font.parts[0]) self.currentstream.write(t1font.parts[1]) self.endStream() return fontdescObject
Example 6
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_pdf.py License: MIT License | 4 votes |
def createType1Descriptor(self, t1font, fontfile): # Create and write the font descriptor and the font file # of a Type-1 font fontdescObject = self.reserveObject('font descriptor') fontfileObject = self.reserveObject('font file') italic_angle = t1font.prop['ItalicAngle'] fixed_pitch = t1font.prop['isFixedPitch'] flags = 0 if fixed_pitch: flags |= 1 << 0 # fixed width if 0: flags |= 1 << 1 # TODO: serif if 1: flags |= 1 << 2 # TODO: symbolic (most TeX fonts are) else: flags |= 1 << 5 # non-symbolic if italic_angle: flags |= 1 << 6 # italic if 0: flags |= 1 << 16 # TODO: all caps if 0: flags |= 1 << 17 # TODO: small caps if 0: flags |= 1 << 18 # TODO: force bold ft2font = FT2Font(str(fontfile)) descriptor = { 'Type': Name('FontDescriptor'), 'FontName': Name(t1font.prop['FontName']), 'Flags': flags, 'FontBBox': ft2font.bbox, 'ItalicAngle': italic_angle, 'Ascent': ft2font.ascender, 'Descent': ft2font.descender, 'CapHeight': 1000, # TODO: find this out 'XHeight': 500, # TODO: this one too 'FontFile': fontfileObject, 'FontFamily': t1font.prop['FamilyName'], 'StemV': 50, # TODO # (see also revision 3874; but not all TeX distros have AFM files!) #'FontWeight': a number where 400 = Regular, 700 = Bold } self.writeObject(fontdescObject, descriptor) self.beginStream(fontfileObject.id, None, { 'Length1': len(t1font.parts[0]), 'Length2': len(t1font.parts[1]), 'Length3': 0 }) self.currentstream.write(t1font.parts[0]) self.currentstream.write(t1font.parts[1]) self.endStream() return fontdescObject