Search code examples
c#scale

Text/Font scaling on page printing


I would like to scale a lable/text when printing.

Below is the sample code i am using:

Graphics g = new Graphics();

g.ScaleTransform(1,2); //scale 200% at Y direction

g.DrawString(myText, myFont, myBrush, pointX, pointY); // pointX = 10; pointY = 5

The text is scaled to 200% at Y direction, but the location/point/coordinate of the text is being scale as well.

I want the text to be scaled without changing the pointX and PointY.

How to do that?


Solution

  • Please try:

    g.TranslateTransform(pointX, pointY);
    g.ScaleTransform(1, 2);
    g.TranslateTransform(-pointX, -pointY);
    
    g.DrawString(myText, myFont, myBrush, pointX, pointY);