#include <nglFontBase.h>
Inheritance diagram for nglFontBase:

This base font class does not handle final rendering. It is intended to support all font services but rendering. Specific rendering methods are implemented atop this class using some advanced and specialized services (see the protected interface).
This class implementation is based on FreeType ( http://www.freetype.org ). It will load fonts of various formats (see nglFontBase()), expose global font as well as glyph specific informations and metrics, control scalable fonts rasterizing (hinting, anti-aliasing), manage charmaps and synthesize missing ones, calculate string layout (no BiDi or vertical support for now) and somehow contribute to the world's entropy.
Although this class is intented to handle transparently both scalable and bitmap fonts, there are some major design differences you ought to know :
Public Types | |
| typedef GlyphData * | GlyphHandle |
| typedef uint | RenderMode |
| enum | GlyphType { eGlyphNative, eGlyphOutline, eGlyphBitmap } |
Public Member Functions | |
Life cycle | |
| nglFontBase () | |
| nglFontBase (uint8 *pBuffer, uint32 BufferSize, uint Face=0) | |
| nglFontBase (const nglPath &rFontFile, uint Face=0) | |
| nglFontBase (const nglFontBase &rFont) | |
| virtual | ~nglFontBase () |
Global font info & metrics | |
| bool | GetInfo (nglFontInfo &rInfo, nglFontUnit Unit=eFontUnitPixel) const |
| nglString | GetFamilyName () const |
| nglString | GetStyleName () const |
| bool | IsScalable () const |
| bool | IsBold () const |
| bool | IsItalic () const |
| float | GetHeight (nglFontUnit Unit=eFontUnitPixel, float DefaultSpacing=1.f) const |
| uint | GetGlyphCount () const |
| float | EMToPixel (float Value) const |
| float | EMToPoint (float Value) const |
| float | PixelToPoint (float Value) const |
| float | PointToPixel (float Value) const |
Glyph metrics | |
| float | GetSize (nglFontUnit Unit=eFontUnitPixel) const |
| bool | SetSize (float Size, nglFontUnit Unit=eFontUnitPixel) |
| float | GetResolution () const |
| void | SetResolution (float Resolution) |
| bool | GetMetrics (nglGlyphInfo &rInfo, nglChar Char, GlyphType Type=eGlyphBitmap) const |
| virtual bool | GetGlyphInfo (nglGlyphInfo &rInfo, uint Index, GlyphType Type) const |
| bool | GetKerning (uint Left, uint Right, float &rX, float &rY) const |
Character maps | |
| int | GetCharMapCount () const |
| int | GetCharMap () const |
| bool | SetCharMap (int Index) |
| const nglChar * | GetCharMapName () const |
| const nglChar * | GetCharMapName (int Index) const |
| int | GetGlyphIndexes (const nglChar *pSource, int SourceLength, uint *pIndexes, int IndexesLength) const |
Rendering/rasterizing (scalable fonts only) | |
| RenderMode | GetRenderMode () const |
| virtual bool | SetRenderMode (RenderMode Mode) |
Glyph metrics, contour and bitmap retrieval | |
| GlyphHandle | GetGlyph (uint Index, GlyphType Type) const |
| GlyphType | GetGlyphType (GlyphHandle Glyph) const |
| bool | GetGlyphBitmap (GlyphHandle Glyph, GlyphBitmap &rBitmap) const |
| bool | GetBitmap8 (const GlyphBitmap &rSrc, GlyphBitmap &rDst) const |
Static Public Attributes | |
| static const RenderMode | AntiAliasing |
| static const RenderMode | Hinting |
| static float | DefaultPixelSize |
Protected Member Functions | |
| virtual const nglChar * | OnError (uint &rError) const |
Friends | |
| class | nglFontInfo |
Classes | |
| class | GlyphBitmap |
| Description of a glyph bitmap representation. More... | |
|
|
|
|
|
Rendering flags. See SetRenderMode() and GetRenderMode().
|
|
|
Glyph fetching mode. See GetGlyphInfo() and GetGlyph().
|
|
|
Create default font Create a font from an embedded description. It implements all ASCII characters using a monospace, lightly serifed, legible scalable font. |
|
||||||||||||||||
|
Create font from memory. Create a font from a memory buffer. |
|
||||||||||||
|
Create a font from a file
|
|
|
Copy a font
Note : this copy constructor is lightweight due to the cache infrastructure. |
|
|
Release the font ressource |
|
|
Convert from EM to pixels (undefined for bitmap fonts).
|
|
|
Convert from EM to points (undefined for bitmap fonts).
|
|
||||||||||||
|
Convert a 1-bit monochrome bitmap to a 8-bit one
|
|
|
Return the current charmap
|
|
|
Returns the number of supported charmaps.
|
|
|
Get charmap
|
|
|
Get current charmap human readable name.
|
|
|
Returns font family (ie. Helvetica, Geneva, etc).
|
|
||||||||||||
|
Fetch a glyph description from a a given glyph index
GetGlyph() can return monochrome (1 bit) or graylevel (8 bit) bitmaps, check the pixel_mode field. See also GetBitmap8(). |
|
||||||||||||
|
Retrieve bitmap info from a glyph handle
|
|
|
Returns the number of available glyphs.
|
|
||||||||||||||||||||
|
Retrieve a range of glyph indexes from a nglChar array (encoding aware)
|
|
||||||||||||||||
|
Fetch a glyph description from a a given glyph index
If To retrieve string metrics, use nglFontLayout::GetMetrics(). |
|
|
Returns the type (outline vs. bitmap) of a glyph handle
|
|
||||||||||||
|
Return font height
Most scalable fonts define their font height, a value specifically choosen by the font designer. In this case, the
Most bitmap fonts do not have a defined font height. If such a value is not present in the font ressource, the font height is computed as the sum of the current font size and the Please note that the Height field of nglFontInfo only returns the designer's font height when it's defined, zero otherwise. GetHeight() is a higher level method which helps you to support fonts which do not define their height (mostly bitmap fonts). |
|
||||||||||||
|
Fetch font informations and global metrics
|
|
||||||||||||||||||||
|
Fetch kerning values from a glyph pair
|
|
||||||||||||||||
|
Fetch glyph metrics
|
|
|
Get current rendering mode.
|
|
|
Get current resolution in DPI (dots per inch).
|
|
|
Returns current font size using
|
|
|
Returns font style (ie. Bold, Italic, Condensed, etc).
|
|
|
Returns font weight, ie. bold or regular.
|
|
|
Returns font slant, ie. italic or regular.
|
|
|
Returns wether the font is scalable or not (ie. bitmap based).
|
|
|
const nglChar** ChildErrorTable = {_T("no error"), _T("Bad luck"), NULL}; const nglChar* Child::OnError (uint& rError) const { return FetchError(ChildErrorTable, Parent::OnError(rError), rError); } Implements nglError. Reimplemented in nglFont. |
|
|
Convert from pixels to points (font size independent).
|
|
|
Convert from points to pixels (font size independent).
|
|
|
Select current charmap
|
|
|
Set rendering mode
AntiAliasing will use an 8bit alpha channel to represent smooth edges. You can apply this mask to a texture or a plain color, blend this on the target surface, and thus obtain smoothed font contours. Anti-aliasing is turned on as a default for scalable fonts. Most scalable fonts are hinted : the font designer added some information to help the renderer keep some font features consistant, such as stem width or spacing, serif control, and so on. These hints are especially important (and well tuned) for small sizes like 10-20 pixels. Hinting is turned on as a default. |
|
|
Set current resolution
You can fetch and use the physical resolution of the display device from a nglWindow instance with nglWindow::GetResolution(). |
|
||||||||||||
|
Set current font size
|
|
|
|
|
|
Use anti-aliasing. See SetRenderMode().
|
|
|
Default size (in pixels) for scalable fonts.
|
|
|
Interpret font hints. See SetRenderMode().
|
1.4.1