public static SKTypeface FromFamilyName( string familyName, SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) { return(new() { FamilyName = familyName, FontWeight = weight, FontWidth = width, Style = slant }); }
private static SKPaint CreatePaint(SKColor color, string fontName, SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) { SKTypeface font = SKTypeface.FromFamilyName(fontName, weight, width, slant); SKPaint paint = new SKPaint { IsAntialias = true, Color = color, Typeface = font, TextSize = 18 }; return(paint); }
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { switch (inputData) { case SKTypeface t: return(t); case string s: return(WCUtils.FontManager.MatchFamily(s, SKFontStyle.Normal)); default: IEnumerable properties = null; if (inputData is Hashtable ht) { properties = ht; } else { properties = PSObject.AsPSObject(inputData).Properties; } SKFontStyle style; if (properties.GetValue("FontWeight") == null || properties.GetValue("FontSlant") == null || properties.GetValue("FontWidth") == null) { SKFontStyleWeight weight = properties.GetValue("FontWeight") == null ? SKFontStyleWeight.Normal : LanguagePrimitives.ConvertTo <SKFontStyleWeight>( properties.GetValue("FontWeight")); SKFontStyleSlant slant = properties.GetValue("FontSlant") == null ? SKFontStyleSlant.Upright : LanguagePrimitives.ConvertTo <SKFontStyleSlant>( properties.GetValue("FontSlant")); SKFontStyleWidth width = properties.GetValue("FontWidth") == null ? SKFontStyleWidth.Normal : LanguagePrimitives.ConvertTo <SKFontStyleWidth>( properties.GetValue("FontWidth")); style = new SKFontStyle(weight, width, slant); } else { var customStyle = properties.GetValue("FontStyle") as SKFontStyle; style = customStyle == null ? SKFontStyle.Normal : customStyle; } string familyName = LanguagePrimitives.ConvertTo <string>(properties.GetValue("FamilyName")); return(WCUtils.FontManager.MatchFamily(familyName, style)); } }
private static SKTypeface FromFamilyName( string name, SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) { if (name.StartsWith(XamlFilePathHelper.AppXIdentifier)) { var path = new Uri(name).PathAndQuery; var filePath = global::System.IO.Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, path.TrimStart('/').Replace('/', global::System.IO.Path.DirectorySeparatorChar)); var font = SKTypeface.FromFile(filePath); return(font); } else { return(SKTypeface.FromFamilyName(name, weight, width, slant)); } }
private static SKTypeface FromFamilyName( string name, SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) { if (name.StartsWith(XamlFilePathHelper.AppXIdentifier)) { var path = new Uri(name).PathAndQuery; var filePath = global::System.IO.Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, path.TrimStart('/').Replace('/', global::System.IO.Path.DirectorySeparatorChar)); var font = SKTypeface.FromFile(filePath); return(font); } else { if (string.Equals(name, "XamlAutoFontFamily", StringComparison.OrdinalIgnoreCase)) { return(SKTypeface.FromFamilyName(null, weight, width, slant)); } var typeFace = SKTypeface.FromFamilyName(name, weight, width, slant); // FromFontFamilyName may return null: https://github.com/mono/SkiaSharp/issues/1058 if (typeFace == null) { if (typeof(TextVisual).Log().IsEnabled(LogLevel.Warning)) { typeof(TextVisual).Log().LogWarning($"The font {name} could not be found, using system default"); } typeFace = SKTypeface.FromFamilyName(null, weight, width, slant); } return(typeFace); } }
public static SKTypeface FromFamilyName(string familyName, SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) { return(FromFamilyName(familyName, (int)weight, (int)width, slant)); }
public SKTypeface MatchCharacter(string familyName, SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant, string[] bcp47, int character) { return(MatchCharacter(familyName, new SKFontStyle(weight, width, slant), bcp47, character)); }
public SKTypeface?FromFamilyName(string fontFamily, SKFontStyleWeight fontWeight, SKFontStyleWidth fontWidth, SKFontStyleSlant fontStyle) { var skTypeface = default(SKTypeface); var fontFamilyNames = fontFamily?.Split(',')?.Select(x => x.Trim().Trim(s_fontFamilyTrim))?.ToArray(); if (fontFamilyNames != null && fontFamilyNames.Length > 0) { foreach (var fontFamilyName in fontFamilyNames) { if (fontFamily == FamilyName) { skTypeface = Typeface; break; } } } return(skTypeface); }
public static SKTypeface FromFamilyName (string familyName, SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) { return FromFamilyName(familyName, (int)weight, (int)width, slant); }
public SKFontStyle(SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) : this((int)weight, (int)width, slant) { }
internal SKFontStyleStatic(SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) : base(weight, width, slant) { IgnorePublicDispose = true; }
public SKTypeface?FromFamilyName(string fontFamily, SKFontStyleWeight fontWeight, SKFontStyleWidth fontWidth, SKFontStyleSlant fontStyle) { var skTypeface = default(SKTypeface); var fontFamilyNames = fontFamily?.Split(',')?.Select(x => x.Trim().Trim(s_fontFamilyTrim))?.ToArray(); if (fontFamilyNames != null && fontFamilyNames.Length > 0) { var defaultName = SKTypeface.Default.FamilyName; var skFontManager = FontManager; var skFontStyle = new SKFontStyle(fontWeight, fontWidth, fontStyle); foreach (var fontFamilyName in fontFamilyNames) { var skFontStyleSet = skFontManager.GetFontStyles(fontFamilyName); if (skFontStyleSet.Count > 0) { skTypeface = skFontManager.MatchFamily(fontFamilyName, skFontStyle); if (skTypeface != null) { if (!defaultName.Equals(fontFamilyName, StringComparison.Ordinal) && defaultName.Equals(skTypeface.FamilyName, StringComparison.Ordinal)) { skTypeface.Dispose(); skTypeface = null; continue; } break; } } } } return(skTypeface); }
public SKTypeface?FromFamilyName(string fontFamily, SKFontStyleWeight fontWeight, SKFontStyleWidth fontWidth, SKFontStyleSlant fontStyle) { var skTypeface = default(SKTypeface); var fontFamilyNames = fontFamily?.Split(',')?.Select(x => x.Trim().Trim(s_fontFamilyTrim))?.ToArray(); if (fontFamilyNames is { } && fontFamilyNames.Length > 0)