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

Commit8955c7f

Browse files
committed
Add Latin Modern support for mathtext
1 parent42c8f2a commit8955c7f

File tree

68 files changed

+80
-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.

68 files changed

+80
-6
lines changed

‎lib/matplotlib/_mathtext.py

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

641641

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

842881

882+
classLatinModernFontConstants(FontConstantsBase):
883+
pass
884+
885+
843886
classComputerModernFontConstants(FontConstantsBase):
844887
script_space=0.075
845888
subdrop=0.2
@@ -887,6 +930,8 @@ class DejaVuSansFontConstants(FontConstantsBase):
887930
'cmss10':ComputerModernFontConstants,
888931
'cmsy10':ComputerModernFontConstants,
889932
'cmtt10':ComputerModernFontConstants,
933+
'Latin Modern Roman':LatinModernFontConstants,
934+
'Latin Modern Math':LatinModernFontConstants,
890935
'STIXGeneral':STIXFontConstants,
891936
'STIXNonUnicode':STIXFontConstants,
892937
'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.

‎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
@@ -959,8 +959,8 @@ def _convert_validator_spec(key, conv):
959959
"mathtext.bf":validate_font_properties,
960960
"mathtext.bfit":validate_font_properties,
961961
"mathtext.sf":validate_font_properties,
962-
"mathtext.fontset": ["dejavusans","dejavuserif","cm","stix",
963-
"stixsans","custom"],
962+
"mathtext.fontset": ["dejavusans","dejavuserif","lm","cm",
963+
"stix","stixsans","custom"],
964964
"mathtext.default": ["rm","cal","bfit","it","tt","sf","bf","default",
965965
"bb","frak","scr","regular"],
966966
"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
@@ -245,7 +245,7 @@ def test_mathtext_rendering_lightweight(baseline_images, fontset, index, text):
245245
@pytest.mark.parametrize(
246246
'index, text',enumerate(font_tests),ids=range(len(font_tests)))
247247
@pytest.mark.parametrize(
248-
'fontset', ['cm','stix','stixsans','dejavusans','dejavuserif'])
248+
'fontset', ['lm','cm','stix','stixsans','dejavusans','dejavuserif'])
249249
@pytest.mark.parametrize('baseline_images', ['mathfont'],indirect=True)
250250
@image_comparison(baseline_images=None,extensions=['png'],
251251
tol=0.011ifplatform.machine()in ('ppc64le','s390x')else0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp