Cairo.Context.GetScaledFont C# (CSharp) Метод

GetScaledFont() публичный Метод

public GetScaledFont ( ) : ScaledFont
Результат ScaledFont
        public ScaledFont GetScaledFont()
        {
            CheckDisposed ();
            return new ScaledFont (NativeMethods.cairo_get_scaled_font (handle), false);
        }

Usage Example

Пример #1
0
        protected override bool OnDrawn(Context cr)
        {
            cr.Rectangle(0, 0, AllocatedWidth, AllocatedHeight);
            cr.SetSourceColor(BackgroundColor);
            cr.Fill();

            cr.SelectFontFace(FontFamily, FontStyle, Cairo.FontWeight.Normal);
            cr.SetFontSize(FontSize);
            cr.SetSourceColor(Color);

            var te           = cr.TextExtents(Text);
            var charsPerLine = AllocatedWidth / te.Height;
            var lineCount    = Text.Length * charsPerLine;
            var totalHeight  = te.Height * lineCount + PaddingBottom + PaddingTop;

            if (totalHeight < AllocatedHeight)
            {
//        SetSizeRequest();
            }
            if (te.Width > AllocatedWidth)
            {
            }

            cr.MoveTo(PaddingLeft, PaddingTop + FontSize);
            cr.ShowText(Text);
//      var g = new Glyph();

//      Pango.CairoHelper.ShowGlyphString();
            Console.WriteLine(cr.TextExtents(Text).Width);
            Console.WriteLine(cr.TextExtents(Text).Height);

            var fontWidth  = cr.GetScaledFont().FontExtents.MaxXAdvance;
            var fontHeight = cr.GetScaledFont().FontExtents.Height;

//      7.201171875
//      13.5

//      cr.ShowGlyphs();
//      cr.ShowGlyphs();

//      for (var i = 0; i < lineCount; i++)
//      {
//        cr.ShowText(Text.Substring(
//          i * charsPerLine,
//          (i + 1) * charsPerLine));
//      }

            return(true);
        }