Exemple #1
0
 def get_name(self):
     """
     Return the name of the font that best matches the font
     properties.
     """
     return ft2font.FT2Font(str(findfont(self))).family_name
from __future__ import print_function
"""
This is a demo script to show you how to use all the properties of an
FT2Font object.  These describe global font properties.  For
individual character metrices, use the Glyp object, as returned by
load_char
"""
import matplotlib
import matplotlib.ft2font as ft


#fname = '/usr/local/share/matplotlib/VeraIt.ttf'
fname = matplotlib.get_data_path() + '/fonts/ttf/VeraIt.ttf'
#fname = '/usr/local/share/matplotlib/cmr10.ttf'

font = ft.FT2Font(fname)

print('Num faces   :', font.num_faces)       # number of faces in file
print('Num glyphs  :', font.num_glyphs)      # number of glyphs in the face
print('Family name :', font.family_name)     # face family name
print('Syle name   :', font.style_name)      # face syle name
print('PS name     :', font.postscript_name) # the postscript name
print('Num fixed   :', font.num_fixed_sizes) # number of embedded bitmap in face

# the following are only available if face.scalable
if font.scalable:
    # the face global bounding box (xmin, ymin, xmax, ymax)
    print('Bbox                :', font.bbox)
    # number of font units covered by the EM
    print('EM                  :', font.units_per_EM)
    # the ascender in 26.6 units
Exemple #3
0
Font properties
===============

This example lists the attributes of an `.FT2Font` object, which describe
global font properties.  For individual character metrics, use the `.Glyph`
object, as returned by `.load_char`.
"""

import os

import matplotlib
import matplotlib.ft2font as ft


font = ft.FT2Font(
    # Use a font shipped with Matplotlib.
    os.path.join(matplotlib.get_data_path(),
                 'fonts/ttf/DejaVuSans-Oblique.ttf'))

print('Num faces:  ', font.num_faces)        # number of faces in file
print('Num glyphs: ', font.num_glyphs)       # number of glyphs in the face
print('Family name:', font.family_name)      # face family name
print('Style name: ', font.style_name)       # face style name
print('PS name:    ', font.postscript_name)  # the postscript name
print('Num fixed:  ', font.num_fixed_sizes)  # number of embedded bitmaps

# the following are only available if face.scalable
if font.scalable:
    # the face global bounding box (xmin, ymin, xmax, ymax)
    print('Bbox:               ', font.bbox)
    # number of font units covered by the EM
    print('EM:                 ', font.units_per_EM)
Exemple #4
0
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.font_manager import ttfFontProperty
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5 import NavigationToolbar2QT as NavigationToolbar
from matplotlib import ft2font
from bs4 import BeautifulSoup
from geopython.TabelViewer import TabelViewer

LocationOfMySelf = os.path.dirname(__file__)

print(LocationOfMySelf, 'Import Denpendence')

fpath = LocationOfMySelf + ('/wqy.ttf')

font = ft2font.FT2Font(fpath)
fprop = font_manager.FontProperties(fname=fpath)

ttfFontProp = ttfFontProperty(font)
fontprop = font_manager.FontProperties(
    family='sans-serif',
    #name=ap.fontprop.name,
    size=9,
    fname=ttfFontProp.fname,
    stretch=ttfFontProp.stretch,
    style=ttfFontProp.style,
    variant=ttfFontProp.variant,
    weight=ttfFontProp.weight)

plt.rcParams['svg.fonttype'] = 'none'
plt.rcParams['pdf.fonttype'] = 'truetype'
Exemple #5
0
def _get_font(filename, hinting_factor, *, _kerning_factor, thread_id):
    return ft2font.FT2Font(filename,
                           hinting_factor,
                           _kerning_factor=_kerning_factor)