dlangui.graphics.fonts

This module contains base fonts access interface and common implementation.

Font - base class for fonts.

FontManager - base class for font managers - provides access to available fonts.

More...

Public Imports

dlangui.core.config
public import dlangui.core.config;
Undocumented in source.
dlangui.graphics.drawbuf
public import dlangui.graphics.drawbuf;
Undocumented in source.
dlangui.core.types
public import dlangui.core.types;
Undocumented in source.
dlangui.core.logger
public import dlangui.core.logger;
Undocumented in source.

Members

Aliases

FontRef
alias FontRef = Ref!Font
Undocumented in source.

Classes

Font
class Font

Instance of font with specific size, weight, face, etc.

FontManager
class FontManager

Access points to fonts.

glyph_gamma_table
class glyph_gamma_table(int maxv = 65)
Undocumented in source.

Enums

FontFamily
enum FontFamily

font families enum

FontWeight
enum FontWeight

font weight constants (0..1000)

HintingMode
enum HintingMode

Hinting mode (currently supported for FreeType only)

Functions

getReplacementChar
dchar getReplacementChar(dchar code)

find some suitable replacement for important characters missing in font

nextGlyphId
uint nextGlyphId()

ID generator for glyphs

Properties

glyphDestroyCallback
void function(uint id) glyphDestroyCallback [@property getter]

get glyph destroy callback (to cleanup OpenGL caches)

glyphDestroyCallback
void glyphDestroyCallback [@property getter]

Set glyph destroy callback (to cleanup OpenGL caches) This callback is used to tell OpenGL glyph cache that glyph is not more used - to let OpenGL glyph cache delete texture if all glyphs in it are no longer used.

Static variables

_gamma256
glyph_gamma_table!256 _gamma256;
Undocumented in source.
_gamma65
glyph_gamma_table!65 _gamma65;
Undocumented in source.

Structs

CustomCharProps
struct CustomCharProps

custom character properties - for char-by-char drawing of text string with different character color and style

FontFaceProps
struct FontFaceProps

font face properties item

FontList
struct FontList

font instance collection - utility class, for font manager implementations

GlyphCache
struct GlyphCache

Glyph image cache

SimpleTextFormatter
struct SimpleTextFormatter

helper to split text into several lines and draw it

Variables

DEF_MIN_ANTIALIASED_FONT_SIZE
int DEF_MIN_ANTIALIASED_FONT_SIZE;

default min font size for antialiased fonts (e.g. if 16 is set, for 16+ sizes antialiasing will be used, for sizes <=15 - antialiasing will be off)

MAX_WIDTH_UNSPECIFIED
int MAX_WIDTH_UNSPECIFIED;

constant for measureText maxWidth paramenter - to tell that all characters of text string should be measured.

UNICODE_HYPHEN
dchar UNICODE_HYPHEN;
Undocumented in source.
UNICODE_NB_HYPHEN
dchar UNICODE_NB_HYPHEN;
Undocumented in source.
UNICODE_NO_BREAK_SPACE
dchar UNICODE_NO_BREAK_SPACE;
Undocumented in source.
UNICODE_SOFT_HYPHEN_CODE
dchar UNICODE_SOFT_HYPHEN_CODE;
Undocumented in source.
UNICODE_ZERO_WIDTH_SPACE
dchar UNICODE_ZERO_WIDTH_SPACE;
Undocumented in source.

Detailed Description

Actual implementation is:

dlangui.graphics.ftfonts - FreeType based font manager.

dlangui.platforms.windows.w32fonts - Win32 API based font manager.

To enable OpenGL support, build with version(USE_OPENGL);

See Also

dlangui.graphics.drawbuf, DrawBuf, drawbuf, drawbuf.html

Synopsis:

import dlangui.graphics.fonts;

// find suitable font of size 25, normal, preferrable Arial, or, if not available, any SansSerif font
FontRef font = FontManager.instance.getFont(25, FontWeight.Normal, false, FontFamily.SansSerif, "Arial");

dstring sampleText = "Sample text to draw"d;
// measure text string width and height (one line)
Point sz = font.textSize(sampleText);
// draw red text at center of DrawBuf buf
font.drawText(buf, buf.width / 2 - sz.x/2, buf.height / 2 - sz.y / 2, sampleText, 0xFF0000);

Meta

License

Boost License 1.0

Authors

Vadim Lopatin, coolreader.org@gmail.com