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);
}