ImageDraw Font objects – represented by Neodynamic.SDK.Font class – are used for displaying text on TextElement and ShapeElement objects.
ImageDraw Font objects not only let you to use Windows System installed fonts (%windir%\Fonts folder) but also let you to use custom font files (*.ttf) stored in local disk.
ImageDraw Fonts
Using Windows installed fonts
You can create ImageDraw Font objects by choosing one of the Windows installed fonts which are available in %windir%\Fonts folder. To do that, just set up the Name property of Font class to a string representation of the face name of the installed font. For example, one of the most commonly used Windows installed font is called "Arial". That font is stored in ARIAL.TTF file under %windir%\Fonts folder. The typeface name for such font is just "Arial". So, if you want to use that installed font to create an ImageDraw Font object, then you must set up the Name property to "Arial" string.
Note
If you select an installed font from your development machine, then you must be sure the same font is installed in the Windows System where your .NET Application will be hosted and run. If the font is missing and you cannot install it on the target system, then you might consider trying "Using Custom Font Files (*.ttf)" approach which is described below.
If you select an installed font from your development machine, then you must be sure the same font is installed in the Windows System where your .NET Application will be hosted and run. If the font is missing and you cannot install it on the target system, then you might consider trying "Using Custom Font Files (*.ttf)" approach which is described below.
Using Custom Font Files (*.ttf)
In some situations, it's possible you want or need to use fonts that are not installed in the Windows System where your .NET Application is running on. For such cases, ImageDraw Font objects let you to render text by using font files (*.ttf) that are not installed in the Windows System but are located in any local folders of target machine.
To create ImageDraw Font objects from custom font files, just set up the CustomFontFile property of Font class. You can specify the CustomFonFile property as a relative URL or full path string pointing out to the custom font file on the Windows System disk or; as an identifier stored in the appSettings section of the Configuration file (*.config) of your .NET application.
Example of Custom Font Files in ASP.NET Web Applications:
To create ImageDraw Font objects from custom font files, just set up the CustomFontFile property of Font class. You can specify the CustomFonFile property as a relative URL or full path string pointing out to the custom font file on the Windows System disk or; as an identifier stored in the appSettings section of the Configuration file (*.config) of your .NET application.
Example of Custom Font Files in ASP.NET Web Applications:
- Adding Custom Font File to website structure:
Suppose we have a folder named MyFonts under our website root folder and a custom font file named Simpsonsfont.TTF inside it as is shown in the following figure:
Note
The Simpsonsfont.ttf file and author info is available at http://www.sharkshock.com/fonts/fontscar.html
- Creating an ImageDraw Font from Custom Font File:
Suppose we want to create a simple TextElement displaying the text "Hello World" by using the "Simpsonsfont.ttf" file. As mentioned before, in order to create an ImageDraw Font object from a custom font file, you must set up the CustomFonFile property of Font class. You can set up CustomFonFile property in two ways:
- Directly specifying the custom font file's relative URL to CustomFonFile property. Example:
- Configure custom font file's relative URL in the Web.config file and then set the configuration key to CustomFonFile property. Example:
Either of the aforementioned settings will produce the following TextElement output i.e. featuring text that is dispalyed by using a custom font file:
- Directly specifying the custom font file's relative URL to CustomFonFile property. Example:
Font Size and Style
ImageDraw Font objects support the following additional features regarding Style and Size.
- Font Styles
ImageDraw Font objects can be set so they look bold, italic, underline, and strikeout. - Font Size and Unit
The font size value will depend on the font unit which can be set to Point, Inch, Millimeter, or Pixel.
Neodynamic ImageDraw SDK for .NET Documentation
Copyright © 2003 - 2008 Neodynamic - All rights reserved.
Copyright © 2003 - 2008 Neodynamic - All rights reserved.