Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

New FreeType wrapper.#9763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
anntzer wants to merge1 commit intomatplotlib:mainfromanntzer:ft2
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions.appveyor.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,8 @@ environment:
CONDA_INSTALL_LOCN: "C:\\Miniconda36-x64"
TEST_ALL: "no"

image: Visual Studio 2017

# We always use a 64-bit machine, but can build x86 distributions
# with the PYTHON_ARCH variable
platform:
Expand All@@ -42,6 +44,7 @@ init:
- echo %PYTHON_VERSION% %CONDA_INSTALL_LOCN%

install:
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
- set PATH=%CONDA_INSTALL_LOCN%;%CONDA_INSTALL_LOCN%\scripts;%PATH%;
- set PYTHONUNBUFFERED=1
# for msinttypes and newer stuff
Expand Down
25 changes: 16 additions & 9 deletions.circleci/config.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,20 +13,24 @@ apt-run: &apt-install
command: |
sudo apt-get -qq update
sudo apt-get install -y \
cm-super \
dvipng \
graphviz \
inkscape \
libav-tools \
dvipng \
pgf \
libgeos-dev \
lmodern \
cm-super \
otf-freefont \
pgf \
software-properties-common \
texlive-fonts-recommended \
texlive-latex-base \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-latex-recommended \
texlive-xetex \
graphviz \
libgeos-dev \
otf-freefont
texlive-xetex
sudo add-apt-repository 'deb http://ftp.us.debian.org/debian testing main'
sudo apt-get update
sudo apt-get install g++-7

fonts-run: &fonts-install
name: Install custom fonts
Expand DownExpand Up@@ -64,7 +68,10 @@ deps-run: &deps-install

mpl-run: &mpl-install
name: Install Matplotlib
command: pip install --user -ve .
command: |
ls /usr/include/freetype2
cat /usr/include/freetype2/ft2build.h
CC=gcc-7 CXX=g++-7 pip install --user -ve .

doc-run: &doc-build
name: Build documentation
Expand Down
35 changes: 29 additions & 6 deletions.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ sudo: false

branches:
except:
- /^auto-backport-of-pr-\d*/
- /^auto-backport-of-pr-\d*/

cache:
pip: true
Expand All@@ -16,11 +16,14 @@ cache:
addons:
artifacts:
paths:
- result_images.tar.bz2
- result_images.tar.bz2
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- cm-super
- dvipng
- g++-7
- gdb
- gir1.2-gtk-3.0
- graphviz
Expand DownExpand Up@@ -68,6 +71,8 @@ matrix:
- python: 3.5
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124.
env:
- CC=gcc-7
- CXX=g++-7
- CYCLER=cycler==0.10
- DATEUTIL=python-dateutil==2.1
- NOSE=nose
Expand All@@ -78,14 +83,30 @@ matrix:
- PYTEST_COV=pytest-cov==2.3.1
- SPHINX=sphinx==1.3
- python: 3.5
env: PYTHON_ARGS=-OO
env:
- CC=gcc-7
- CXX=g++-7
- PYTHON_ARGS=-OO
- python: 3.6
env: DELETE_FONT_CACHE=1 PANDAS='pandas<0.21.0' PYTEST_PEP8=pytest-pep8 RUN_PEP8=--pep8
env:
- CC=gcc-7
- CXX=g++-7
- DELETE_FONT_CACHE=1
- PANDAS='pandas<0.21.0'
- PYTEST_PEP8=pytest-pep8
- RUN_PEP8=--pep8
- python: "nightly"
env: PRE=--pre
env:
- CC=gcc-7
- CXX=g++-7
- PRE=--pre
- os: osx
language: generic # https://github.com/travis-ci/travis-ci/issues/2312
only: master
env:
- PATH="/usr/local/opt/llvm/bin:$PATH"
- CPPFLAGS=-L/usr/local/opt/llvm/include
- LDFLAGS='-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib'
cache:
# As for now travis caches only "$HOME/.cache/pip"
# https://docs.travis-ci.com/user/caching/#pip-cache
Expand All@@ -108,7 +129,9 @@ before_install:
else
ci/travis/silence brew update
brew upgrade python
brew install ffmpeg imagemagick mplayer ccache
brew install ccache llvm
brew info llvm
brew install ffmpeg imagemagick mplayer
hash -r
which python
python --version
Expand Down
50 changes: 19 additions & 31 deletionsexamples/misc/font_indexing.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,39 +4,27 @@
=============

A little example that shows how the various indexing into the font
tables relate to one another. Mainly formpl developers....
tables relate to one another. Mainly forMatplotlib developers...

"""
import matplotlib
from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, KERNING_UNFITTED, KERNING_UNSCALED

from matplotlib._ft2 import Kerning
import matplotlib.font_manager


fname = matplotlib.get_data_path() + '/fonts/ttf/DejaVuSans.ttf'
font = FT2Font(fname)
font.set_charmap(0)

codes = font.get_charmap().items()
#dsu = [(ccode, glyphind) for ccode, glyphind in codes]
#dsu.sort()
#for ccode, glyphind in dsu:
# try: name = font.get_glyph_name(glyphind)
# except RuntimeError: pass
# else: print('% 4d % 4d %s %s' % (glyphind, ccode, hex(int(ccode)), name))


# make a charname to charcode and glyphind dictionary
coded = {}
glyphd = {}
for ccode, glyphind in codes:
name = font.get_glyph_name(glyphind)
coded[name] = ccode
glyphd[name] = glyphind

code = coded['A']
glyph = font.load_char(code)
print(glyph.bbox)
print(glyphd['A'], glyphd['V'], coded['A'], coded['V'])
print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_DEFAULT))
print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_UNFITTED))
print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_UNSCALED))
print('AV', font.get_kerning(glyphd['A'], glyphd['T'], KERNING_UNSCALED))
font = matplotlib.font_manager.get_font(fname)

# This assumes FreeType>=2.8.1, which automatically picks or synthesizes a
# Unicode charmap.

def get_kerning(c1, c2, mode):
i1 = font.get_char_index(ord(c1))
i2 = font.get_char_index(ord(c2))
return font.get_kerning(i1, i2, mode)


print('AV default ', get_kerning('A', 'V', Kerning.DEFAULT))
print('AV unfitted', get_kerning('A', 'V', Kerning.UNFITTED))
print('AT default ', get_kerning('A', 'T', Kerning.DEFAULT))
print('AT unfitted', get_kerning('A', 'T', Kerning.UNFITTED))
114 changes: 50 additions & 64 deletionsexamples/misc/ftface_props.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,53 @@
"""
============
Ftface Props
============

This is a demo script to show you how to use all the properties ofan
FT2Fontobject. These describe global font properties. For
individual charactermetrics, use the Glyph object, asreturned by
load_char
===============
Face properties
===============

This is a demo script to show you how to use all the properties ofa Face
object. These describe global font properties. For individual character
metrics, use the Glyph object, asloaded from the glyph attribute after calling
load_char.
"""
import matplotlib
import matplotlib.ft2font as ft


#fname = '/usr/local/share/matplotlib/VeraIt.ttf'
fname = matplotlib.get_data_path() + '/fonts/ttf/DejaVuSans-Oblique.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('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 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
print('Ascender :', font.ascender)
# the descender in 26.6 units
print('Descender :', font.descender)
# the height in 26.6 units
print('Height :', font.height)
# maximum horizontal cursor advance
print('Max adv width :', font.max_advance_width)
# same for vertical layout
print('Max adv height :', font.max_advance_height)
# vertical position of the underline bar
print('Underline pos :', font.underline_position)
# vertical thickness of the underline
print('Underline thickness :', font.underline_thickness)

for style in ('Italic',
'Bold',
'Scalable',
'Fixed sizes',
'Fixed width',
'SFNT',
'Horizontal',
'Vertical',
'Kerning',
'Fast glyphs',
'Multiple masters',
'Glyph names',
'External stream'):
bitpos = getattr(ft, style.replace(' ', '_').upper()) - 1
print('%-17s:' % style, bool(font.style_flags & (1 << bitpos)))

print(dir(font))

print(font.get_kerning)
from matplotlib import font_manager, _ft2


fname = matplotlib.get_data_path() + "/fonts/ttf/DejaVuSans-Oblique.ttf"
font = font_manager.get_font(fname)

print("Faces in file :", font.num_faces)
print("Glyphs in face :", font.num_glyphs)
print("Family name :", font.family_name)
print("Style name :", font.style_name)
print("Postscript name :", font.get_postscript_name())
print("Embedded bitmap strikes:", font.num_fixed_sizes)

if font.face_flags & _ft2.FACE_FLAG_SCALABLE:
print('Global bbox (xmin, ymin, xmax, ymax):', font.bbox)
print('Font units per EM :', font.units_per_EM)
print('Ascender (pixels) :', font.ascender)
print('Descender (pixels) :', font.descender)
print('Height (pixels) :', font.height)
print('Max horizontal advance :', font.max_advance_width)
print('Max vertical advance :', font.max_advance_height)
print('Underline position :', font.underline_position)
print('Underline thickness :', font.underline_thickness)

for style in ['Style flag italic',
'Style flag bold']:
flag = getattr(_ft2, style.replace(' ', '_').upper()) - 1
print('%-26s:' % style, bool(font.style_flags & flag))

for style in ['Face flag scalable',
'Face flag fixed sizes',
'Face flag fixed width',
'Face flag SFNT',
'Face flag horizontal',
'Face flag vertical',
'Face flag kerning',
'Face flag fast glyphs',
'Face flag multiple masters',
'Face flag glyph names',
'Face flag external stream']:
flag = getattr(_ft2, style.replace(' ', '_').upper())
print('%-26s:' % style, bool(font.face_flags & flag))
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
import os

import matplotlib
from matplotlib.ft2font importFT2Font
from matplotlib import_ft2
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt

Expand All@@ -32,8 +32,8 @@
fontname = os.path.join(matplotlib.get_data_path(),
'fonts', 'ttf', 'DejaVuSans.ttf')

font =FT2Font(fontname)
codes = sorted(font.get_charmap().items())
font =_ft2.Face(fontname)
codes = sorted(font.get_charmap().items()) # FIXME

# a 16,16 array of character strings
chars = [['' for c in range(16)] for r in range(16)]
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp