OpenBarnyard
 
Loading...
Searching...
No Matches
AGUI2FontManager Class Reference

#include <AGUI2FontManager.h>

Static Public Member Functions

static TBOOL Open (const TCHAR *a_szFileName)
 
static AGUI2FontFindFont (const TCHAR *a_szFontName)
 
static AGUI2FontRefFindFontRef (const TCHAR *a_szFontName)
 
static AGUI2FontResourceFindFontResource (const TCHAR *a_szResourceName)
 

Static Public Attributes

static constexpr TUINT MAX_NUM_LOADED_FONTS = 1
 
static constexpr TUINT MAX_NUM_FONT_REFS = 16
 
static AGUI2FontResource s_fontresources [MAX_NUM_LOADED_FONTS]
 
static AGUI2FontRef s_fontrefs [MAX_NUM_FONT_REFS]
 

Detailed Description

Definition at line 5 of file AGUI2FontManager.h.

Member Function Documentation

◆ FindFont()

AGUI2Font * AGUI2FontManager::FindFont ( const TCHAR * a_szFontName)
static

Definition at line 44 of file AGUI2FontManager.cpp.

45{
46 auto pRef = FindFontRef( a_szFontName );
47
48 if ( pRef )
49 {
50 pRef->uiNumRefs += 1;
51 return pRef->pFont;
52 }
53
54 return TNULL;
55}
#define TNULL
Definition Typedefs.h:23
static AGUI2FontRef * FindFontRef(const TCHAR *a_szFontName)

◆ FindFontRef()

AGUI2FontRef * AGUI2FontManager::FindFontRef ( const TCHAR * a_szFontName)
static

Definition at line 57 of file AGUI2FontManager.cpp.

58{
59 for ( TUINT i = 0; i < MAX_NUM_FONT_REFS; i++ )
60 {
61 if ( s_fontrefs[ i ].pFontResource != TNULL )
62 {
63 if ( TStringManager::String8CompareNoCase( s_fontrefs[ i ].szName, a_szFontName ) == 0 )
64 {
65 return &s_fontrefs[ i ];
66 }
67 }
68 }
69
70 return TNULL;
71}
unsigned int TUINT
Definition Typedefs.h:8
static TINT String8CompareNoCase(const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)
static constexpr TUINT MAX_NUM_FONT_REFS
static AGUI2FontRef s_fontrefs[MAX_NUM_FONT_REFS]

◆ FindFontResource()

AGUI2FontResource * AGUI2FontManager::FindFontResource ( const TCHAR * a_szResourceName)
static

Definition at line 73 of file AGUI2FontManager.cpp.

74{
75 for ( TUINT i = 0; i < MAX_NUM_LOADED_FONTS; i++ )
76 {
77 if ( s_fontresources[ i ].uiRefCount > 0 )
78 {
79 if ( TStringManager::String8CompareNoCase( s_fontresources[ i ].szFileName, a_szResourceName ) == 0 )
80 {
81 return &s_fontresources[ i ];
82 }
83 }
84 }
85
86 return TNULL;
87}
static AGUI2FontResource s_fontresources[MAX_NUM_LOADED_FONTS]
static constexpr TUINT MAX_NUM_LOADED_FONTS

◆ Open()

TBOOL AGUI2FontManager::Open ( const TCHAR * a_szFileName)
static

Definition at line 12 of file AGUI2FontManager.cpp.

13{
14 auto pResource = FindFontResource( a_szFileName );
15
16 if ( pResource )
17 {
18 pResource->uiRefCount++;
19 return TTRUE;
20 }
21
22 pResource = FindUnusedFontResource();
23 TASSERT( pResource != TNULL );
24
25 if ( !pResource )
26 {
27 return TFALSE;
28 }
29
30 if ( pResource->oTRB.Load( a_szFileName ) != TTRB::ERROR_OK )
31 {
32 return TFALSE;
33 }
34
35 pResource->szFileName = new TCHAR[ TStringManager::String8Length( a_szFileName ) + 1 ];
36 TStringManager::String8Copy( pResource->szFileName, a_szFileName );
37
38 pResource->uiRefCount++;
39 CreateFontFromResource( pResource );
40
41 return TTRUE;
42}
#define TASSERT(X,...)
Definition Defines.h:138
char TCHAR
Definition Typedefs.h:20
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
@ ERROR_OK
Definition TTRB.h:258
static TSIZE String8Length(const TCHAR *str)
static TCHAR * String8Copy(TCHAR *dst, const TCHAR *src, TSIZE size=-1)
static AGUI2FontResource * FindFontResource(const TCHAR *a_szResourceName)

Member Data Documentation

◆ MAX_NUM_FONT_REFS

TUINT AGUI2FontManager::MAX_NUM_FONT_REFS = 16
staticconstexpr

Definition at line 9 of file AGUI2FontManager.h.

◆ MAX_NUM_LOADED_FONTS

TUINT AGUI2FontManager::MAX_NUM_LOADED_FONTS = 1
staticconstexpr

Definition at line 8 of file AGUI2FontManager.h.

◆ s_fontrefs

AGUI2FontRef AGUI2FontManager::s_fontrefs[MAX_NUM_FONT_REFS]
inlinestatic

Definition at line 25 of file AGUI2FontManager.h.

◆ s_fontresources

AGUI2FontResource AGUI2FontManager::s_fontresources[MAX_NUM_LOADED_FONTS]
inlinestatic

Definition at line 24 of file AGUI2FontManager.h.


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