SKFontManager returns "artificial" styles for fonts? #3257
Unanswered
ArcanoxDragon
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Maybe it just uses this? https://learn.microsoft.com/de-de/dotnet/api/skiasharp.skpaint.fakeboldtext?view=skiasharp-2.88&viewFallbackFrom=skiasharp-1.68.1 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am writing some code to work with Excel worksheets, and I need to know whether or not Excel will "synthesize" its own bold version of any particular font (if it does, text sizing works differently for that font). I was hoping I could query
SKFontManager.Default.GetFontStyles(...)
to determine if a font includes its own bold style, but I'm not getting the results I hoped.For example, the "Lucida Console" font does not have a bold style. There is a separate "Lucida Console Bold" font, which is not included with Windows (and is not present on my machine). If you use this font in Excel and set it to "Bold", Excel synthesizes a bold version which looks different than the official "Lucida Console Bold".
However, if I run the following code:
The
fontSupportsBold
variable istrue
, and I can see thatfontStyles
contains four variants: Oblique 400, Upright 400, Oblique 700, Upright 700.How is Skia(Sharp) finding a bold variant of Lucida Console? Is it somehow locating fonts in a location other than the Windows Fonts directory (
C:\Windows\Fonts
)? From what I can tell, it's using DirectWrite to query system fonts, but I'm not sure what is going on under the hood beyond that.If I attempt to use the "Bold" variant of Lucida Console returned by Skia to measure text, the measurement results are pretty different from how Excel is measuring the same text using the same font - Excel is clearly synthesizing its own bold variant.
As an addendum, I checked the actual font files installed on my own Windows machine (by browsing to
\\localhost\C$\Windows\Fonts
, which bypasses the stupid custom Explorer folder). There's one single Lucida Console font file -lucon.ttf
. According to fontdrop.info, this TTF file contains only the 400-weight typeface.Beta Was this translation helpful? Give feedback.
All reactions