NCBI C++ ToolKit
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CGlTextureFont Class Reference

Search Toolkit Book for CGlTextureFont

#include <gui/opengl/gltexturefont.hpp>

+ Inheritance diagram for CGlTextureFont:
+ Collaboration diagram for CGlTextureFont:

Public Types

enum  EFontFace {
  eFontFace_Helvetica = 0 , eFontFace_Helvetica_Bold , eFontFace_Helvetica_Italic , eFontFace_Helvetica_BoldItalic ,
  eFontFace_Lucida , eFontFace_Lucida_Bold , eFontFace_Lucida_Italic , eFontFace_Lucida_BoldItalic ,
  eFontFace_Courier , eFontFace_Courier_Bold , eFontFace_Courier_Italic , eFontFace_Courier_BoldItalic ,
  eFontFace_Fixed , eFontFace_Fixed_Bold , eFontFace_Fixed_Italic , eFontFace_Fixed_BoldItalic ,
  eFontFace_TimesRoman , eFontFace_TimesRoman_Bold , eFontFace_TimesRoman_Italic , eFontFace_TimesRoman_BoldItalic ,
  eFontFace_BPMono , eFontFace_BPMono_Bold , eFontFace_BPMono_Italic , eFontFace_BPMono_BoldStencil ,
  eFontFace_LastFont , eFontFace_Helvetica6 , eFontFace_Helvetica8 , eFontFace_Helvetica10 ,
  eFontFace_LastBitmapFont
}
 Set of pre-defined fonts for which we know we have valid font files. More...
 
enum  EFontRotateFlags { fFontRotateBase = (1 << 0) , fFontRotateMid = (1 << 1) , fFontRotateCap = (1 << 2) , fReorientText = (1 << 4) }
 Font rotate options. More...
 
typedef int TFontRotateFlags
 
- Public Types inherited from IGlFont
enum  ETruncate { eTruncate_None , eTruncate_Empty , eTruncate_Ellipsis }
 
enum  EMetric {
  eMetric_CharHeight , eMetric_FullCharHeight , eMetric_AvgCharWidth , eMetric_MaxCharWidth ,
  eMetric_TextWidth , eMetric_FullTextWidth , eMetric_Descender
}
 
enum  EAlignMode {
  eAlign_HorizMask = 0x000f , eAlign_Left = 0x0001 , eAlign_HCenter = 0x0002 , eAlign_Right = 0x0004 ,
  eAlign_VertMask = 0x00f0 , eAlign_Top = 0x0010 , eAlign_VCenter = 0x0020 , eAlign_Bottom = 0x0040 ,
  eAlign_Center = eAlign_HCenter | eAlign_VCenter
}
 alignment modes More...
 
typedef int TAlign
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 

Public Member Functions

 CGlTextureFont ()
 default constructor. More...
 
 CGlTextureFont (const string &font_file_name, unsigned int font_size=12)
 create a font with a face loaded from a file More...
 
 CGlTextureFont (EFontFace face, unsigned int font_size=12)
 create a font with one of the pre-defined faces More...
 
 ~CGlTextureFont ()
 use default copy ctor and operator=() More...
 
void SetFontFace (EFontFace face, bool use_bitmap_overrides=true)
 
EFontFace GetFontFace () const
 
void SetFontSize (unsigned int size)
 Set/get font size in points. More...
 
unsigned int GetFontSize () const
 
bool SetFont (string font_file_name, unsigned int font_size, bool use_bitmap_overrides=true)
 Load font from file explicitly. Returns true on success, false otherwise. More...
 
string GetFontFile () const
 Get current font filename. Fonts set via EFontFace also have filenames. More...
 
virtual bool IsBitmapFont () const
 Returns true if the currently loaded font is from a bitmap. More...
 
void SetFontRotate (TFontRotateFlags rot)
 Set rotation flags (for center of rotation and re-orienting) More...
 
TFontRotateFlags GetFontRotate (void) const
 
void SetSnapToPixel (bool xpix, bool ypix)
 If true (the default) text output position is rounded to nearest pixel coordinate, which improves text appearance (slightly) More...
 
void BeginText () const
 WriteText interface The WriteText functions produce the same results as TextOut but they are more effcient when writing multiple strings since the OpenGL state is only updated in BeginText and EndText. More...
 
void BeginText (const TVPRect &viewport) const
 Use this version if rendering may be non-OpenGL (viewport for pdf can be larger than max-size for OpenGL) More...
 
void BeginText (const TVPRect &viewport, GLdouble *mview, GLdouble *proj) const
 
void EndText () const
 Pops matrices and attributes after writing text. More...
 
void WriteText (TModelUnit x, TModelUnit y, const char *text, TModelUnit rotate_degrees=0.0) const
 Write text at specified model coords. More...
 
void WriteText (TModelUnit x, TModelUnit y, TModelUnit width, TModelUnit height, const char *text, TAlign align=eAlign_Center, ETruncate trunc=eTruncate_Ellipsis, TModelUnit rotate_degrees=0.0f) const
 Write text at specified model coords inside box defined by (x,y,width,height) with specified alignment, truncation and rotation. More...
 
void WriteText (TModelUnit x, TModelUnit y, const char *text, const float *color, TModelUnit rotate_degrees) const
 
void WriteText (TModelUnit x, TModelUnit y, TModelUnit width, TModelUnit height, const char *text, const float *color, TAlign align, ETruncate trunc, TModelUnit rotate_degrees) const
 Write text at specified model coords inside box defined by (x,y,width,height) with specified alignment, truncation and rotation. More...
 
CMatrix4< double > GetTextXform (TModelUnit x, TModelUnit y, TModelUnit width, TModelUnit height, string &text, TAlign align=eAlign_Center, ETruncate trunc=eTruncate_Ellipsis, TModelUnit rotate_degrees=0.0f) const
 Get the transformation that will be applied to the text to write it within the box (x,y,width,height). More...
 
virtual void TextOut (const char *text) const
 TextOut interface Write the specified text and set up state and transformation as needed. More...
 
virtual void TextOut (TModelUnit x, TModelUnit y, const char *text) const
 Write text at specified model coords (this function sets all necessary state) More...
 
void TextOut (TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2, const char *text, TAlign align=eAlign_Center, ETruncate trunc=eTruncate_Ellipsis, TModelUnit scale_x=1.0, TModelUnit scale_y=1.0) const
 Output text into a given rectangle using a particular alignment. More...
 
string Truncate (const char *text, TModelUnit w, ETruncate trunc=eTruncate_Ellipsis) const
 Truncate text to the secified width. More...
 
string Truncate (const string &text, TModelUnit w, ETruncate trunc=eTruncate_Ellipsis) const
 
void ArrayTextOut (TModelUnit x, TModelUnit y, TModelUnit dx, TModelUnit dy, const char *text, const vector< CRgbaColor * > *colors=NULL, TModelUnit scale_x=1.0f, TModelUnit scale_y=1.0f) const
 prints array of characters in positions (x + i*dx, y + i*dy) where "i" is index of a character in the given string More...
 
virtual TModelUnit TextWidth (const char *text) const
 Compute and return font metrics. More...
 
virtual TModelUnit TextHeight (void) const
 
virtual TModelUnit GetFontDescender () const
 
TModelUnit GetAdvance (char c) const
 
void ProjectVertex (CVect2< float > &vertex) const
 
TModelUnit GetMaxWidth (int max_num) const
 returns minimal space sufficient to render any number in [0, max_num]. More...
 
virtual TModelUnit GetMetric (EMetric metric, const char *text=NULL, int len=-1) const
 
string ToString () const
 saves and restores font face and size to/from a string More...
 
bool FromString (const string &value)
 
- Public Member Functions inherited from IGlFont
 IGlFont (void)
 
virtual ~IGlFont (void)
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (const CObject &src) THROWS_NONE
 Assignment operator. More...
 
bool CanBeDeleted (void) const THROWS_NONE
 Check if object can be deleted. More...
 
bool IsAllocatedInPool (void) const THROWS_NONE
 Check if object is allocated in memory pool (not system heap) More...
 
bool Referenced (void) const THROWS_NONE
 Check if object is referenced. More...
 
bool ReferencedOnlyOnce (void) const THROWS_NONE
 Check if object is referenced only once. More...
 
void AddReference (void) const
 Add reference to object. More...
 
void RemoveReference (void) const
 Remove reference to object. More...
 
void ReleaseReference (void) const
 Remove reference without deleting object. More...
 
virtual void DoNotDeleteThisObject (void)
 Mark this object as not allocated in heap – do not delete this object. More...
 
virtual void DoDeleteThisObject (void)
 Mark this object as allocated in heap – object can be deleted. More...
 
void * operator new (size_t size)
 Define new operator for memory allocation. More...
 
void * operator new[] (size_t size)
 Define new[] operator for 'array' memory allocation. More...
 
void operator delete (void *ptr)
 Define delete operator for memory deallocation. More...
 
void operator delete[] (void *ptr)
 Define delete[] operator for memory deallocation. More...
 
void * operator new (size_t size, void *place)
 Define new operator. More...
 
void operator delete (void *ptr, void *place)
 Define delete operator. More...
 
void * operator new (size_t size, CObjectMemoryPool *place)
 Define new operator using memory pool. More...
 
void operator delete (void *ptr, CObjectMemoryPool *place)
 Define delete operator. More...
 
virtual void DebugDump (CDebugDumpContext ddc, unsigned int depth) const
 Define method for dumping debug information. More...
 
- Public Member Functions inherited from CDebugDumpable
 CDebugDumpable (void)
 
virtual ~CDebugDumpable (void)
 
void DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const
 
void DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const
 
void DumpToConsole (void) const
 

Static Public Member Functions

static string GetFontFileForFace (EFontFace face)
 Get font file for given face. More...
 
static string FaceToString (EFontFace face)
 funtions below provide conversion of font parameters to strings and back. More...
 
static EFontFace FaceFromString (const string &str)
 Selects a font face given a string or eFontFace_LastFont on failure. More...
 
static string PdfBaseFontName (EFontFace face, EFontFace &pdf_face)
 Name of basefont for PDF purposes, or "" if not available. More...
 
static void GetAllFaces (vector< string > &faces)
 GetAllFaces() and GetAllSizes() fills containers with strings repesenting all available enumerated (pre-defined)fonts. More...
 
static void GetAllSizes (vector< string > &sizes)
 
- Static Public Member Functions inherited from CObject
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (void)
 Define method to throw null pointer exception. More...
 
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (const type_info &type)
 
static EAllocFillMode GetAllocFillMode (void)
 
static void SetAllocFillMode (EAllocFillMode mode)
 
static void SetAllocFillMode (const string &value)
 Set mode from configuration parameter value. More...
 
- Static Public Member Functions inherited from CDebugDumpable
static void EnableDebugDump (bool on)
 

Private Member Functions

int x_Truncate (const char *text, TModelUnit w, ETruncate trunc, string *str=NULL) const
 Truncate a string for display. More...
 
int x_Truncate2 (const char *text, TModelUnit w, ETruncate trunc, string *str=NULL) const
 
CMatrix4< double > x_WriteText (TModelUnit x, TModelUnit y, TModelUnit width, TModelUnit height, string &text, TAlign align, ETruncate trunc, TModelUnit rotate_degrees, bool write_text) const
 Called by both writetext and gettexttransform to compute transformation matrix or write the text. More...
 
string x_GetFontFile (EFontFace face, string font_file_name, unsigned int font_size, bool use_bitmap_overrides=true) const
 Return the font file for a font face - some fonts may use bitmap files for smaller sizes, so a font face can map to more than one file. More...
 
void x_ComputeMetrics ()
 Compute metrics for the font upon creation (for performance) More...
 

Private Attributes

FTFont * m_Font
 The current font for writing. These are owned by CFtglFontManager class. More...
 
EFontFace m_FontFace
 Current font face held by m_Font. More...
 
unsigned int m_FontSize
 Size of current font. More...
 
TFontRotateFlags m_Rotate
 flags for center of rotation and how to handle direction and orientation More...
 
bool m_SnapToPixelX
 Normally, when text is written to the screen the position is synched to the nearest pixel. More...
 
bool m_SnapToPixelY
 
string m_FontFile
 File from which current font was loaded. More...
 
TModelUnit m_MetricCharHeight
 Pre-computed metrics (may be computed first time accessed) More...
 
TModelUnit m_MetricFullCharHeight
 
TModelUnit m_MetricAvgCharWidth
 
TModelUnit m_MetricMaxCharWidth
 
TModelUnit m_MetricDescender
 
GLint m_Viewport [4]
 Temporary variables initialized by the BeginText() function and used by the Draw() functions. More...
 
GLdouble m_ModelviewMatrix [16]
 
GLdouble m_ProjectionMatrix [16]
 
GLint m_PrevShader
 Switch back to previous shader after writing text. More...
 

Static Private Attributes

static string s_FontFileNames []
 This maps EFontFace enums to font file names for loading. More...
 
static string s_FontNames []
 Maps EFontFace enums to a readable strings for selection lists. More...
 
static int s_FontSizes []
 Font sizes used as a standard set for user selection - last element in array is set to 0 as a marker. More...
 

Additional Inherited Members

- Static Public Attributes inherited from CObject
static const TCount eCounterBitsCanBeDeleted = 1 << 0
 Define possible object states. More...
 
static const TCount eCounterBitsInPlainHeap = 1 << 1
 Heap signature was found. More...
 
static const TCount eCounterBitsPlaceMask
 Mask for 'in heap' state flags. More...
 
static const int eCounterStep = 1 << 2
 Skip over the "in heap" bits. More...
 
static const TCount eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2)
 Minimal value for valid objects (reference counter is zero) Must be a single bit value. More...
 
static const TCount eCounterStateMask
 Valid object, and object in heap. More...
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Detailed Description

Definition at line 52 of file gltexturefont.hpp.


The documentation for this class was generated from the following files:
Modified on Mon Jun 17 05:09:51 2024 by modify_doxy.py rev. 669887