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

Commitfc2cc18

Browse files
committed
Add Latin Modern support for mathtext
1 parent11a5d66 commitfc2cc18

File tree

10 files changed

+80
-6
lines changed

10 files changed

+80
-6
lines changed

‎lib/matplotlib/_mathtext.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ def __init__(self, *args, **kwargs):
478478
fallback_rc=mpl.rcParams['mathtext.fallback']
479479
font_cls= {'stix':StixFonts,
480480
'stixsans':StixSansFonts,
481-
'cm':BakomaFonts
481+
'cm':BakomaFonts,
482+
'lm':LatinModernFonts
482483
}.get(fallback_rc)
483484
self._fallback_font=font_cls(*args,**kwargs)iffont_clselseNone
484485

@@ -639,6 +640,42 @@ class DejaVuSerifFonts(DejaVuFonts):
639640
}
640641

641642

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

842879

880+
classLatinModernFontConstants(FontConstantsBase):
881+
pass
882+
883+
843884
classComputerModernFontConstants(FontConstantsBase):
844885
script_space=0.075
845886
subdrop=0.2
@@ -887,6 +928,10 @@ class DejaVuSansFontConstants(FontConstantsBase):
887928
'cmss10':ComputerModernFontConstants,
888929
'cmsy10':ComputerModernFontConstants,
889930
'cmtt10':ComputerModernFontConstants,
931+
'lmr10':LatinModernFontConstants,
932+
'lmbx10':LatinModernFontConstants,
933+
'lmbx10':LatinModernFontConstants,
934+
'lmbxi10':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.
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,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp