manpagez: man pages & more
info mathgl
Home | html | info | man
[ < ] [ > ]   [ << ] [ 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.

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=NULL limited data from memory (default for Windows).

Method on mglFont: 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.

Method on mglFont: void Restore ()

Restore default font.

Method on mglFont: void (mglFont * fnt)

Copy data from other font instance.

Method on mglFont: void Clear ()

Clear memory by deleting the loaded font.

Method on mglFont: inline unsigned GetNumGlyph ()

Return the number of glyphs in the font.

Method on mglFont: inline bool Ready ()

Return true if font is loaded and ready for use.

Method on mglFont: float Height (int font)

Gets height of text for font specified by integer constant.

Method on mglFont: float Puts (const char *str, int font=0, int align=0)

Prints 8-bit text string for font specified by integer constant.

Method on mglFont: float Width (const char *str, int font=0)

Gets width of 8-bit text string for font specified by integer constant.

Method on mglFont: float Puts (const wchar_t *str, int font=0, int align=0)

Prints Unicode text string for font specified by integer constant.

Method on mglFont: float Width (const wchar_t *str, int font=0)

Gets width of Unicode text string for font specified by integer constant.

Method on mglFont: float Height (const char *how)

Gets height of text for font specified by string.

Method on mglFont: float Puts (const char *str, const char *how)

Prints 8-bit text string for font specified by string.

Method on mglFont: float Width (const char *str, const char *how)

Gets width of 8-bit text string for font specified by string.

Method on mglFont: float Puts (const wchar_t *str, const char *how)

Prints Unicode text string for font specified by string.

Method on mglFont: float Width (const wchar_t *str, const char *how)

Gets width of Unicode text string for font specified by string.

Parameter of mglFont: mglGraph * gr

Instance of mglGraph class which is used for character drawing.

Parameter of mglFont: bool parse

Flag for switching on/off the parsing of TeX commands. Default value is true.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.