toptensoftware / RichTextKit

Rich text rendering for SkiaSharp
Other
367 stars 73 forks source link

Select Roboto Condensed as font for text #45

Open charlenni opened 2 years ago

charlenni commented 2 years ago

Hello,

I have the problem, that I don't find the Roboto Condensed font on my machine when selecting font family for my text. If I look into the fonts in the system manager or use Word, both can see the font. If I look into SKFontManager.FontFamilies I see only the Roboto font.

So I have to provide SKFontStyleWidth with SKFontStyleWidth.Condensed instead of SKFontStyleWidth.Normal. But how to do this with RichTextKit? Is this missing? Could it be, that this line is the problem?

Regards, Dirk

handerss-spotfire commented 1 year ago

You can supply the font width either by setting it via RichString.FontWidth() or by supplying it via the FontWidth property of the Style class when adding text to a TextBlock.

Skia will only show you the list of typographical font names when calling SKFontManager.FontFamilies. You can loop through the list and call SKFontManager.Default.GetFontStyles for each font to see which styles are available. Note that synthesized font styles (e.g. bold/italic versions of some fonts) will not be included, however they can be created via SKFontManager.Default.MatchTypeface.

toptensoftware commented 1 year ago

Hi @charlenni

Does @handerss-tibco answer help? Off hand, I'm not 100% sure what's going on here. Get back to me if you still can't get it to work and I'll look into it.

Brad