| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
7.3 mglFont class
Class for working with font: load, get metrics, parse and draw strings. This class is defined in #include <mgl/mgl_font.h>.
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.
| 7.3.1 Format of font files |
- Method on mglFont:
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=
NULLlimited data from memory (default for Windows).
- Method on mglFont:
boolLoad (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.
- Method on mglFont:
floatHeight (intfont) Gets height of text for font specified by integer constant.
- Method on mglFont:
floatPuts (const char *str,intfont=0,intalign=0) Prints 8-bit text string for font specified by integer constant.
- Method on mglFont:
floatWidth (const char *str,intfont=0) Gets width of 8-bit text string for font specified by integer constant.
- Method on mglFont:
floatPuts (const wchar_t *str,intfont=0,intalign=0) Prints Unicode text string for font specified by integer constant.
- Method on mglFont:
floatWidth (const wchar_t *str,intfont=0) Gets width of Unicode text string for font specified by integer constant.
- Method on mglFont:
floatPuts (const char *str,const char *how) Prints 8-bit text string for font specified by string.
- Method on mglFont:
floatWidth (const char *str,const char *how) Gets width of 8-bit text string for font specified by string.
- Method on mglFont:
floatPuts (const wchar_t *str,const char *how) Prints Unicode text string for font specified by string.
- Method on mglFont:
floatWidth (const wchar_t *str,const char *how) Gets width of Unicode text string for font specified by string.
- Parameter of mglFont:
boolparse Flag for switching on/off the parsing of TeX commands. Default value is
true.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
