Example #1
0
        static SkiaFontInfo GetFontInfo(Font f)
        {
            var fi = f.Tag as SkiaFontInfo;

            if (fi == null)
            {
                var paint = new SKPaint();

                var name = "Helvetica";
                if (f.FontFamily == "Monospace")
                {
                    name = "Courier";
                }
                else if (f.FontFamily == "DBLCDTempBlack")
                {
#if __MACOS__
                    name = "Courier-Bold";
#else
                    name = f.FontFamily;
#endif
                }

                var tf = SKTypeface.FromFamilyName(name, f.IsBold ? SKTypefaceStyle.Bold : SKTypefaceStyle.Normal);
                fi = new SkiaFontInfo {
                    Typeface = tf,
                };
                ApplyFontToPaint(f, fi, paint);
                fi.FontMetrics = new SkiaFontMetrics(paint);
                f.Tag          = fi;
            }
            return(fi);
        }
Example #2
0
        static void ApplyFontToPaint(Font f, SkiaFontInfo fi, SKPaint p)
        {
            p.Typeface = fi.Typeface;
            p.TextSize = f.Size;

            if (fi.FontMetrics == null)
            {
                fi.FontMetrics = new SkiaFontMetrics(p);
            }
        }