Esempio n. 1
0
 private SSPosition drawLabel(SSLabel label, SKCanvas canvas, SSPosition position)
 {
     using (SKPaint paint = new SKPaint()) {
         paint.TextSize    = label.fontSize;
         paint.IsAntialias = true;
         paint.Typeface    = getFont(label);
         SKColor.TryParse(label.color, out SKColor color);
         color       = color.WithAlpha(label.alpha);
         paint.Color = color;
         float height = label.fontSize;
         canvas.DrawText(label.text, position.x, position.y, paint);
         position.x += paint.MeasureText(label.text);
         return(position);
     }
 }
Esempio n. 2
0
 private SKTypeface getFont(SSLabel label)
 {
     try {
         if (label.fontName.Contains(".ttf"))
         {
             return(SKTypeface.FromFile(label.fontName));
         }
         else
         {
             return(SKTypeface.FromFamilyName(label.fontName,
                                              label.styleWeight, label.styleWidth, label.styleSlant));
         }
     } catch (Exception ex) {
         Print.Error(ex.Message);
         return(SKTypeface.FromFamilyName("Roboto"));
     }
 }