Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FontManager.h"
- #include "WinCustom.h"
- CFontManager gFontManager;
- CFontManager::CFontManager ( void )
- {
- m_font.clear ();
- }
- CFontManager::~CFontManager ( void )
- {
- m_font.clear ();
- }
- void CFontManager::AddFont ( const char* fontName, int fontSize )
- {
- renderer_font_t fontSlot;
- strncpy_s ( fontSlot.m_fontName, fontName, 128 );
- fontSlot.m_fontSize = fontSize;
- fontSlot.m_fontPointer = 0;
- m_font.push_back ( fontSlot );
- }
- void CFontManager::Update ( IDirect3DDevice9* pDevice )
- {
- if ( !m_font.empty () )
- {
- for ( int i = 0; i < m_font.size (); i++ )
- {
- if ( !m_font.at ( i ).m_fontPointer )
- {
- if ( FAILED(D3DXCreateFontA ( pDevice, m_font.at ( i ).m_fontSize, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, m_font.at ( i ).m_fontName, &m_font.at ( i ).m_fontPointer )) )
- {
- DbgPrint ( "Can't create font %s with size of %i!", m_font.at ( i ).m_fontName, m_font.at ( i ).m_fontSize );
- }
- }
- }
- }
- }
- void CFontManager::Release ( void )
- {
- if ( !m_font.empty () )
- {
- for ( int i = 0; i < m_font.size (); i++ )
- {
- if ( m_font.at ( i ).m_fontPointer )
- {
- m_font.at ( i ).m_fontPointer->OnLostDevice ();
- m_font.at ( i ).m_fontPointer->OnResetDevice ();
- }
- }
- }
- }
- ID3DXFont* CFontManager::GetFont ( const char* fontName )
- {
- if ( !m_font.empty () )
- {
- for ( int i = 0; i < m_font.size (); i++ )
- {
- if ( !strcmp ( m_font.at ( i ).m_fontName, fontName ) )
- {
- return m_font.at ( i ).m_fontPointer;
- }
- }
- }
- return 0;
- }
- int CFontManager::GetFontSize ( const char* fontName )
- {
- if ( !m_font.empty () )
- {
- for ( int i = 0; i < m_font.size (); i++ )
- {
- if ( !strcmp ( m_font.at ( i ).m_fontName, fontName ) )
- {
- return m_font.at ( i ).m_fontSize;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement