| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Class for working with font: load, get metrics, parse and draw strings. This class is defined in #include <mgl2/font.h>. This class is accessible only from C++ (and only from GNU compilers in default binary files).
The class is based on loading and drawing of vector Hershey font. There are two styles of specifying of the font type and aligning: by integer parameters or by string.
The string can be any combination of characters: ‘rbiLCRwou’. The font types are: ‘r’ – roman font, ‘i’ – italic style, ‘b’ – bold style. By default roman font (that is ‘’ or ‘r’) is used. The align types are: ‘L’ – align left (default), ‘C’ – align center, ‘R’ – align right. Additional font effects are: ‘w’ – wire, ‘o’ – over-lined, ‘u’ – underlined. Parsing of the string to special (TeX-like) commands will be done if variable parse is true (it’s default). See also see section Font styles.
The over way of font and alignment setting is the using of the integer constant. Integer font Id can be one of predefined constants: MGL_FONT_ITAL, MGL_FONT_BOLD, MGL_FONT_BOLD_ITAL = MGL_FONT_ITAL+MGL_FONT_BOLD. Default font is MGL_FONT_ROMAN. Also there are flags MGL_FONT_ULINE, MGL_FONT_OLINE, MGL_FONT_WIRE for additional font effects. Align parameter controls the text alignment: 0 – align left, 1 – align center, 2 – align right.
| 8.3.1 Format of font files |
mglFont (const char *name=MGL_DEF_FONT_NAME, const char *path=NULL)Initialize the font and load data from file name (default name is "STIX" for Linux and MacOS) or if name=NULL limited data from memory (default for Windows).
bool Load (const char * base, const char *path=NULL)Load font from file path/base into the memory. The font may contain 4 files: base.vfm, base_b.vfm, base_i.vfm, base_bi.vfm. Appendix contain detailed description of font format.
void Restore ()Restore default font.
void Copy (mglFont *fnt)Copy data from other font instance.
void Clear ()Clear memory by deleting the loaded font.
unsigned GetNumGlyph ()Return the number of glyphs in the font.
bool Ready ()Return true if font is loaded and ready for use.
float Height (int font)Gets height of text for font specified by integer constant.
float Puts (const char *str, int font=0, int align=0)Prints 8-bit text string for font specified by integer constant.
float Width (const char *str, int font=0)Gets width of 8-bit text string for font specified by integer constant.
float Puts (const wchar_t *str, int font=0, int align=0)Prints Unicode text string for font specified by integer constant.
float Width (const wchar_t *str, int font=0)Gets width of Unicode text string for font specified by integer constant.
float Height (const char *how)Gets height of text for font specified by string.
float Puts (const char *str, const char *how)Prints 8-bit text string for font specified by string.
float Width (const char *str, const char *how)Gets width of 8-bit text string for font specified by string.
float Puts (const wchar_t *str, const char *how)Prints Unicode text string for font specified by string.
float Width (const wchar_t *str, const char *how)Gets width of Unicode text string for font specified by string.
HMGL grInstance of mglGraph class which is used for character drawing.
bool parseFlag for switching on/off the parsing of TeX commands. Default value is true.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Starting from v.1.6 the MathGL library uses new font files. The font is defined in 4 files with suffixes ‘*.vfm’, ‘*_b.vfm’, ‘*_i.vfm’, ‘*_bi.vfm’. These files are text files containing the data for roman font, bold font, italic font and bold italic font. The files (or some symbols in the files) for bold, italic or bold italic fonts can be absent. In this case the roman glyph will be used for them. By analogy, if the bold italic font is absent but the bold font is present then bold glyph will be used for bold italic. You may create these font files by yourself from *.ttf, *.otf files with the help of program font_tools. This program can be found at MathGL home site.
The format of font files (*.vfm – vector font for MathGL) is the following.
Each font file can be compressed by gzip.
Note: the closing contour line is done automatically (so the last segment may be absent). For starting new contour use a point with coordinates {0x3fff, 0x3fff}.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Autobuild on July 16, 2012 using texi2html 1.82.