Reference > Methods > DefineFont Method

SharpPlot.DefineFont Method

Add a short code for a complex font definition.

Example

sp.DefineFont("AS","Arial,sans","filter:url(#MyShadow);opacity:0.8");

Overloads

Creating a stylesheet

This method may be used simply to define a ‘house style’ of fonts to save possible errors in typing the full name, and to make future change much simpler. You may give each font face a two-letter code, for example:

sp.DefineFont("VN","Verdana,sans");

From now on, you can use any of the four short codes ‘VN’ ‘VNB’ ‘VNI’ or ‘VNBI’ to get the four variants of this basic font. To have your Captions in Verdana,Italic, (at default size) you simply use:

sp.SetCaptionFont("VNI",Color.Teal);

If you are giving a long string of alternative font names for use as browser fall-backs, this clearly saves a good deal of typing. Longer abbreviations (up to 4 characters) will be accepted but may not be suffixed to make the variants.

Adding extra CSS details

SharpPlot allows you to insert any extra CSS properties you want after the font name. These are passed on to charts rendered as SVG or VML, and may be used for various special effects. They are ignored in images and PDF rendering.

sp.DefineFont("VN","Verdana,sans","opacity:0.8");

You can set any standard font property here, for example letter-spacing to open out heading text slightly.

Setting up PostScript equivalents

If you are generating an EPS document, you may need to map your screen font to a PostScript font known on the printer.

sp.DefineFont("VN","Verdana,sans","","Univers");

Check with the repro house to be sure you get the names exactly correct here!

See also ...

SharpPlot Members


Send comments on this topic
© Dyalog Ltd 2014