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

Add Latin Modern support for mathtext#26240

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

Open
devRD wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromdevRD:lmfont
Open
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
43 changes: 43 additions & 0 deletionslib/matplotlib/_mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -640,6 +640,43 @@ class DejaVuSerifFonts(DejaVuFonts):
}


class LatinModernFonts(UnicodeFonts):
"""
A font handling class for the Latin Modern fonts

"""
_fontmap = {
'rm': 'Latin Modern Roman',
'it': 'Latin Modern Roman:italic',
'bf': 'Latin Modern Roman:weight=bold',
'bfit': 'Latin Modern Roman:italic:bold',
'tt': 'Latin Modern Mono',
'sf': 'Latin Modern Sans',
'ex': 'Latin Modern Math'
}
_fallback_font = False
_sans = False

def __init__(self, *args, **kwargs):
# This must come first so the backend's owner is set correctly
self.fontmap = {}
TruetypeFonts.__init__(self, *args, **kwargs)

for key, name in self._fontmap.items():
fullpath = findfont(name)
self.fontmap[key] = fullpath
self.fontmap[name] = fullpath

def _get_glyph(self, fontname, font_class, sym):
uniindex = get_unicode_index(sym)
font = self._get_font(fontname)
if font is not None:
glyphindex = font.get_char_index(uniindex)
if glyphindex != 0:
return super()._get_glyph(fontname, font_class, sym)
return super()._get_glyph('ex', font_class, sym)


class DejaVuSansFonts(DejaVuFonts):
"""
A font handling class for the DejaVu Sans fonts
Expand DownExpand Up@@ -841,6 +878,10 @@ class FontConstantsBase:
delta_integral = 0.1


class LatinModernFontConstants(FontConstantsBase):
pass


class ComputerModernFontConstants(FontConstantsBase):
script_space = 0.075
subdrop = 0.2
Expand DownExpand Up@@ -888,6 +929,8 @@ class DejaVuSansFontConstants(FontConstantsBase):
'cmss10': ComputerModernFontConstants,
'cmsy10': ComputerModernFontConstants,
'cmtt10': ComputerModernFontConstants,
'Latin Modern Roman': LatinModernFontConstants,
'Latin Modern Math': LatinModernFontConstants,
'STIXGeneral': STIXFontConstants,
'STIXNonUnicode': STIXFontConstants,
'STIXSizeFiveSym': STIXFontConstants,
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/font_manager.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -562,7 +562,7 @@ class FontProperties:
absolute font size, e.g., 10. Default: :rc:`font.size`

- math_fontfamily: The family of fonts used to render math text.
Supported values are: 'dejavusans', 'dejavuserif', 'cm',
Supported values are: 'lm', 'dejavusans', 'dejavuserif', 'cm',
'stix', 'stixsans' and 'custom'. Default: :rc:`mathtext.fontset`

Alternatively, a font may be specified using the absolute path to a font
Expand Down
1 change: 1 addition & 0 deletionslib/matplotlib/mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,7 @@ class MathTextParser:
'dejavusans': _mathtext.DejaVuSansFonts,
'stix': _mathtext.StixFonts,
'stixsans': _mathtext.StixSansFonts,
'lm': _mathtext.LatinModernFonts,
'custom': _mathtext.UnicodeFonts,
}

Expand Down
28 changes: 28 additions & 0 deletionslib/matplotlib/mpl-data/fonts/ttf/LICENSE_GUST_FONT.TXT
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
% This is version 1.0, dated 22 June 2009, of the GUST Font License.
% (GUST is the Polish TeX Users Group, http://www.gust.org.pl)
%
% For the most recent version of this license see
% http://www.gust.org.pl/fonts/licenses/GUST-FONT-LICENSE.txt
% or
% http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt
%
% This work may be distributed and/or modified under the conditions
% of the LaTeX Project Public License, either version 1.3c of this
% license or (at your option) any later version.
%
% Please also observe the following clause:
% 1) it is requested, but not legally required, that derived works be
% distributed only after changing the names of the fonts comprising this
% work and given in an accompanying "manifest", and that the
% files comprising the Work, as listed in the manifest, also be given
% new names. Any exceptions to this request are also given in the
% manifest.
%
% We recommend the manifest be given in a separate file named
% MANIFEST-<fontid>.txt, where <fontid> is some unique identification
% of the font family. If a separate "readme" file accompanies the Work,
% we recommend a name of the form README-<fontid>.txt.
%
% The latest version of the LaTeX Project Public License is in
% http://www.latex-project.org/lppl.txt and version 1.3c or later
% is part of all distributions of LaTeX version 2006/05/20 or later.
View file
Open in desktop
Binary file not shown.
View file
Open in desktop
Binary file not shown.
View file
Open in desktop
Binary file not shown.
Binary file addedlib/matplotlib/mpl-data/fonts/ttf/lmr10.otf
View file
Open in desktop
Binary file not shown.
View file
Open in desktop
Binary file not shown.
Binary file addedlib/matplotlib/mpl-data/fonts/ttf/lmss10.otf
View file
Open in desktop
Binary file not shown.
Binary file addedlib/matplotlib/mpl-data/fonts/ttf/lmtt10.otf
View file
Open in desktop
Binary file not shown.
4 changes: 2 additions & 2 deletionslib/matplotlib/mpl-data/matplotlibrc
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -267,7 +267,7 @@
#font.size: 10.0

#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
#font.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
#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
#font.cursive: Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, Comic Neue, Comic Sans MS, cursive
#font.fantasy: Chicago, Charcoal, Impact, Western, Humor Sans, xkcd, fantasy
#font.monospace: DejaVu Sans Mono, Bitstream Vera Sans Mono, Computer Modern Typewriter, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace
Expand DownExpand Up@@ -335,7 +335,7 @@
## The following settings allow you to select the fonts in math mode.
#mathtext.fontset: dejavusans # Should be 'dejavusans' (default),
# 'dejavuserif', 'cm' (Computer Modern), 'stix',
# 'stixsans' or'custom'
# 'stixsans','custom', 'lm' (Latin Modern)
## "mathtext.fontset: custom" is defined by the mathtext.bf, .cal, .it, ...
## settings which map a TeX font name to a fontconfig font pattern. (These
## settings are not used for other font sets.)
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/rcsetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1004,8 +1004,8 @@ def _convert_validator_spec(key, conv):
"mathtext.bf": validate_font_properties,
"mathtext.bfit": validate_font_properties,
"mathtext.sf": validate_font_properties,
"mathtext.fontset": ["dejavusans", "dejavuserif", "cm", "stix",
"stixsans", "custom"],
"mathtext.fontset": ["dejavusans", "dejavuserif", "lm", "cm",
"stix", "stixsans", "custom"],
"mathtext.default": ["rm", "cal", "bfit", "it", "tt", "sf", "bf", "default",
"bb", "frak", "scr", "regular"],
"mathtext.fallback": _validate_mathtext_fallback,
Expand Down
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
View file
Open in desktop
2 changes: 1 addition & 1 deletionlib/matplotlib/tests/test_mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -247,7 +247,7 @@ def test_mathtext_rendering_lightweight(baseline_images, fontset, index, text):
@pytest.mark.parametrize(
'index, text', enumerate(font_tests), ids=range(len(font_tests)))
@pytest.mark.parametrize(
'fontset', ['cm', 'stix', 'stixsans', 'dejavusans', 'dejavuserif'])
'fontset', ['lm', 'cm', 'stix', 'stixsans', 'dejavusans', 'dejavuserif'])
@pytest.mark.parametrize('baseline_images', ['mathfont'], indirect=True)
@image_comparison(baseline_images=None, extensions=['png'],
tol=0.011 if platform.machine() in ('ppc64le', 's390x') else 0)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp