Cairo.Context.TextExtents C# (CSharp) Method

TextExtents() public method

public TextExtents ( byte utf8 ) : TextExtents
utf8 byte
return TextExtents
        public TextExtents TextExtents(byte[] utf8)
        {
            CheckDisposed ();
            TextExtents extents;
            NativeMethods.cairo_text_extents (handle, TerminateUtf8 (utf8), out extents);
            return extents;
        }

Same methods

Context::TextExtents ( string s ) : TextExtents

Usage Example

Ejemplo n.º 1
0
 public virtual void Paint(Context ctx)
 {
     PointD size = this.MeasureSize (ctx);
     PaintContour (ctx,size);
     KnownColors.SetFontFacePieceName(ctx);
     TextExtents te = ctx.TextExtents(this.Name), ten;
     double y0 = 0.5d*(size.Y-te.Width);
     ctx.MoveTo(0.5d*Margin,y0);
     ctx.Save();
     ctx.Rotate(0.5d*Math.PI);
     ctx.ShowText(this.Name);
     ctx.Restore();
     double x0 = Margin+te.Height;
     KnownColors.SetFontFaceNormal(ctx);
     te = ctx.TextExtents(OptionalString);
     y0 = 2.0d*Margin;
     int index = 0x00;
     PointD siz;
     foreach(IPuzzlePiece ipp in this.arguments) {
         ctx.Save();
         ctx.Translate(x0,Margin);
         if(ipp == null) {
             siz = new PointD(MinimumWidth,size.Y-4.0d*Margin);
             ctx.Rectangle(Margin,Margin,siz.X,siz.Y);
             ctx.Pattern = KnownColors.ConstructionPattern;
             ctx.FillPreserve();
         }
         else {
             siz = ipp.MeasureSize(ctx);
         }
         ctx.Rectangle(0.0d,0.0d,siz.X+2.0d*Margin,siz.Y+2.0d*Margin);
         ctx.Color = KnownColors.Black;
         ctx.StrokePreserve();
         if(ipp == null) {
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]);
             ctx.Fill();
             ctx.Translate(Margin,Margin);
             ctx.MoveTo(0.0d,0.0d);
             ctx.LineTo(MinimumWidth,0.0d);
             ctx.RelLineTo(0.0d,5.0d);
             ctx.LineTo(5.0d,5.0d);
             ctx.ClosePath();
             ctx.Pattern = KnownColors.ShadowDownPattern;
             ctx.Fill();
             ctx.MoveTo(0.0d,0.0d);
             ctx.LineTo(0.0d,siz.Y);
             ctx.RelLineTo(5.0d,0.0d);
             ctx.LineTo(5.0d,5.0d);
             ctx.ClosePath();
             ctx.Pattern = KnownColors.ShadowRightPattern;
             ctx.Fill();
         }
         else {
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]);
             ctx.Fill();
             ctx.Color = KnownColors.Black;
             ctx.Translate(Margin,Margin);
             ipp.Paint(ctx);
         }
         ctx.Restore();
         subpieces[index] = new Rectangle(x0+Margin,2.0d*Margin,siz.X,siz.Y);
         x0 += siz.X+3.0d*Margin;
         if(index >= NumberOfArguments-NumberOfOptionalArguments) {
             ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+te.Width),siz.Y+3.0d*Margin-2.0d);
             ctx.ShowText(OptionalString);
         }
         if(this.ArgumentNames != null && index < arguments.Length) {
             ten = ctx.TextExtents(this.ArgumentNames[index]);
             ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+ten.Width),-te.YBearing+Margin+2.0d);
             ctx.ShowText(this.ArgumentNames[index]);
         }
         index++;
     }
 }
All Usage Examples Of Cairo.Context::TextExtents