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

Commit594caad

Browse files
committed
Add Latin Modern support for mathtext
1 parent6eeede6 commit594caad

File tree

70 files changed

+78
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+78
-6
lines changed

‎lib/matplotlib/_mathtext.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,43 @@ class DejaVuSerifFonts(DejaVuFonts):
640640
}
641641

642642

643+
classLatinModernFonts(UnicodeFonts):
644+
"""
645+
A font handling class for the Latin Modern fonts
646+
647+
"""
648+
_fontmap= {
649+
'rm':'Latin Modern Roman',
650+
'it':'Latin Modern Roman:italic',
651+
'bf':'Latin Modern Roman:weight=bold',
652+
'bfit':'Latin Modern Roman:italic:bold',
653+
'tt':'Latin Modern Mono',
654+
'sf':'Latin Modern Sans',
655+
'ex':'Latin Modern Math'
656+
}
657+
_fallback_font=False
658+
_sans=False
659+
660+
def__init__(self,*args,**kwargs):
661+
# This must come first so the backend's owner is set correctly
662+
self.fontmap= {}
663+
TruetypeFonts.__init__(self,*args,**kwargs)
664+
665+
forkey,nameinself._fontmap.items():
666+
fullpath=findfont(name)
667+
self.fontmap[key]=fullpath
668+
self.fontmap[name]=fullpath
669+
670+
def_get_glyph(self,fontname,font_class,sym):
671+
uniindex=get_unicode_index(sym)
672+
font=self._get_font(fontname)
673+
iffontisnotNone:
674+
glyphindex=font.get_char_index(uniindex)
675+
ifglyphindex!=0:
676+
returnsuper()._get_glyph(fontname,font_class,sym)
677+
returnsuper()._get_glyph('ex',font_class,sym)
678+
679+
643680
classDejaVuSansFonts(DejaVuFonts):
644681
"""
645682
A font handling class for the DejaVu Sans fonts
@@ -841,6 +878,10 @@ class FontConstantsBase:
841878
delta_integral=0.1
842879

843880

881+
classLatinModernFontConstants(FontConstantsBase):
882+
pass
883+
884+
844885
classComputerModernFontConstants(FontConstantsBase):
845886
script_space=0.075
846887
subdrop=0.2
@@ -888,6 +929,8 @@ class DejaVuSansFontConstants(FontConstantsBase):
888929
'cmss10':ComputerModernFontConstants,
889930
'cmsy10':ComputerModernFontConstants,
890931
'cmtt10':ComputerModernFontConstants,
932+
'Latin Modern Roman':LatinModernFontConstants,
933+
'Latin Modern Math':LatinModernFontConstants,
891934
'STIXGeneral':STIXFontConstants,
892935
'STIXNonUnicode':STIXFontConstants,
893936
'STIXSizeFiveSym':STIXFontConstants,

‎lib/matplotlib/font_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ class FontProperties:
562562
absolute font size, e.g., 10. Default: :rc:`font.size`
563563
564564
- math_fontfamily: The family of fonts used to render math text.
565-
Supported values are: 'dejavusans', 'dejavuserif', 'cm',
565+
Supported values are: 'lm', 'dejavusans', 'dejavuserif', 'cm',
566566
'stix', 'stixsans' and 'custom'. Default: :rc:`mathtext.fontset`
567567
568568
Alternatively, a font may be specified using the absolute path to a font

‎lib/matplotlib/mathtext.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class MathTextParser:
4141
'dejavusans':_mathtext.DejaVuSansFonts,
4242
'stix':_mathtext.StixFonts,
4343
'stixsans':_mathtext.StixSansFonts,
44+
'lm':_mathtext.LatinModernFonts,
4445
'custom':_mathtext.UnicodeFonts,
4546
}
4647

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
% This is version 1.0, dated 22 June 2009, of the GUST Font License.
2+
% (GUST is the Polish TeX Users Group, http://www.gust.org.pl)
3+
%
4+
% For the most recent version of this license see
5+
% http://www.gust.org.pl/fonts/licenses/GUST-FONT-LICENSE.txt
6+
% or
7+
% http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt
8+
%
9+
% This work may be distributed and/or modified under the conditions
10+
% of the LaTeX Project Public License, either version 1.3c of this
11+
% license or (at your option) any later version.
12+
%
13+
% Please also observe the following clause:
14+
% 1) it is requested, but not legally required, that derived works be
15+
% distributed only after changing the names of the fonts comprising this
16+
% work and given in an accompanying "manifest", and that the
17+
% files comprising the Work, as listed in the manifest, also be given
18+
% new names. Any exceptions to this request are also given in the
19+
% manifest.
20+
%
21+
% We recommend the manifest be given in a separate file named
22+
% MANIFEST-<fontid>.txt, where <fontid> is some unique identification
23+
% of the font family. If a separate "readme" file accompanies the Work,
24+
% we recommend a name of the form README-<fontid>.txt.
25+
%
26+
% The latest version of the LaTeX Project Public License is in
27+
% http://www.latex-project.org/lppl.txt and version 1.3c or later
28+
% is part of all distributions of LaTeX version 2006/05/20 or later.
Binary file not shown.
109 KB
Binary file not shown.
115 KB
Binary file not shown.
109 KB
Binary file not shown.
116 KB
Binary file not shown.
92.9 KB
Binary file not shown.
63.2 KB
Binary file not shown.

‎lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
#font.size: 10.0
268268

269269
#font.serif: DejaVu Serif, Bitstream Vera Serif, Computer Modern Roman, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
270-
#font.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
270+
#font.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde,Latin Modern Roman,sans-serif
271271
#font.cursive: Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, Comic Neue, Comic Sans MS, cursive
272272
#font.fantasy: Chicago, Charcoal, Impact, Western, Humor Sans, xkcd, fantasy
273273
#font.monospace: DejaVu Sans Mono, Bitstream Vera Sans Mono, Computer Modern Typewriter, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace
@@ -335,7 +335,7 @@
335335
## The following settings allow you to select the fonts in math mode.
336336
#mathtext.fontset: dejavusans # Should be 'dejavusans' (default),
337337
# 'dejavuserif', 'cm' (Computer Modern), 'stix',
338-
# 'stixsans' or'custom'
338+
# 'stixsans','custom', 'lm' (Latin Modern)
339339
## "mathtext.fontset: custom" is defined by the mathtext.bf, .cal, .it, ...
340340
## settings which map a TeX font name to a fontconfig font pattern. (These
341341
## settings are not used for other font sets.)

‎lib/matplotlib/rcsetup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,8 @@ def _convert_validator_spec(key, conv):
10041004
"mathtext.bf":validate_font_properties,
10051005
"mathtext.bfit":validate_font_properties,
10061006
"mathtext.sf":validate_font_properties,
1007-
"mathtext.fontset": ["dejavusans","dejavuserif","cm","stix",
1008-
"stixsans","custom"],
1007+
"mathtext.fontset": ["dejavusans","dejavuserif","lm","cm",
1008+
"stix","stixsans","custom"],
10091009
"mathtext.default": ["rm","cal","bfit","it","tt","sf","bf","default",
10101010
"bb","frak","scr","regular"],
10111011
"mathtext.fallback":_validate_mathtext_fallback,

‎lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def test_mathtext_rendering_lightweight(baseline_images, fontset, index, text):
247247
@pytest.mark.parametrize(
248248
'index, text',enumerate(font_tests),ids=range(len(font_tests)))
249249
@pytest.mark.parametrize(
250-
'fontset', ['cm','stix','stixsans','dejavusans','dejavuserif'])
250+
'fontset', ['lm','cm','stix','stixsans','dejavusans','dejavuserif'])
251251
@pytest.mark.parametrize('baseline_images', ['mathfont'],indirect=True)
252252
@image_comparison(baseline_images=None,extensions=['png'],
253253
tol=0.011ifplatform.machine()in ('ppc64le','s390x')else0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp