FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Mathtext font tests by mdboom · Pull Request #21 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .pdf  (3) .png  (3) .py  (2) .svg  (3) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
31 changes: 23 additions & 8 deletions lib/matplotlib/_mathtext_data.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2355,17 +2355,17 @@
[
(0x0030, 0x0039, 'rm', 0x1d7d8), # 0-9
(0x0041, 0x0042, 'it', 0xe154), # A-B
(0x0043, 0x0043, 'it', 0x2102), # C (missing in beta STIX fonts)
(0x0043, 0x0043, 'it', 0x2102), # C
(0x0044, 0x0044, 'it', 0x2145), # D
(0x0045, 0x0047, 'it', 0xe156), # E-G
(0x0048, 0x0048, 'it', 0x210d), # H (missing in beta STIX fonts)
(0x0048, 0x0048, 'it', 0x210d), # H
(0x0049, 0x004d, 'it', 0xe159), # I-M
(0x004e, 0x004e, 'it', 0x2115), # N (missing in beta STIX fonts)
(0x004e, 0x004e, 'it', 0x2115), # N
(0x004f, 0x004f, 'it', 0xe15e), # O
(0x0050, 0x0051, 'it', 0x2119), # P-Q (missing in beta STIX fonts)
(0x0052, 0x0052, 'it', 0x211d), # R (missing in beta STIX fonts)
(0x0050, 0x0051, 'it', 0x2119), # P-Q
(0x0052, 0x0052, 'it', 0x211d), # R
(0x0053, 0x0059, 'it', 0xe15f), # S-Y
(0x005a, 0x005a, 'it', 0x2124), # Z (missing in beta STIX fonts)
(0x005a, 0x005a, 'it', 0x2124), # Z
(0x0061, 0x0063, 'it', 0xe166), # a-c
(0x0064, 0x0065, 'it', 0x2146), # d-e
(0x0066, 0x0068, 'it', 0xe169), # f-h
Expand All @@ -2380,8 +2380,23 @@
'bf':
[
(0x0030, 0x0039, 'rm', 0x1d7d8), # 0-9
(0x0041, 0x005a, 'bf', 0xe38a), # A-Z
(0x0061, 0x007a, 'bf', 0xe39d), # a-z
(0x0041, 0x0042, 'bf', 0xe38a), # A-B
(0x0043, 0x0043, 'bf', 0x2102), # C
(0x0044, 0x0044, 'bf', 0x2145), # D
(0x0045, 0x0047, 'bf', 0xe38d), # E-G
(0x0048, 0x0048, 'bf', 0x210d), # H
(0x0049, 0x004d, 'bf', 0xe390), # I-M
(0x004e, 0x004e, 'bf', 0x2115), # N
(0x004f, 0x004f, 'bf', 0xe395), # O
(0x0050, 0x0051, 'bf', 0x2119), # P-Q
(0x0052, 0x0052, 'bf', 0x211d), # R
(0x0053, 0x0059, 'bf', 0xe396), # S-Y
(0x005a, 0x005a, 'bf', 0x2124), # Z
(0x0061, 0x0063, 'bf', 0xe39d), # a-c
(0x0064, 0x0065, 'bf', 0x2146), # d-e
(0x0066, 0x0068, 'bf', 0xe3a2), # f-h
(0x0069, 0x006a, 'bf', 0x2148), # i-j
(0x006b, 0x007a, 'bf', 0xe3a7), # k-z
(0x0393, 0x0393, 'bf', 0x213e), # \Gamma
(0x03a0, 0x03a0, 'bf', 0x213f), # \Pi
(0x03a3, 0x03a3, 'bf', 0x2140), # \Sigma
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
3,056 changes: 3,056 additions & 0 deletions lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_font.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
85 changes: 77 additions & 8 deletions lib/matplotlib/tests/test_mathtext.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,73 @@
r'${x}_{92}^{31415}+\pi $',
r'${x}_{{y}_{b}^{a}}^{{z}_{c}^{d}}$',
r'${y}_{3}^{\prime \prime \prime }$',
r"$\left( \xi \left( 1 - \xi \right) \right)$" # Bug 2969451
r"$\left( \xi \left( 1 - \xi \right) \right)$", # Bug 2969451
]

def _run_all_tests():
fig = plt.figure(figsize=(5, len(math_tests) / 2.0))
for i, test in enumerate(math_tests):
fig.text(0, float(len(math_tests) - i - 1) / len(math_tests), test)
digits = "0123456789"
uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lowercase = "abcdefghijklmnopqrstuvwxyz"
uppergreek = (r"\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi "
r"\Omega")
lowergreek = (r"\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota "
r"\lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon "
r"\phi \chi \psi")
all = [digits, uppercase, lowercase, uppergreek, lowergreek]

font_test_specs = [
([], all),
(['mathrm'], all),
(['mathbf'], all),
(['mathit'], all),
(['mathtt'], [digits, uppercase, lowercase]),
(['mathcircled'], [digits, uppercase, lowercase]),
(['mathrm', 'mathcircled'], [digits, uppercase, lowercase]),
(['mathbf', 'mathcircled'], [digits, uppercase, lowercase]),
(['mathbb'], [digits, uppercase, lowercase,
r'\Gamma \Pi \Sigma \gamma \pi']),
(['mathrm', 'mathbb'], [digits, uppercase, lowercase,
r'\Gamma \Pi \Sigma \gamma \pi']),
(['mathbf', 'mathbb'], [digits, uppercase, lowercase,
r'\Gamma \Pi \Sigma \gamma \pi']),
(['mathcal'], [uppercase]),
(['mathfrak'], [uppercase, lowercase]),
(['mathbf', 'mathfrak'], [uppercase, lowercase]),
(['mathscr'], [uppercase, lowercase]),
(['mathsf'], [digits, uppercase, lowercase]),
(['mathrm', 'mathsf'], [digits, uppercase, lowercase]),
(['mathbf', 'mathsf'], [digits, uppercase, lowercase])
]

font_tests = []
for fonts, chars in font_test_specs:
wrapper = [' '.join(fonts), ' $']
for font in fonts:
wrapper.append(r'\%s{' % font)
wrapper.append('%s')
for font in fonts:
wrapper.append('}')
wrapper.append('$')
wrapper = ''.join(wrapper)

for set in chars:
font_tests.append(wrapper % set)

def _run_all_tests(tests):
fig = plt.figure(figsize=(5, len(tests) / 2.0))
for i, test in enumerate(tests):
fig.text(0, float(len(tests) - i - 1) / len(tests), test)
return fig

@image_comparison(baseline_images=['mathtext'])
def test_mathtext():
fig = _run_all_tests()
fig = _run_all_tests(math_tests)
fig.savefig('mathtext')

@image_comparison(baseline_images=['mathtext_stix'])
def test_mathtext_stix():
matplotlib.rcParams['mathtext.fontset'] = 'stix'

fig = _run_all_tests()
fig = _run_all_tests(math_tests)
fig.savefig('mathtext_stix')

matplotlib.rcParams['mathtext.fontset'] = 'cm'
Expand All @@ -109,9 +157,30 @@ def test_mathtext_stix():
def test_mathtext_stixsans():
matplotlib.rcParams['mathtext.fontset'] = 'stixsans'

fig = _run_all_tests()
fig = _run_all_tests(math_tests)
fig.savefig('mathtext_stixsans')

matplotlib.rcParams['mathtext.fontset'] = 'cm'

@image_comparison(baseline_images=['mathtext_font'])
def test_mathtext_font():
fig = _run_all_tests(font_tests)
fig.savefig('mathtext_font')

@image_comparison(baseline_images=['mathtext_font_stix'])
def test_mathtext_font_stix():
matplotlib.rcParams['mathtext.fontset'] = 'stix'

fig = _run_all_tests(font_tests)
fig.savefig('mathtext_font_stix')

matplotlib.rcParams['mathtext.fontset'] = 'cm'

@image_comparison(baseline_images=['mathtext_font_stixsans'])
def test_mathtext_font_stixsans():
matplotlib.rcParams['mathtext.fontset'] = 'stixsans'

fig = _run_all_tests(font_tests)
fig.savefig('mathtext_font_stixsans')

matplotlib.rcParams['mathtext.fontset'] = 'cm'

Back | FazBrowse Home | New Git URL