wxArt2D
|
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc. More...
#include <stylebase.h>
Public Types | |
enum | a2dFontLoadMethod { a2d_LOAD_DEFAULT = 0x0, a2d_LOAD_NO_SCALE = 0x1, a2d_LOAD_NO_HINTING = 0x2, a2d_LOAD_RENDER = 0x4, a2d_LOAD_NO_BITMAP = 0x8, a2d_LOAD_VERTICAL_LAYOUT = 0x10, a2d_LOAD_FORCE_AUTOHINT = 0x20, a2d_LOAD_CROP_BITMAP = 0x40, a2d_LOAD_PEDANTIC = 0x80, a2d_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH = 0x200, a2d_LOAD_NO_RECURSE = 0x400, a2d_LOAD_IGNORE_TRANSFORM = 0x800, a2d_LOAD_MONOCHROME = 0x1000, a2d_LOAD_LINEAR_DESIGN = 0x2000, a2d_LOAD_NO_AUTOHINT = 0x8000U } |
load method of glyph, see Freetype refence for meaning of FT_LOAD_* | |
Public Member Functions | |
a2dFontType | GetType (void) const |
a2dFont () | |
Constructor. | |
a2dFont (const a2dFont &other) | |
Copy constructor. | |
a2dFont (const wxFont &font, double size, a2dFontType type=a2dFONT_WXDC, wxFontEncoding encoding=wxFONTENCODING_DEFAULT) | |
Constructor. More... | |
a2dFont (double size, int family, int style=wxNORMAL, int weight=wxNORMAL, const bool underline=false, const wxString &faceName=wxT(""), wxFontEncoding encoding=wxFONTENCODING_DEFAULT) | |
Constructor. More... | |
a2dFont (const wxString &filename, double size=0.0, wxFontEncoding encoding=wxFONTENCODING_DEFAULT, int faceindex=0) | |
constructor of Freetype font based on filename of fontfile. | |
a2dFont (const wxString &filename, double size, bool monoSpaced, double weight=0.0) | |
constructor of stroked font based on filename of fontfile. See a2dFontStrokeData | |
virtual | ~a2dFont () |
Destructor. | |
bool | operator== (const a2dFont &a) |
return true if the same font (same reference) | |
bool | operator!= (const a2dFont &a) |
return true if not the same font (same reference) | |
bool | Ok () const |
Check font validity. More... | |
const a2dFontInfo & | GetFontInfo () const |
Get fontinfo of the font. | |
void | SetSize (double size) |
Set the font size. More... | |
double | GetSize () const |
Get the font size. More... | |
double | GetLineHeight () const |
Get the line height. More... | |
double | GetDescent () const |
Get descent. More... | |
double | GetWidth (wxChar c) |
Get width of a single character. | |
double | GetKerning (wxChar c1, wxChar c2) const |
Get kerning space between two characters. More... | |
double | GetStrokeWidth () const |
Get stroke width. More... | |
a2dStrokeGlyph | GetGlyphStroke (wxChar c) const |
Get the glyph of a single character. More... | |
const a2dGlyph * | GetGlyphFreetype (wxChar c) const |
void | SetDeviceHeight (double sizeInPixels) |
double | GetDeviceHeight () |
wxFont & | GetFont (void) |
wxFont in case of a2dFONT_WXDC | |
a2dBoundingBox | GetTextExtent (const wxString &string, int alignment=wxMINX|wxMINY, double *w=NULL, double *h=NULL, double *descent=NULL, double *externalLeading=NULL) const |
Get the dimensions in world coordinates of the string. More... | |
void | GetTextExtent (const wxString &string, double &w, double &h, double &descent, double &externalLeading) const |
Get the dimensions in world coordinates of the string. More... | |
void | GetTextExtentWH (const wxString &string, double &w, double &h) const |
Get the dimensions in world coordinates of the string. More... | |
bool | GetPartialTextExtents (const wxString &text, wxArrayInt &widths) const |
bool | GetVpath (wxChar c, a2dVpath &glyph, const a2dAffineMatrix &affine=a2dIDENTITY_MATRIX) |
Get the glyph of a single character as a vpath. More... | |
void | GetVpath (const wxString &text, a2dVpath &vpath, double x=0, double y=0, int alignment=wxMINX|wxMINY, bool yaxis=true, const a2dAffineMatrix &affine=a2dIDENTITY_MATRIX) |
Render a text string into a vector path. More... | |
bool | AlwaysWriteSerializationId () const |
wxString | CreateString () |
Create a string description of the font. More... | |
void | SetFilename (const wxString &filename) |
Set the font filename and load the font. More... | |
wxString | GetFilename (bool filenameonly=false) const |
Get the font filename. More... | |
double | GetWeight () const |
Get the weight of the font. More... | |
void | SetWeight (double weight) |
Set the weight of the font. More... | |
void | SetWeight (const wxString &weight) |
Set the weight of the font, from a string. More... | |
wxObjectRefData * | CreateRefData () const |
wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const |
Static Public Member Functions | |
static void | GetInfoList (a2dFontInfoList &list) |
Append fonts of this type to the list. More... | |
static a2dFont | CreateFont (const a2dFontInfo &info, bool force=false) |
Create the font from a fontinfo description. More... | |
static wxString | CreateString (const wxString &filename, double size, wxFontEncoding encoding, int weight) |
create a unique string presenting a a2dFONT_FREETYPE type font (see constructor for parameters) | |
static wxString | CreateString (const wxString &filename, double size, bool monoSpaced, double weight) |
create a unique string presenting a a2dFONT_STROKED type font (see constructor for parameters) | |
static wxString | CreateString (a2dFontType type, const wxFont &font, double size, wxFontEncoding encoding) |
create a unique string presenting a a2dFONT_WXDC type font (see constructor for parameters) | |
static void | SetLoadFlags (wxInt32 loadMethodMask) |
Friends | |
bool | operator== (const a2dFont &a, const a2dFont &b) |
return true if the same font (same reference) | |
bool | operator!= (const a2dFont &a, const a2dFont &b) |
return true if not the same font (same reference) | |
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
There are 3 types of fonts as in a2dFontType. The a2dDrawer2D classes know how to draw strings with these fonts.
Definition at line 779 of file stylebase.h.
a2dFont::a2dFont | ( | const wxFont & | font, |
double | size, | ||
a2dFontType | type = a2dFONT_WXDC , |
||
wxFontEncoding | encoding = wxFONTENCODING_DEFAULT |
||
) |
Constructor.
This constructor tries to locate the font file, belonging to the wxFont class, which is then used for drawing. At present only a Windows version is implemented.
font | Font format. The size of the font is not used and should be set using the next parameter. |
size | Size in world coordinates. |
encoding | endocing of font |
Definition at line 2814 of file stylebase.cpp.
a2dFont::a2dFont | ( | double | size, |
int | family, | ||
int | style = wxNORMAL , |
||
int | weight = wxNORMAL , |
||
const bool | underline = false , |
||
const wxString & | faceName = wxT( "" ) , |
||
wxFontEncoding | encoding = wxFONTENCODING_DEFAULT |
||
) |
Constructor.
Creates a font object (see font encoding overview, in the wxWidgets documentation, for the meaning of the last parameter).
size | Size in world coordinates. |
family | Font family, a generic way of referring to fonts without specifying actual facename. One of:
|
style | One of wxNORMAL, wxSLANT and wxITALIC. |
weight | One of wxNORMAL, wxLIGHT and wxBOLD. |
underline | The value can be true or false. At present this has an effect on Windows and Motif 2.x only. |
faceName | An optional string specifying the actual typeface to be used. If the empty string, a default typeface will chosen based on the family. |
encoding | An encoding which may be one of
|
If the specified encoding isn't available, no font is created.
wxFONTENCODING_DEFAULT is the encoding set by calls to SetDefaultEncoding and which may be set to, say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the default application encoding is the same as default system encoding.
Definition at line 2844 of file stylebase.cpp.
|
static |
Create the font from a fontinfo description.
The a2dFont::CreateFont will allways return a valid font. The derived fonts should return NULL.
This routine will first try to find the exact font, as described in the fontinfo. If it does not find this font, it will try to create any font of any font type, that matches part of the string. eg. if a user asks for a dc-font called "Arial Black" and this is not installed on the system, this routine might return as a replacement a freetype-font called "Arial".
info | font info for creating font |
force | This param does not have a function in a2dFont, but it should be used in its descendants. When force is false, only the exact match should be made. When true, the routine should try to match any likely candidate. |
Definition at line 3163 of file stylebase.cpp.
wxString a2dFont::CreateString | ( | ) |
Create a string description of the font.
Definition at line 2887 of file stylebase.cpp.
double a2dFont::GetDescent | ( | ) | const |
Get descent.
The descent is the distance from the basline to the bottom of the bounding box.
Definition at line 3101 of file stylebase.cpp.
wxString a2dFont::GetFilename | ( | bool | filenameonly = false | ) | const |
Get the font filename.
filenameonly | The returned filename will be stripped of drive-letters and directories. |
Definition at line 3269 of file stylebase.cpp.
a2dStrokeGlyph a2dFont::GetGlyphStroke | ( | wxChar | c | ) | const |
Get the glyph of a single character.
Definition at line 2944 of file stylebase.cpp.
|
static |
Append fonts of this type to the list.
Using a2dFont::GetInfoList(list), will enumerate all fonts, of all types
Definition at line 3156 of file stylebase.cpp.
double a2dFont::GetKerning | ( | wxChar | c1, |
wxChar | c2 | ||
) | const |
Get kerning space between two characters.
Kerning is a method, which moves characters closer together/further apart, to improve the look of the font. Eg. the letter combination LT will be moved closer together. The return value is negative or positive, to respectively move characters closer together, or further apart.
Definition at line 2924 of file stylebase.cpp.
double a2dFont::GetLineHeight | ( | ) | const |
Get the line height.
The line height is calculated from the text bounding box.
Definition at line 3096 of file stylebase.cpp.
double a2dFont::GetSize | ( | ) | const |
Get the font size.
Definition at line 2917 of file stylebase.cpp.
double a2dFont::GetStrokeWidth | ( | ) | const |
Get stroke width.
Definition at line 2931 of file stylebase.cpp.
a2dBoundingBox a2dFont::GetTextExtent | ( | const wxString & | string, |
int | alignment = wxMINX | wxMINY , |
||
double * | w = NULL , |
||
double * | h = NULL , |
||
double * | descent = NULL , |
||
double * | externalLeading = NULL |
||
) | const |
Get the dimensions in world coordinates of the string.
string | The text string to measure (should be a single line of text). |
alignment | Alignment of the text (eg. wxLEFT) |
w | Total width in world coordinates. |
h | Total height in world coordinates. |
descent | The dimension from the baseline of the font to the bottom of the descender in world coordinates. |
externalLeading | Any extra vertical space added to the font by the font designer in world coordinates (usually is zero). |
Definition at line 3044 of file stylebase.cpp.
void a2dFont::GetTextExtent | ( | const wxString & | string, |
double & | w, | ||
double & | h, | ||
double & | descent, | ||
double & | externalLeading | ||
) | const |
Get the dimensions in world coordinates of the string.
string | The text string to measure (should be a single line of text). |
w | Total width in world coordinates. |
h | Total height in world coordinates. |
descent | The dimension from the baseline of the font to the bottom of the descender in world coordinates. |
externalLeading | Any extra vertical space added to the font by the font designer in world coordinates (usually is zero). |
Definition at line 3079 of file stylebase.cpp.
void a2dFont::GetTextExtentWH | ( | const wxString & | string, |
double & | w, | ||
double & | h | ||
) | const |
Get the dimensions in world coordinates of the string.
string | The text string to measure (should be a single line of text). |
w | Total width in world coordinates. |
h | Total height in world coordinates. |
Definition at line 3085 of file stylebase.cpp.
bool a2dFont::GetVpath | ( | wxChar | c, |
a2dVpath & | glyph, | ||
const a2dAffineMatrix & | affine = a2dIDENTITY_MATRIX |
||
) |
Get the glyph of a single character as a vpath.
The position, indicated by x and y, is the lowerleft bbox corner of the glyph.
c | The character. |
glyph | A vectorpath, to which the glyph is added. |
affine | Position etc., where the glyph is constructed. |
Definition at line 3111 of file stylebase.cpp.
void a2dFont::GetVpath | ( | const wxString & | text, |
a2dVpath & | vpath, | ||
double | x = 0 , |
||
double | y = 0 , |
||
int | alignment = wxMINX | wxMINY , |
||
bool | yaxis = true , |
||
const a2dAffineMatrix & | affine = a2dIDENTITY_MATRIX |
||
) |
Render a text string into a vector path.
The position, indicated by x and y, is the lowerleft bbox corner of the text.
text | The string to render. |
vpath | The vectorpath, to which the string is rendered |
x | Position, where the string is constructed. |
y | Position, where the string is constructed. |
alignment | how to position text relative top position |
yaxis | up or down text |
affine | Position etc., where the text is constructed. |
Definition at line 3116 of file stylebase.cpp.
double a2dFont::GetWeight | ( | ) | const |
Get the weight of the font.
Definition at line 3283 of file stylebase.cpp.
bool a2dFont::Ok | ( | ) | const |
Check font validity.
Definition at line 2894 of file stylebase.cpp.
void a2dFont::SetFilename | ( | const wxString & | filename | ) |
Set the font filename and load the font.
filename | The filename of the font. This may either be a full path, or just the fontname. In the latter case, the fontpath of a2dGlobals will be used to search the font. |
Definition at line 3253 of file stylebase.cpp.
|
static |
Set the way glyphs are loaded by freetype. Important for small fonts. a2d_LOAD_DEFAULT; a2d_LOAD_DEFAULT | a2d_LOAD_NO_HINTING; a2d_LOAD_DEFAULT | a2d_LOAD_FORCE_AUTOHINT;
Definition at line 3247 of file stylebase.cpp.
void a2dFont::SetSize | ( | double | size | ) |
Set the font size.
size | Font size in world coordinates. |
Definition at line 2909 of file stylebase.cpp.
void a2dFont::SetWeight | ( | double | weight | ) |
Set the weight of the font.
weight | The weight (in this case stroke width) in percentages of the font size. There are two exceptions. 0: Draws the font with a pen of 1 pixel wide. -1: Draws the font with a normalized pen, as the font-designer intended it. |
Definition at line 3295 of file stylebase.cpp.
void a2dFont::SetWeight | ( | const wxString & | weight | ) |
Set the weight of the font, from a string.
weight | One of: "Normalized Pen", "Pixel pen" or a string starting with the width in percentages, ending with %. |
Definition at line 3311 of file stylebase.cpp.