Print with your own font using C#

CsharpProgrammingServer Side Programming

To print your own font in C#, firstly construct −

  • FontFamily object
  • Font Object

The FontFamily object sets the typeface like Arial, TimesNewRoman, etc, whereas the Font object sets the size and style of font.

Let us create an Arial font style.

FontFamily myFontFamily = new FontFamily("Arial");
Font myFont = new Font(
myFontFamily,
20,
FontStyle.Bold,
GraphicsUnit.Pixel);

Above, we have set the FontFamily object. The first parameter passed to the Font() is the FontFamily object “myFontFamily”, then comes the size of the font. The third argument sets the style.

raja
Published on 14-Aug-2018 14:00:58
Advertisements