diff --git a/MTA10/core/CGraphics.cpp b/MTA10/core/CGraphics.cpp index 6292c60dea7..6931aace9e7 100644 --- a/MTA10/core/CGraphics.cpp +++ b/MTA10/core/CGraphics.cpp @@ -1140,8 +1140,7 @@ bool CGraphics::CreateStandardDXFontWithCustomScale ( eFontType fontType, float return true; } - -bool CGraphics::LoadAdditionalDXFont ( std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, ID3DXFont** ppD3DXFont ) +bool CGraphics::LoadAdditionalDXFont( std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, DWORD ulQuality, ID3DXFont** ppD3DXFont ) { int iLoaded = AddFontResourceEx ( strFontPath.c_str (), FR_PRIVATE, 0 ); @@ -1151,7 +1150,7 @@ bool CGraphics::LoadAdditionalDXFont ( std::string strFontPath, std::string strF bool bSuccess = true; // Normal size if( !SUCCEEDED ( D3DXCreateFont ( m_pDevice, uiHeight, 0, iWeight, 1, - FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, strFontName.c_str(), + FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ulQuality, DEFAULT_PITCH | FF_DONTCARE, strFontName.c_str(), ppD3DXFont ) ) ) { WriteErrorEvent( SString( "Could not create Direct3D font '%s'", strFontName.c_str() ) ); @@ -1161,6 +1160,12 @@ bool CGraphics::LoadAdditionalDXFont ( std::string strFontPath, std::string strF return bSuccess && ( iLoaded == 1 ); } + +bool CGraphics::LoadAdditionalDXFont ( std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, ID3DXFont** ppD3DXFont ) +{ + return this->LoadAdditionalDXFont( strFontPath, strFontName, uiHeight, bBold, PROOF_QUALITY, ppD3DXFont ); +} + bool CGraphics::DestroyAdditionalDXFont ( std::string strFontPath, ID3DXFont *pD3DXFont ) { bool bResult = RemoveFontResourceEx ( strFontPath.c_str (), FR_PRIVATE, 0 ) != 0; diff --git a/MTA10/core/CGraphics.h b/MTA10/core/CGraphics.h index e64a9edde91..b801a23bab0 100644 --- a/MTA10/core/CGraphics.h +++ b/MTA10/core/CGraphics.h @@ -108,6 +108,7 @@ class CGraphics : public CGraphicsInterface, public CSingleton < CGraphics > bool CreateStandardDXFontWithCustomScale ( eFontType fontType, float fScale, ID3DXFont** ppD3DXFont ); bool LoadAdditionalDXFont ( std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, ID3DXFont** ppD3DXFont ); + bool LoadAdditionalDXFont ( std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, DWORD ulQuality, ID3DXFont** ppD3DXFont ); bool DestroyAdditionalDXFont ( std::string strFontPath, ID3DXFont* pD3DXFont ); float GetDXFontHeight ( float fScale = 1.0f, ID3DXFont * pDXFont = NULL ); diff --git a/MTA10/core/CRenderItem.DxFont.cpp b/MTA10/core/CRenderItem.DxFont.cpp index b7f370e2132..bbf11ddc109 100644 --- a/MTA10/core/CRenderItem.DxFont.cpp +++ b/MTA10/core/CRenderItem.DxFont.cpp @@ -19,13 +19,13 @@ // // //////////////////////////////////////////////////////////////// -void CDxFontItem::PostConstruct ( CRenderItemManager* pManager, const SString& strFullFilePath, uint uiSize, bool bBold ) +void CDxFontItem::PostConstruct ( CRenderItemManager* pManager, const SString& strFullFilePath, uint uiSize, bool bBold, DWORD ulQuality ) { Super::PostConstruct ( pManager ); m_strFullFilePath = strFullFilePath; // Initial creation of d3d data - CreateUnderlyingData ( uiSize, bBold ); + CreateUnderlyingData ( uiSize, bBold, ulQuality ); } @@ -89,7 +89,7 @@ void CDxFontItem::OnResetDevice ( void ) // // //////////////////////////////////////////////////////////////// -void CDxFontItem::CreateUnderlyingData ( uint uiSize, bool bBold ) +void CDxFontItem::CreateUnderlyingData ( uint uiSize, bool bBold, DWORD ulQuality ) { assert ( !m_pFntNormal ); @@ -98,7 +98,7 @@ void CDxFontItem::CreateUnderlyingData ( uint uiSize, bool bBold ) // Create the D3DX fonts FONT_PROPERTIES sFontProps; if ( GetFontProperties ( LPCTSTR ( m_strFullFilePath.c_str () ), &sFontProps ) ) - CCore::GetSingleton ().GetGraphics()->LoadAdditionalDXFont ( m_strFullFilePath, sFontProps.csName, static_cast < int > ( std::floor ( uiSize * 1.75f ) ), bBold, &m_pFntNormal ); + CCore::GetSingleton ().GetGraphics()->LoadAdditionalDXFont ( m_strFullFilePath, sFontProps.csName, static_cast < int > ( std::floor ( uiSize * 1.75f ) ), bBold, ulQuality, &m_pFntNormal ); if ( !m_pFntNormal ) return; diff --git a/MTA10/core/CRenderItemManager.cpp b/MTA10/core/CRenderItemManager.cpp index e8da42f3ed1..3293a132e7b 100644 --- a/MTA10/core/CRenderItemManager.cpp +++ b/MTA10/core/CRenderItemManager.cpp @@ -263,13 +263,13 @@ CShaderItem* CRenderItemManager::CreateShader ( const SString& strFullFilePath, // TODO: Make underlying data for fonts shared // //////////////////////////////////////////////////////////////// -CDxFontItem* CRenderItemManager::CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold ) +CDxFontItem* CRenderItemManager::CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold, DWORD ulQuality ) { if ( !CanCreateRenderItem ( CDxFontItem::GetClassId () ) ) return NULL; CDxFontItem* pDxFontItem = new CDxFontItem (); - pDxFontItem->PostConstruct ( this, strFullFilePath, uiSize, bBold ); + pDxFontItem->PostConstruct ( this, strFullFilePath, uiSize, bBold, ulQuality ); if ( !pDxFontItem->IsValid () ) { diff --git a/MTA10/core/CRenderItemManager.h b/MTA10/core/CRenderItemManager.h index 9a065a32a8f..dcbda40cc1b 100644 --- a/MTA10/core/CRenderItemManager.h +++ b/MTA10/core/CRenderItemManager.h @@ -25,7 +25,7 @@ class CRenderItemManager : public CRenderItemManagerInterface // CRenderItemManagerInterface virtual void DoPulse ( void ); - virtual CDxFontItem* CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold ); + virtual CDxFontItem* CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold, DWORD ulQuality = DEFAULT_QUALITY ); virtual CGuiFontItem* CreateGuiFont ( const SString& strFullFilePath, const SString& strFontName, uint uiSize ); virtual CTextureItem* CreateTexture ( const SString& strFullFilePath, const CPixels* pPixels, bool bMipMaps = true, uint uiSizeX = RDEFAULT, uint uiSizeY = RDEFAULT, ERenderFormat format = RFORMAT_UNKNOWN, ETextureAddress textureAddress = TADDRESS_WRAP, ETextureType textureType = TTYPE_TEXTURE, uint uiVolumeDepth = 1 ); virtual CShaderItem* CreateShader ( const SString& strFullFilePath, const SString& strRootPath, SString& strOutStatus, float fPriority, float fMaxDistance, bool bLayered, bool bDebug, int iTypeMask ); diff --git a/MTA10/mods/shared_logic/CClientRenderElementManager.cpp b/MTA10/mods/shared_logic/CClientRenderElementManager.cpp index 7cbff884ae8..03b2f731105 100644 --- a/MTA10/mods/shared_logic/CClientRenderElementManager.cpp +++ b/MTA10/mods/shared_logic/CClientRenderElementManager.cpp @@ -53,10 +53,10 @@ CClientRenderElementManager::~CClientRenderElementManager ( void ) // // //////////////////////////////////////////////////////////////// -CClientDxFont* CClientRenderElementManager::CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold ) +CClientDxFont* CClientRenderElementManager::CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold, const DWORD ulQuality ) { // Create the item - CDxFontItem* pDxFontItem = m_pRenderItemManager->CreateDxFont ( strFullFilePath, uiSize, bBold ); + CDxFontItem* pDxFontItem = m_pRenderItemManager->CreateDxFont ( strFullFilePath, uiSize, bBold, ulQuality ); // Check create worked if ( !pDxFontItem ) diff --git a/MTA10/mods/shared_logic/CClientRenderElementManager.h b/MTA10/mods/shared_logic/CClientRenderElementManager.h index 5a8cf0a1247..379c3ddd459 100644 --- a/MTA10/mods/shared_logic/CClientRenderElementManager.h +++ b/MTA10/mods/shared_logic/CClientRenderElementManager.h @@ -26,7 +26,7 @@ class CClientRenderElementManager CClientRenderElementManager ( CClientManager* pClientManager ); ~CClientRenderElementManager ( void ); - CClientDxFont* CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold ); + CClientDxFont* CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold, DWORD ulQuality = DEFAULT_QUALITY ); CClientGuiFont* CreateGuiFont ( const SString& strFullFilePath, const SString& strUniqueName, uint uiSize ); CClientTexture* CreateTexture ( const SString& strFullFilePath, const CPixels* pPixels = NULL, bool bMipMaps = true, uint uiSizeX = RDEFAULT, uint uiSizeY = RDEFAULT, ERenderFormat format = RFORMAT_UNKNOWN, ETextureAddress textureAddress = TADDRESS_WRAP, ETextureType textureType = TTYPE_TEXTURE, uint uiVolumeDepth = 1 ); CClientShader* CreateShader ( const SString& strFullFilePath, const SString& strRootPath, SString& strOutStatus, float fPriority, float fMaxDistance, bool bLayered, bool bDebug, int iTypeMask ); diff --git a/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Drawing.cpp b/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Drawing.cpp index 628bdd65a5a..e0d555255c3 100644 --- a/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Drawing.cpp +++ b/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Drawing.cpp @@ -852,12 +852,13 @@ int CLuaFunctionDefs::dxUpdateScreenSource ( lua_State* luaVM ) int CLuaFunctionDefs::dxCreateFont ( lua_State* luaVM ) { // element dxCreateFont( string filepath [, int size=9, bool bold=false ] ) - SString strFilePath; int iSize; bool bBold; + SString strFilePath; int iSize; bool bBold; eFontQuality ulFontQuality; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strFilePath ); argStream.ReadNumber ( iSize, 9 ); argStream.ReadBool ( bBold, false ); + argStream.ReadEnumString ( ulFontQuality, FONT_QUALITY_PROOF ); if ( !argStream.HasErrors () ) { @@ -871,14 +872,16 @@ int CLuaFunctionDefs::dxCreateFont ( lua_State* luaVM ) { if ( FileExists ( strPath ) ) { - CClientDxFont* pDxFont = g_pClientGame->GetManager ()->GetRenderElementManager ()->CreateDxFont ( strPath, iSize, bBold ); - if ( pDxFont ) + CClientDxFont* pDxFont = g_pClientGame->GetManager()->GetRenderElementManager()->CreateDxFont( strPath, iSize, bBold, ulFontQuality ); + + if( pDxFont ) { // Make it a child of the resource's file root ** CHECK Should parent be pFileResource, and element added to pParentResource's ElementGroup? ** - pDxFont->SetParent ( pParentResource->GetResourceDynamicEntity () ); - lua_pushelement ( luaVM, pDxFont ); + pDxFont->SetParent( pParentResource->GetResourceDynamicEntity() ); + lua_pushelement( luaVM, pDxFont ); return 1; } + argStream.SetCustomError( strFilePath, "Error creating font" ); } else diff --git a/MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.cpp b/MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.cpp index 27c1ad348cb..2b7f5892f3b 100644 --- a/MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.cpp +++ b/MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.cpp @@ -394,6 +394,20 @@ IMPLEMENT_ENUM_BEGIN( eFontType ) ADD_ENUM( FONT_BECKETT, "beckett" ) IMPLEMENT_ENUM_END_DEFAULTS( "font-type", FONT_DEFAULT, "" ) +IMPLEMENT_ENUM_BEGIN( eFontQuality ) + ADD_ENUM( FONT_QUALITY_DEFAULT, "default" ) + ADD_ENUM( FONT_QUALITY_DRAFT, "draft" ) + ADD_ENUM( FONT_QUALITY_PROOF, "proof" ) +#if( WINVER >= 0x0400 ) + ADD_ENUM( FONT_QUALITY_NONANTIALIASED, "nonantialiased" ) + ADD_ENUM( FONT_QUALITY_ANTIALIASED, "antialiased" ) +#endif +#if( _WIN32_WINNT >= _WIN32_WINNT_WINXP ) + ADD_ENUM( FONT_QUALITY_CLEARTYPE, "cleartype" ) + ADD_ENUM( FONT_QUALITY_CLEARTYPE_NATURAL, "cleartype_natural" ) +#endif +IMPLEMENT_ENUM_END_DEFAULTS( "font-quality", FONT_QUALITY_DEFAULT, "" ) + IMPLEMENT_ENUM_BEGIN ( eAudioLookupIndex ) ADD_ENUM ( AUDIO_LOOKUP_FEET, "feet" ) ADD_ENUM ( AUDIO_LOOKUP_GENRL, "genrl" ) diff --git a/MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.h b/MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.h index d0a32b1da58..7db92e6bbb6 100644 --- a/MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.h +++ b/MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.h @@ -36,6 +36,7 @@ DECLARE_ENUM( eWeaponState ); DECLARE_ENUM( eWeaponFlags ); DECLARE_ENUM( eVehicleComponent ); DECLARE_ENUM( eFontType ); +DECLARE_ENUM( eFontQuality ); DECLARE_ENUM( eAudioLookupIndex ); DECLARE_ENUM( eAspectRatio ); DECLARE_ENUM( eRadioStreamIndex ); diff --git a/MTA10/sdk/core/CGraphicsInterface.h b/MTA10/sdk/core/CGraphicsInterface.h index f4a3b1cb39d..a97a7869308 100644 --- a/MTA10/sdk/core/CGraphicsInterface.h +++ b/MTA10/sdk/core/CGraphicsInterface.h @@ -33,6 +33,25 @@ enum eFontType NUM_FONTS }; +enum eFontQuality +{ + FONT_QUALITY_DEFAULT = DEFAULT_QUALITY, + FONT_QUALITY_DRAFT = DRAFT_QUALITY, + FONT_QUALITY_PROOF = PROOF_QUALITY, + +#if( WINVER >= 0x0400 ) + FONT_QUALITY_NONANTIALIASED = NONANTIALIASED_QUALITY, + FONT_QUALITY_ANTIALIASED = ANTIALIASED_QUALITY, +#endif + +#if( _WIN32_WINNT >= _WIN32_WINNT_WINXP ) + FONT_QUALITY_CLEARTYPE = CLEARTYPE_QUALITY, + FONT_QUALITY_CLEARTYPE_NATURAL = CLEARTYPE_NATURAL_QUALITY, +#endif + + NUM_QUALITIES +}; + namespace EBlendMode { enum EBlendModeType @@ -78,6 +97,7 @@ class CGraphicsInterface virtual float GetDXTextExtent ( const char * szText, float fScale = 1.0f, ID3DXFont * pDXFont = NULL, bool bColorCoded = false ) = 0; virtual bool LoadAdditionalDXFont ( std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, ID3DXFont** ppD3DXFont ) = 0; + virtual bool LoadAdditionalDXFont ( std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, DWORD ulQuality, ID3DXFont** ppD3DXFont ) = 0; virtual bool DestroyAdditionalDXFont ( std::string strFontPath, ID3DXFont* pD3DXFont ) = 0; virtual ID3DXFont * GetFont ( eFontType fontType = FONT_DEFAULT, float* pfOutScaleUsed = NULL, float fRequestedScale = 1, const char* szCustomScaleUser = NULL ) = 0; diff --git a/MTA10/sdk/core/CRenderItemManagerInterface.h b/MTA10/sdk/core/CRenderItemManagerInterface.h index 3df06d95873..e37d5ca49cf 100644 --- a/MTA10/sdk/core/CRenderItemManagerInterface.h +++ b/MTA10/sdk/core/CRenderItemManagerInterface.h @@ -136,7 +136,7 @@ class CRenderItemManagerInterface // CRenderItemManagerInterface virtual void DoPulse ( void ) = 0; - virtual CDxFontItem* CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold ) = 0; + virtual CDxFontItem* CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold, DWORD ulQuality = DEFAULT_QUALITY ) = 0; virtual CGuiFontItem* CreateGuiFont ( const SString& strFullFilePath, const SString& strFontName, uint uiSize ) = 0; virtual CTextureItem* CreateTexture ( const SString& strFullFilePath, const CPixels* pPixels = NULL, bool bMipMaps = true, uint uiSizeX = RDEFAULT, uint uiSizeY = RDEFAULT, ERenderFormat format = RFORMAT_UNKNOWN, ETextureAddress textureAddress = TADDRESS_WRAP, ETextureType textureType = TTYPE_TEXTURE, uint uiVolumeDepth = 1 ) = 0; virtual CShaderItem* CreateShader ( const SString& strFullFilePath, const SString& strRootPath, SString& strOutStatus, float fPriority, float fMaxDistance, bool bLayered, bool bDebug, int iTypeMask ) = 0; @@ -263,12 +263,12 @@ class CDxFontItem : public CRenderItem { DECLARE_CLASS( CDxFontItem, CRenderItem ) CDxFontItem ( void ) : ClassInit ( this ) {} - virtual void PostConstruct ( CRenderItemManager* pManager, const SString& strFullFilePath, uint uiSize, bool bBold ); + virtual void PostConstruct ( CRenderItemManager* pManager, const SString& strFullFilePath, uint uiSize, bool bBold, DWORD ulQuality = DEFAULT_QUALITY ); virtual void PreDestruct ( void ); virtual bool IsValid ( void ); virtual void OnLostDevice ( void ); virtual void OnResetDevice ( void ); - void CreateUnderlyingData ( uint uiSize, bool bBold ); + void CreateUnderlyingData ( uint uiSize, bool bBold, DWORD ulQuality = DEFAULT_QUALITY ); void ReleaseUnderlyingData ( void ); SString m_strFullFilePath;