예제 #1
0
 Android.Graphics.Paint.FontMetrics FontMetrics(string fontFamily, double fontSize, FontAttributes fontAttributes)
 {
     var typeface = FontManagment.TypefaceForFontFamily(fontFamily);
     var label = new Android.Widget.TextView(Settings.Context);
     Android.Graphics.TypefaceStyle style = Android.Graphics.TypefaceStyle.Normal;
     if (fontAttributes == FontAttributes.Bold)
         style = Android.Graphics.TypefaceStyle.Bold;
     else if (fontAttributes == FontAttributes.Italic)
         style = Android.Graphics.TypefaceStyle.Italic;
     else if (fontAttributes != FontAttributes.None)
         style = Android.Graphics.TypefaceStyle.BoldItalic;
     label.SetTypeface(typeface, style);
     var fontMetrics = label.Paint.GetFontMetrics();
     return fontMetrics;
 }
예제 #2
0
#pragma warning disable IDE0060 // Remove unused parameter
        Android.Graphics.Paint.FontMetrics FontMetrics(string fontFamily, double fontSize, FontAttributes fontAttributes)
#pragma warning restore IDE0060 // Remove unused parameter
        {
            using (var typeface = FontManagment.TypefaceForFontFamily(fontFamily))
                using (var label = new Android.Widget.TextView(Settings.Context))
                {
                    Android.Graphics.TypefaceStyle style = Android.Graphics.TypefaceStyle.Normal;
                    if (fontAttributes == FontAttributes.Bold)
                    {
                        style = Android.Graphics.TypefaceStyle.Bold;
                    }
                    else if (fontAttributes == FontAttributes.Italic)
                    {
                        style = Android.Graphics.TypefaceStyle.Italic;
                    }
                    else if (fontAttributes != FontAttributes.None)
                    {
                        style = Android.Graphics.TypefaceStyle.BoldItalic;
                    }
                    label.SetTypeface(typeface, style);
                    var fontMetrics = label.Paint.GetFontMetrics();
                    return(fontMetrics);
                }
        }