Tag Archives: fonts

Get font size in pixels in C#

One oddity of the Font class is that its Size property returns font size in the units that were used to create the font. The Font class’s Unit property tells you the units used to create the font, but if … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , , , , , | Leave a comment

Draw smooth text in a GraphicsPath in C#

You can set a Graphics object’s TextRenderingHint property to AntiAliasGridFit to draw smooth text. However, if you place text in a GraphicsPath object and draw the GraphicsPath, then the TextRenderingHint property doesn’t give you smooth text. Instead you need to … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , , , , | 1 Comment

Make pop buttons in C#

This example produces an interesting visual effect that I call “pop buttons.” The buttons grow and shrink when the mouse moves over them. The technique is remarkably simple and adds some extra interactivity to an otherwise ordinary program. The program’s … Continue reading

Posted in controls, fonts, user interface | Tagged , , , , , , , , , , , , , , , | Leave a comment

Understand AutoScaleMode in C#

A form’s AutoScaleMode property lets a form automatically resize itself when its font changes. This can be particularly useful with an aging user population that may have trouble seeing smaller fonts. To try to help users out, you can give … Continue reading

Posted in fonts, forms, graphics | Tagged , , , , , , , , , , | 1 Comment

Draw transformed text in C#

This example uses the following Paint event handler to draw transformed text. // Draw some transformed text. private void Form1_Paint(object sender, PaintEventArgs e) { // Transform. e.Graphics.ScaleTransform(1.5f, 1.5f, MatrixOrder.Append); e.Graphics.RotateTransform(25, MatrixOrder.Append); e.Graphics.TranslateTransform(80, 30, MatrixOrder.Append); // Make a font. using (Font … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , | 2 Comments

Easily draw rotated text on a form in C#

The example Draw rotated text in C# shows how to draw rotated text. Unfortunately that method requires you to use code at run time to position the text. It’s not too hard but it’s inconvenient if you’re trying to draw … Continue reading

Posted in fonts, forms, graphics | Tagged , , , , , , , , , , , , | 1 Comment

Draw numbered buttons and save them into files in C#

This example is very similar to the previous one Draw numbered circles and save them into files in C# except it draws its circles so they look like numbered buttons. The following code shows how the program draws the circles’ … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , | 4 Comments

Draw numbered circles and save them into files in C#

Sometimes I need to draw numbered circles to place on pictures that I’m going to use in books or articles. This program lets me draw circles that look nice, that are smoothly shaded, and that have transparent backgrounds. The MakeNumberBitmap … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , | 3 Comments

Set font size to fit a wrapped label in C#

The example Set font size to fit a label in C# shows how you can pick a font size to make text large but still fit inside a Label. This example is similar except it allows the text to wrap … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , , , , , | Leave a comment

Set font size to fit a label in C#

This program uses the following method to calculate the largest font size that the Label can use while still allowing the sample text to fit. // Return the largest font size that lets the text fit. private float GetFontSize(Label label, … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , , , | Leave a comment