Skip to content

SP5: Fonts.Default and Fonts.Detect()#2753

Merged
swharden merged 10 commits intomainfrom
2746
Jul 15, 2023
Merged

SP5: Fonts.Default and Fonts.Detect()#2753
swharden merged 10 commits intomainfrom
2746

Conversation

@swharden
Copy link
Member

adds support for international character sets

adds support for international character sets

resolves #2746
@swharden
Copy link
Member Author

After reviewing the feedback I got and thinking about this problem some more, I decided to simplify this class. The user can handle fancy things like font lookups and fallback logic. I'll merge it in like it is now, but I welcome continued feedback and am happy to change it with a new PR/issue if improvements can be made.

Default

ScottPlot.Plot plt = new();
plt.Add.Signal(Generate.Sin());
plt.Add.Signal(Generate.Cos());
plt.TopAxis.Label.Text = Fonts.Default;
plt.BottomAxis.Label.Text = "Horizontal Axis";
plt.LeftAxis.Label.Text = "Vertical Axis";

image

Changing the Default

Fonts.Default = "Comic Sans MS";

ScottPlot.Plot plt = new();
plt.Add.Signal(Generate.Sin());
plt.Add.Signal(Generate.Cos());
plt.TopAxis.Label.Text = Fonts.Default;
plt.BottomAxis.Label.Text = "Horizontal Axis";
plt.LeftAxis.Label.Text = "Vertical Axis";

image

Best Font Identification

Fonts.Default = Fonts.Detect('频') ?? Fonts.System;

ScottPlot.Plot plt = new();
plt.Add.Signal(Generate.Sin());
plt.Add.Signal(Generate.Cos());
plt.TopAxis.Label.Text = "频率信号削减1/32";
plt.BottomAxis.Label.Text = "Horizontal Axis";
plt.LeftAxis.Label.Text = "Vertical Axis";

image

@swharden swharden changed the title SP5: FontService.SetDefaultFont() SP5: Font.Default, Font.Exists(), and Font.Detect() Jul 15, 2023
@swharden swharden changed the title SP5: Font.Default, Font.Exists(), and Font.Detect() SP5: Fonts.Default, Fonts.Exists(), and Fonts.Detect() Jul 15, 2023
@swharden swharden changed the title SP5: Fonts.Default, Fonts.Exists(), and Fonts.Detect() SP5: Fonts.Default and Fonts.Detect() Jul 15, 2023
@swharden swharden changed the title SP5: Fonts.Default and Fonts.Detect() SP5: Fonts.Default and Fonts.Detect() Jul 15, 2023
@swharden swharden enabled auto-merge July 15, 2023 06:18
@swharden swharden merged commit c1cb0b0 into main Jul 15, 2023
@swharden swharden deleted the 2746 branch July 15, 2023 06:38
@heartacker
Copy link
Contributor

I still believe that we should render correctly for all of user, not be beautiful firstly

@swharden
Copy link
Member Author

I still believe that we should render correctly for all of user, not be beautiful firstly

Thanks for being persistent about this point! I improved it by always favoring the system default font (and only using Open Sans if the default font is Segoe UI)

e83eeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SP5: Improve support for Chinese characters

3 participants