Example #1
0
        internal void Initialize(FontFamily genericSansSerif, float size, FontStyle bold = FontStyle.Regular,
                                 GraphicsUnit pixel   = GraphicsUnit.Point, byte gdiCharSet = 0,
                                 bool gdiVerticalFont = false)
        {
            try {
                var loader = SKTypeface.Default;

                nativeFont = new SKPaint()
                {
                    Typeface  = SKTypeface.FromFamilyName(genericSansSerif?.Name), TextSize = size,
                    TextAlign = SKTextAlign.Left
                };

                if (nativeFont.Typeface == null)
                {
                    nativeFont.Typeface = genericSansSerif.ToSKTypeface();
                    if (nativeFont.Typeface == null)
                    {
                        nativeFont.Typeface = SKTypeface.Default;
                    }
                }

                FontFamily = new FontFamily()
                {
                    Name = nativeFont.Typeface.FamilyName
                };
                Name = nativeFont.Typeface.FamilyName;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Style = bold;
            Unit  = pixel;
            Size  = size;
        }