@@ -708,6 +708,57 @@ def get_data(E, spec, start_idx):
708708 return y , col_names
709709
710710
711+ def configure_fds_fonts ():
712+ import matplotlib .pyplot as plt
713+ import platform
714+
715+ system = platform .system ()
716+
717+ if system == "Linux" :
718+ # Linux: use Nimbus Roman as primary serif, with Times ahead of Times New Roman in the fallback chain
719+ primary_serif = "Nimbus Roman"
720+ serif_list = [
721+ "Nimbus Roman" , # primary on Linux
722+ "Times" ,
723+ "Times New Roman" ,
724+ "serif" ,
725+ ]
726+ else :
727+ # macOS ("Darwin") and Windows: prefer Times, then Times New Roman
728+ primary_serif = "Times"
729+ serif_list = [
730+ "Times" , # first choice
731+ "Times New Roman" ,
732+ "Nimbus Roman" ,
733+ "serif" ,
734+ ]
735+
736+ plt .rcParams .update ({
737+ # Core-14 fonts for small PDFs (Times-Roman in output)
738+ "pdf.use14corefonts" : True ,
739+ "text.usetex" : False ,
740+
741+ # Make serif the default everywhere
742+ "font.family" : "serif" ,
743+ "font.serif" : serif_list ,
744+
745+ # If something explicitly requests 'sans-serif', try to keep it Times-like too
746+ "font.sans-serif" : serif_list ,
747+
748+ # Math text: follow the same primary serif
749+ "mathtext.fontset" : "custom" ,
750+ "mathtext.rm" : primary_serif ,
751+ "mathtext.it" : f"{ primary_serif } :italic" ,
752+ "mathtext.bf" : f"{ primary_serif } :bold" ,
753+ "mathtext.cal" : f"{ primary_serif } :italic" ,
754+ "mathtext.tt" : "Courier" ,
755+ "mathtext.default" : "rm" ,
756+
757+ "axes.unicode_minus" : False ,
758+ "pdf.compression" : 9 ,
759+ })
760+
761+
711762def plot_to_fig (x_data ,y_data ,** kwargs ):
712763 """
713764 Create a simple x,y plot and return the fig handle
@@ -718,59 +769,10 @@ def plot_to_fig(x_data,y_data,**kwargs):
718769 # for key, value in kwargs.items():
719770 # print ("%s == %s" %(key, value))
720771
721- plot_style = get_plot_style ("fds" )
722-
723772 import matplotlib .pyplot as plt
724773 import matplotlib .ticker as ticker
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- })
773774
775+ plot_style = get_plot_style ("fds" )
774776
775777 configure_fds_fonts ()
776778
0 commit comments