Neodynamic ImageDraw for ASP.NET
ImageDraw Fonts
ImageDraw Font objects – represented by Neodynamic.WebControls.ImageDraw.Font class – are used for displaying text on TextElement, WordArtElement and ShapeElement objects. ImageDraw Font objects not only let you to use Windows server's installed fonts (%windir%\Fonts folder) but also let you to use custom font files (*.ttf) stored in local folders under your website structure.


Using Windows Server installed fonts
You can create ImageDraw Font objects by choosing one of the Windows Server's 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 Server where your website will be hosted. If the font is missing and you cannot install it on the server, 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 Server where your ASP.NET website 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 Server but are located in any local folders under your website structure.

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 Server disk or; as an identifier stored in the appSettings section of Web.config file of your ASP.NET website.

Example of Custom Font Files:

  • 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:

    MyFonts folder under website root folder holding custom font file

    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:

    A TextElement object featuring custom font files

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.