Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of Chinese display garbled in OxyPlot.SkiaSharp

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "How to solve the problem of OxyPlot.SkiaSharp Chinese display garbled code," the explanation content in this article is simple and clear, easy to learn and understand, please follow the idea of small editor slowly in-depth, together to study and learn "How to solve OxyPlot.SkiaSharp Chinese display garbled code problem" bar!

Oxyplot chart controls are powerful and widely used. Recently, considering the performance, OxyPlot.SkiaSharp was used instead of OxyPlot.WPF, and the preliminary test of curve chart showed that the performance was improved by nearly 10 times. SkiaSharp graphics engine based on some of the controls often encounter Chinese garbled problems, so when using OxyPlot.SkiaSharp also have the heart prepared. By default the Chinese display is really garbled. This is shown below.

So I flipped through the OxyPlot.SkiaSharp source code and saw that the default value of the DefaultFont attribute in PlotModel is "Segoe UI", a Western sans serif. Try to change it to "Microsoft Yahei," Chinese display is normal. This is shown below.

Why is OxyPlot.WPF showing no problem? After changing TextBlock font to ALGERIAN font in WPF, only English font is applied, while Chinese font is displayed in another font. This is shown below.

We know that the default font of WPF is also "Segoe UI", why there is no problem with the display, this is to mention the mechanism of WPF application font.

The WPF application uses the attributes FontFamily, FontStyle, FontWeight, FontStretch, and FontSize to specify the font it wants. At runtime, WPF determines the exact font to use on the target system on which the application runs. This decision is based on matching the first four attributes (ignoring FontSize for now) to the physical font files installed on the system.

WPF first matches the supplied FontFamily with font names found in the system. It then tries to find a font that is closest to the requested FontStretch, FontStyle, and FontWeight attribute values. Matching FontStretch is the highest priority, followed by FontStyle and then FontWeight.

If WPF cannot find a matching font, it will "fall back" to the default font installed with WPF, i.e.

C:\Windows\Fonts\GlobalUserInterface.CompositeFont

This is a compound font that attempts to map individual characters to fonts that may exist on the system. That is to say, Chinese and English are mapped separately to different fonts.

Thank you for reading, the above is "how to solve OxyPlot.SkiaSharp Chinese display garbled code problem" content, after the study of this article, I believe we have a deeper understanding of how to solve OxyPlot.SkiaSharp Chinese display garbled code problem, the specific use of the situation still needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report