Skip to content

Commit 5528e64

Browse files
committed
Python
: use Nimbux Roman on Linux platforms
1 parent ade5cf1 commit 5528e64

File tree

1 file changed

+71
-20
lines changed

1 file changed

+71
-20
lines changed

Utilities/Python/fdsplotlib.py

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -722,26 +722,77 @@ def plot_to_fig(x_data,y_data,**kwargs):
722722

723723
import matplotlib.pyplot as plt
724724
import matplotlib.ticker as ticker
725-
726-
plt.rcParams.update({
727-
"pdf.use14corefonts": True,
728-
"text.usetex": False,
729-
730-
# Text and math in Times New Roman
731-
"font.family": "serif",
732-
"font.serif": ["Times", "Times New Roman"],
733-
734-
"mathtext.fontset": "custom",
735-
"mathtext.rm": "Times",
736-
"mathtext.it": "Times New Roman:italic",
737-
"mathtext.bf": "Times:bold",
738-
"mathtext.cal": "Times New Roman:italic",
739-
"mathtext.tt": "Courier New",
740-
"mathtext.default": "it",
741-
742-
"axes.unicode_minus": False,
743-
"pdf.compression": 9,
744-
})
725+
import platform
726+
727+
def configure_fds_fonts():
728+
system = platform.system()
729+
730+
if system == "Linux":
731+
# Linux: use Nimbus Roman as primary serif, with Times ahead of Times New Roman in the fallback chain
732+
primary_serif = "Nimbus Roman"
733+
serif_list = [
734+
"Nimbus Roman", # primary on Linux
735+
"Times",
736+
"Times New Roman",
737+
"serif",
738+
]
739+
else:
740+
# macOS ("Darwin") and Windows: prefer Times, then Times New Roman
741+
primary_serif = "Times"
742+
serif_list = [
743+
"Times", # first choice
744+
"Times New Roman",
745+
"Nimbus Roman",
746+
"serif",
747+
]
748+
749+
plt.rcParams.update({
750+
# Core-14 fonts for small PDFs (Times-Roman in output)
751+
"pdf.use14corefonts": True,
752+
"text.usetex": False,
753+
754+
# Make serif the default everywhere
755+
"font.family": "serif",
756+
"font.serif": serif_list,
757+
758+
# If something explicitly requests 'sans-serif', try to keep it Times-like too
759+
"font.sans-serif": serif_list,
760+
761+
# Math text: follow the same primary serif
762+
"mathtext.fontset": "custom",
763+
"mathtext.rm": primary_serif,
764+
"mathtext.it": f"{primary_serif}:italic",
765+
"mathtext.bf": f"{primary_serif}:bold",
766+
"mathtext.cal": f"{primary_serif}:italic",
767+
"mathtext.tt": "Courier",
768+
"mathtext.default": "rm",
769+
770+
"axes.unicode_minus": False,
771+
"pdf.compression": 9,
772+
})
773+
774+
775+
configure_fds_fonts()
776+
777+
# plt.rcParams.update({
778+
# "pdf.use14corefonts": True,
779+
# "text.usetex": False,
780+
781+
# # Text and math in Times New Roman
782+
# "font.family": "serif",
783+
# "font.serif": ["Times", "Times New Roman"],
784+
785+
# "mathtext.fontset": "custom",
786+
# "mathtext.rm": "Times",
787+
# "mathtext.it": "Times New Roman:italic",
788+
# "mathtext.bf": "Times:bold",
789+
# "mathtext.cal": "Times New Roman:italic",
790+
# "mathtext.tt": "Courier New",
791+
# "mathtext.default": "it",
792+
793+
# "axes.unicode_minus": False,
794+
# "pdf.compression": 9,
795+
# })
745796

746797
import logging
747798
# Suppress just the 'findfont' warnings from matplotlib's font manager

0 commit comments

Comments
 (0)