HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_Font Class Reference

#include <RE_Font.h>

Public Member Functions

bool isValid () const
 
const char * getName () const
 Returns the full name of the font. More...
 
const FONT_InfogetFontInfo () const
 
float getSize () const
 Get the size, in points, of this font. More...
 
bool operator== (const RE_Font &other) const
 
bool operator!= (const RE_Font &other) const
 

Static Public Member Functions

static RE_Fontget (const FONT_Info &font_info, float size)
 
static RE_Fontget (const char *font_name, float size)
 
static RE_Fontget (RE_Font &font, FONT_Variant variant)
 
static RE_FontemptyFont ()
 
class re_FontCache
 The size, in points, of this font. More...
 
class RE_RenderUI
 The size, in points, of this font. More...
 
static void renderFontDeferData (RE_Render *r, UT_Array< RE_FontDeferData > &deferData)
 Performs rendering of the render data generated by createFontDeferData. More...
 
static void createFontDeferData (RE_Render *r, const UT_StringArray &strings, const UT_Array< RE_Font * > &fonts, const UT_Array< UT_Unicode::transform * > &xforms, const UT_Array< UT_FRGBA > &clrs, const UT_Array< UT_Vector3F > &positions, fpreal32 sx, fpreal32 sy, fpreal32 tx, fpreal32 ty, UT_Array< RE_FontDeferData > &defer_data, bool use_shared_font_buffers)
 
float getAscender ()
 
float getDescender ()
 
float getHeight ()
 
float getXHeight ()
 
float getUnderlinePos ()
 
float getUnderlineThickness ()
 
bool hasGlyph (utf32 cp)
 Returns true if the font contains a glyph for the given code point. More...
 
float getHorizAdvance (utf32 cp)
 
float getHorizAdvance (utf32 cp, utf32 cp_next)
 
float getStringWidth (const utf8 *s, const utf8 *e=nullptr, const UT_Unicode::transform *cp_xform=nullptr)
 Get the width of a string, including all kerning adjustments. More...
 
float getStringWidth (const UT_StringView &str, const UT_Unicode::transform *cp_xform=nullptr)
 The size, in points, of this font. More...
 
float getStringWidth (const UT_String &str, const UT_Unicode::transform *cp_xform=nullptr)
 The size, in points, of this font. More...
 
float getStringWidth (const UT_StringRef &str, const UT_Unicode::transform *cp_xform=nullptr)
 The size, in points, of this font. More...
 
float getStringWidth (const UT_WorkBuffer &str, const UT_Unicode::transform *cp_xform=nullptr)
 The size, in points, of this font. More...
 
bool isStringWiderThan (const utf8 *s, const utf8 *e, float width, const UT_Unicode::transform *cp_xform=nullptr)
 
bool isStringWiderThan (const UT_StringView &str, float width, const UT_Unicode::transform *cp_xform=nullptr)
 The size, in points, of this font. More...
 
bool getTrimmedString (const utf8 *&s, const utf8 *&e, const utf8 *ellipsis, float max_width, bool trim_right, const UT_Unicode::transform *cp_xform=nullptr, float *trimmed_width=nullptr)
 
bool splitString (const UT_StringView &s, UT_StringView &left, UT_StringView &right, float max_width, RE_StringSplitType split_type=RE_SST_NARROWER_ONLY, const UT_Unicode::transform *cp_xform=nullptr)
 
bool wrapString (const UT_StringView &s, UT_StringViewArray &result, float max_width, float max_height=FLT_MAX, RE_StringSplitType split_type=RE_SST_BOUNDARY_HARD, const UT_Unicode::transform *cp_xform=nullptr)
 
float getIntegerWidth (const char *s)
 Faster String width method for integers. More...
 
float getFloatWidth (const char *s)
 Faster String width method for floats. More...
 

Detailed Description

Examples:
DM/DM_InfoHook.C, and DM/DM_OverdrawHook.C.

Definition at line 98 of file RE_Font.h.

Member Function Documentation

static void RE_Font::createFontDeferData ( RE_Render r,
const UT_StringArray strings,
const UT_Array< RE_Font * > &  fonts,
const UT_Array< UT_Unicode::transform * > &  xforms,
const UT_Array< UT_FRGBA > &  clrs,
const UT_Array< UT_Vector3F > &  positions,
fpreal32  sx,
fpreal32  sy,
fpreal32  tx,
fpreal32  ty,
UT_Array< RE_FontDeferData > &  defer_data,
bool  use_shared_font_buffers 
)
static

Builds directly renderable data structures from the provided set of strings, fonts, positions, and colors.

static RE_Font& RE_Font::emptyFont ( )
static
static RE_Font& RE_Font::get ( const FONT_Info font_info,
float  size 
)
static
static RE_Font& RE_Font::get ( const char *  font_name,
float  size 
)
static
static RE_Font& RE_Font::get ( RE_Font font,
FONT_Variant  variant 
)
static
float RE_Font::getAscender ( )

Font query Returns the height of the ascender, in pixels. The ascender is the distance from the font's baseline to the top of the tallest glyph.

float RE_Font::getDescender ( )

The descender is the distance, in pixels, from the baseline to the bottom-most pixel of all glyphs in the font.

float RE_Font::getFloatWidth ( const char *  s)

Faster String width method for floats.

const FONT_Info& RE_Font::getFontInfo ( ) const
inline

Definition at line 111 of file RE_Font.h.

float RE_Font::getHeight ( )

The height is the baseline-to-baseline distance for this font. This should be used as the appropriate vertical spacing for the font.

Examples:
DM/DM_InfoHook.C, and DM/DM_OverdrawHook.C.
float RE_Font::getHorizAdvance ( utf32  cp)

Get the horizontal advance, in pixels, of the cursor, after drawing the given code point's glyph. NOTE: This ignores kerning! If you want to get the width of a whole string, use getStringWidth instead.

float RE_Font::getHorizAdvance ( utf32  cp,
utf32  cp_next 
)

Get the horizontal advance, in pixels, of the cursor, after drawing the given code point's glyph, and including it's kerning pair glyph.

float RE_Font::getIntegerWidth ( const char *  s)

Faster String width method for integers.

const char* RE_Font::getName ( ) const

Returns the full name of the font.

float RE_Font::getSize ( ) const
inline

Get the size, in points, of this font.

Definition at line 114 of file RE_Font.h.

float RE_Font::getStringWidth ( const utf8 s,
const utf8 e = nullptr,
const UT_Unicode::transform cp_xform = nullptr 
)

Get the width of a string, including all kerning adjustments.

Examples:
DM/DM_InfoHook.C, and DM/DM_OverdrawHook.C.
float RE_Font::getStringWidth ( const UT_StringView str,
const UT_Unicode::transform cp_xform = nullptr 
)
inline

The size, in points, of this font.

Definition at line 165 of file RE_Font.h.

float RE_Font::getStringWidth ( const UT_String str,
const UT_Unicode::transform cp_xform = nullptr 
)
inline

The size, in points, of this font.

Definition at line 170 of file RE_Font.h.

float RE_Font::getStringWidth ( const UT_StringRef str,
const UT_Unicode::transform cp_xform = nullptr 
)
inline

The size, in points, of this font.

Definition at line 175 of file RE_Font.h.

float RE_Font::getStringWidth ( const UT_WorkBuffer str,
const UT_Unicode::transform cp_xform = nullptr 
)
inline

The size, in points, of this font.

Definition at line 180 of file RE_Font.h.

bool RE_Font::getTrimmedString ( const utf8 *&  s,
const utf8 *&  e,
const utf8 ellipsis,
float  max_width,
bool  trim_right,
const UT_Unicode::transform cp_xform = nullptr,
float trimmed_width = nullptr 
)

Get the length of string that can be put in the given space, using the provided ellipsis text to replace removed characters.

float RE_Font::getUnderlinePos ( )

Returns the signed distance from the baseline to where the the underline for the font should be drawn.

float RE_Font::getUnderlineThickness ( )

Returns the thickness of the underline to be drawn, corresponding with the font's size and weight.

float RE_Font::getXHeight ( )

Get the x-height. This is usually the distance from the baseline to the top of the lower-case x.

bool RE_Font::hasGlyph ( utf32  cp)

Returns true if the font contains a glyph for the given code point.

bool RE_Font::isStringWiderThan ( const utf8 s,
const utf8 e,
float  width,
const UT_Unicode::transform cp_xform = nullptr 
)

Quick check to see if a string exceeds the given width. Usually faster than calling getStringWidth if only the threshold check is required.

bool RE_Font::isStringWiderThan ( const UT_StringView str,
float  width,
const UT_Unicode::transform cp_xform = nullptr 
)
inline

The size, in points, of this font.

Definition at line 190 of file RE_Font.h.

bool RE_Font::isValid ( ) const
inline

Definition at line 106 of file RE_Font.h.

bool RE_Font::operator!= ( const RE_Font other) const
inline

Definition at line 117 of file RE_Font.h.

bool RE_Font::operator== ( const RE_Font other) const
static void RE_Font::renderFontDeferData ( RE_Render r,
UT_Array< RE_FontDeferData > &  deferData 
)
static

Performs rendering of the render data generated by createFontDeferData.

bool RE_Font::splitString ( const UT_StringView s,
UT_StringView left,
UT_StringView right,
float  max_width,
RE_StringSplitType  split_type = RE_SST_NARROWER_ONLY,
const UT_Unicode::transform cp_xform = nullptr 
)

Split the string into two parts, at a breakable space or a breakable hyphen, using the font's metric to ensure that the left part doesn't exceed max_width. The particular splitting strategy, and whether max_width is strictly honored, is governed by split_type. If the splitting fails, this function returns false.

bool RE_Font::wrapString ( const UT_StringView s,
UT_StringViewArray result,
float  max_width,
float  max_height = FLT_MAX,
RE_StringSplitType  split_type = RE_SST_BOUNDARY_HARD,
const UT_Unicode::transform cp_xform = nullptr 
)

Takes an input string, and splits it up into a list of strings none wider than max_width (depending on splitting strategy). The string is initially split by newline characters, and then each sub-string split using splitString to satisfy the maximum width requirement. If max_height is given, then only as many lines as will fit in that vertical space, assuming the lines are spaced out by the amount returned by getHeight. Returns false if it failed to fully wrap the input string.

Friends And Related Function Documentation

friend class re_FontCache
friend

The size, in points, of this font.

Definition at line 275 of file RE_Font.h.

friend class RE_RenderUI
friend

The size, in points, of this font.

Definition at line 276 of file RE_Font.h.


The documentation for this class was generated from the following file: