-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(skiawpf): Added support for FontWeight, FontStyle & FontStretch.…
… Works only with Font Families, not when specifying font file directly.
- Loading branch information
1 parent
9801c51
commit 03698ab
Showing
3 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using SkiaSharp; | ||
|
||
namespace Windows.UI.Text | ||
{ | ||
internal static class FontStyleExtensions | ||
{ | ||
public static SKFontStyleSlant ToSkiaSlant(this FontStyle style) => | ||
style switch | ||
{ | ||
FontStyle.Italic => SKFontStyleSlant.Italic, | ||
FontStyle.Normal => SKFontStyleSlant.Upright, | ||
FontStyle.Oblique => SKFontStyleSlant.Oblique, | ||
_ => SKFontStyleSlant.Upright | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using SkiaSharp; | ||
|
||
namespace Windows.UI.Text | ||
{ | ||
partial struct FontWeight | ||
{ | ||
public SKFontStyleWeight ToSkiaWeight() | ||
{ | ||
// Uno weight values are using the same system, | ||
// so we can convert directly to Skia system | ||
// without need for a mapping. | ||
return (SKFontStyleWeight)this.Weight; | ||
} | ||
} | ||
} |