0

I need to write some text with pango-sharp, but depending on the number of characters scale the width.

This is what I currently have:

var layout = new Pango.Layout (Core.PangoContext);
layout.FontDescription = Pango.FontDescription.FromString (
  "'Courier New' CLM  20");
layout.SetMarkup (@"<span  color='black'>12</span>");
Area.GdkWindow.DrawLayout (Core.Area.Style.TextGC (
  StateType.Normal), 50, 50, layout);

I was not able to find any hints on accomplishing that. I have found only a XY Scale in Pango, but no Scale just on X or Y.

skolima
  • 31,963
  • 27
  • 115
  • 151
l2rek
  • 32
  • 1
  • 5

1 Answers1

0

Finally found a solution:

(cc=cairocontext)

layout.FontDescription = Pango.FontDescription.FromString ("Courier New CLM  " + FontSize);
layout.SetText (Position.ToString ());
cc.Scale (1, 1);
cc.MoveTo (NoteCenterX, NoteCenterY - 12);

cc.Scale (ScaleX, 1);
Pango.CairoHelper.ShowLayout (cc, layout);
cc.Scale (1 / ScaleX, 1);
l2rek
  • 32
  • 1
  • 5