Darryl Pogue
9 years ago
6 changed files with 0 additions and 1784 deletions
File diff suppressed because it is too large
Load Diff
@ -1,221 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify |
|
||||||
it under the terms of the GNU General Public License as published by |
|
||||||
the Free Software Foundation, either version 3 of the License, or |
|
||||||
(at your option) any later version. |
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, |
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
GNU General Public License for more details. |
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License |
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// //
|
|
||||||
// plDynSurfaceWriter Class Header //
|
|
||||||
// Abstract class wrapping around Windows GDI functionality for writing to //
|
|
||||||
// a generic RGBA surface. Allows us to create one writer per DTMap or a //
|
|
||||||
// single shared writer to conserve OS resources on 98/ME. //
|
|
||||||
// //
|
|
||||||
// Cyan, Inc. //
|
|
||||||
// //
|
|
||||||
//// Version History //////////////////////////////////////////////////////////
|
|
||||||
// //
|
|
||||||
// 10.28.2002 mcn - Created. //
|
|
||||||
// //
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef _plDynSurfaceWriter_h |
|
||||||
#define _plDynSurfaceWriter_h |
|
||||||
|
|
||||||
#include "hsColorRGBA.h" |
|
||||||
#include "hsWindows.h" // FIXME: windows :( |
|
||||||
|
|
||||||
struct hsMatrix44; |
|
||||||
|
|
||||||
class plDynamicTextMap; |
|
||||||
|
|
||||||
//// Class Definition /////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class plDynSurfaceWriter |
|
||||||
{ |
|
||||||
public: |
|
||||||
|
|
||||||
//// Public Flags ////
|
|
||||||
enum Justify |
|
||||||
{ |
|
||||||
kLeftJustify = 0, |
|
||||||
kCenter, |
|
||||||
kRightJustify |
|
||||||
}; |
|
||||||
|
|
||||||
enum Flags |
|
||||||
{ |
|
||||||
kSupportAlpha = 0x00000001, |
|
||||||
|
|
||||||
kFontBold = 0x00000002, |
|
||||||
kFontItalic = 0x00000004, |
|
||||||
kFontShadowed = 0x00000008, |
|
||||||
kFontMask = 0x0000000e, |
|
||||||
|
|
||||||
kDiscardOnFlush = 0x00000010 |
|
||||||
}; |
|
||||||
|
|
||||||
//// Public Data /////
|
|
||||||
|
|
||||||
|
|
||||||
//// Public Members ////
|
|
||||||
|
|
||||||
|
|
||||||
plDynSurfaceWriter(); |
|
||||||
plDynSurfaceWriter( plDynamicTextMap *target, uint32_t flags = 0 ); |
|
||||||
virtual ~plDynSurfaceWriter(); |
|
||||||
|
|
||||||
|
|
||||||
/// Operations to perform on the text block
|
|
||||||
|
|
||||||
void ClearToColor( hsColorRGBA &color ); |
|
||||||
void SetFont( const char *face, uint16_t size, uint8_t fontFlags = 0, bool antiAliasRGB = true ); |
|
||||||
void SetTextColor( hsColorRGBA &color, bool blockRGB = false ); |
|
||||||
void SetJustify( Justify j ); |
|
||||||
|
|
||||||
void DrawString( uint16_t x, uint16_t y, const char *text ); |
|
||||||
void DrawClippedString( int16_t x, int16_t y, const char *text, uint16_t width, uint16_t height ); |
|
||||||
void DrawClippedString( int16_t x, int16_t y, const char *text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height ); |
|
||||||
void DrawWrappedString( uint16_t x, uint16_t y, const char *text, uint16_t width, uint16_t height ); |
|
||||||
uint16_t CalcStringWidth( const char *text, uint16_t *height = nil ); |
|
||||||
void CalcWrappedStringSize( const char *text, uint16_t *width, uint16_t *height ); |
|
||||||
void FillRect( uint16_t x, uint16_t y, uint16_t width, uint16_t height, hsColorRGBA &color ); |
|
||||||
void FrameRect( uint16_t x, uint16_t y, uint16_t width, uint16_t height, hsColorRGBA &color ); |
|
||||||
|
|
||||||
// void DrawImage( uint16_t x, uint16_t y, plMipmap *image, bool respectAlpha = false );
|
|
||||||
// void DrawClippedImage( uint16_t x, uint16_t y, plMipmap *image, uint16_t srcClipX, uint16_t srcClipY,
|
|
||||||
// uint16_t srcClipWidth, uint16_t srcClipHeight, bool respectAlpha = false );
|
|
||||||
|
|
||||||
// Copy the raw data from the given buffer.
|
|
||||||
// void SetBitsFromBuffer( uint32_t *clearBuffer, uint16_t width, uint16_t height )
|
|
||||||
|
|
||||||
/// Target switching operations
|
|
||||||
|
|
||||||
// Flushes all ops to the target.
|
|
||||||
void FlushToTarget( void ); |
|
||||||
|
|
||||||
// Switches targets. Will flush to old target before switching. Also, if kDiscard isn't specified, will copy contents of new target to working surface
|
|
||||||
void SwitchTarget( plDynamicTextMap *target ); // Will force a flush
|
|
||||||
|
|
||||||
// Clears and resets everything. Does NOT flush.
|
|
||||||
void Reset( void ); |
|
||||||
|
|
||||||
bool IsValid( void ) const; |
|
||||||
|
|
||||||
static bool CanHandleLotsOfThem( void ); |
|
||||||
|
|
||||||
protected: |
|
||||||
|
|
||||||
//// Protected Members ////
|
|
||||||
|
|
||||||
void IInit( void ); |
|
||||||
void IEnsureSurfaceUpdated( void ); |
|
||||||
void IRefreshOSJustify( void ); |
|
||||||
void ISetTextColor( hsColorRGBA &color, bool blockRGB ); |
|
||||||
|
|
||||||
void ISetFont( const plString &face, uint16_t size, uint8_t fontFlags = 0, bool antiAliasRGB = true ); |
|
||||||
|
|
||||||
plDynamicTextMap *fCurrTarget; |
|
||||||
uint32_t fFlags; |
|
||||||
Justify fJustify; |
|
||||||
bool fFlushed; |
|
||||||
|
|
||||||
plString fFontFace; |
|
||||||
uint16_t fFontSize; |
|
||||||
uint8_t fFontFlags; |
|
||||||
bool fFontAntiAliasRGB; |
|
||||||
bool fFontBlockedRGB; |
|
||||||
|
|
||||||
static bool fForceSharedSurfaces; |
|
||||||
static bool fOSDetected; |
|
||||||
static bool fOSCanShareSurfaces; |
|
||||||
|
|
||||||
#if HS_BUILD_FOR_WIN32 |
|
||||||
class plWinSurface |
|
||||||
{ |
|
||||||
protected: |
|
||||||
void *fBits; |
|
||||||
|
|
||||||
virtual uint8_t IBitsPerPixel( void ) const = 0; |
|
||||||
|
|
||||||
public: |
|
||||||
HDC fDC; |
|
||||||
HBITMAP fBitmap; |
|
||||||
HFONT fFont; |
|
||||||
COLORREF fTextColor; |
|
||||||
int fSaveNum; |
|
||||||
|
|
||||||
uint16_t fWidth, fHeight; |
|
||||||
|
|
||||||
plString fFontFace; |
|
||||||
uint16_t fFontSize; |
|
||||||
uint8_t fFontFlags; |
|
||||||
bool fFontAntiAliasRGB, fFontBlockedRGB; |
|
||||||
|
|
||||||
plWinSurface(); |
|
||||||
~plWinSurface(); |
|
||||||
|
|
||||||
void Allocate( uint16_t w, uint16_t h ); |
|
||||||
void Release( void ); |
|
||||||
|
|
||||||
bool WillFit( uint16_t w, uint16_t h ); |
|
||||||
bool FontMatches( const plString &face, uint16_t size, uint8_t flags, bool aaRGB ); |
|
||||||
void SetFont( const plString &face, uint16_t size, uint8_t flags, bool aaRGB ); |
|
||||||
}; |
|
||||||
|
|
||||||
class plWinRGBSurface : public plWinSurface |
|
||||||
{ |
|
||||||
virtual uint8_t IBitsPerPixel( void ) const { return 32; } |
|
||||||
public: |
|
||||||
uint32_t *GetBits( void ) const { return (uint32_t *)fBits; } |
|
||||||
}; |
|
||||||
|
|
||||||
class plWinAlphaSurface : public plWinSurface |
|
||||||
{ |
|
||||||
virtual uint8_t IBitsPerPixel( void ) const { return 8; } |
|
||||||
public: |
|
||||||
uint8_t *GetBits( void ) const { return (uint8_t *)fBits; } |
|
||||||
}; |
|
||||||
|
|
||||||
plWinRGBSurface fRGBSurface; |
|
||||||
plWinAlphaSurface fAlphaSurface; |
|
||||||
#endif |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
#endif // _plDynSurfaceWriter_h
|
|
@ -1,293 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify |
|
||||||
it under the terms of the GNU General Public License as published by |
|
||||||
the Free Software Foundation, either version 3 of the License, or |
|
||||||
(at your option) any later version. |
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, |
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
GNU General Public License for more details. |
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License |
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// //
|
|
||||||
// plWinFontCache Class Header //
|
|
||||||
// I've stopped keeping track, there are far too many reasons already to //
|
|
||||||
// hate Microsoft. Anyway, this class keeps track of various Win32 fonts we //
|
|
||||||
// allocate because Win98/ME seems to have problems re-allocating the exact //
|
|
||||||
// same freaking goddamn font over and over again. I mean, you'd think //
|
|
||||||
// there'd be a rule somewhere about deterministic behavior when calling //
|
|
||||||
// the exact same function with the exact same parameters over and over... //
|
|
||||||
// Oh, wait... //
|
|
||||||
// //
|
|
||||||
// Cyan, Inc. //
|
|
||||||
// //
|
|
||||||
//// Version History //////////////////////////////////////////////////////////
|
|
||||||
// //
|
|
||||||
// 11.25.2002 mcn - Created. //
|
|
||||||
// //
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "HeadSpin.h" |
|
||||||
|
|
||||||
#include "plWinFontCache.h" |
|
||||||
|
|
||||||
#include "plStatusLog/plStatusLog.h" |
|
||||||
#include "plGImage/plDynSurfaceWriter.h" |
|
||||||
|
|
||||||
#if HS_BUILD_FOR_WIN32 |
|
||||||
|
|
||||||
#include <wingdi.h> |
|
||||||
|
|
||||||
|
|
||||||
const char* plWinFontCache::kCustFontExtension = ".prf"; |
|
||||||
|
|
||||||
|
|
||||||
plWinFontCache::plWinFontCache() |
|
||||||
{ |
|
||||||
fInShutdown = false; |
|
||||||
fCustFontDir = nil; |
|
||||||
} |
|
||||||
|
|
||||||
plWinFontCache::~plWinFontCache() |
|
||||||
{ |
|
||||||
fInShutdown = true; |
|
||||||
Clear(); |
|
||||||
delete [] fCustFontDir; |
|
||||||
} |
|
||||||
|
|
||||||
plWinFontCache &plWinFontCache::GetInstance( void ) |
|
||||||
{ |
|
||||||
static plWinFontCache cache; |
|
||||||
return cache; |
|
||||||
} |
|
||||||
|
|
||||||
HFONT plWinFontCache::IFindFont( const plString &face, int height, int weight, bool italic, uint32_t quality ) |
|
||||||
{ |
|
||||||
int i; |
|
||||||
|
|
||||||
|
|
||||||
for( i = 0; i < fFontCache.GetCount(); i++ ) |
|
||||||
{ |
|
||||||
// Do other tests first, since they're cheaper
|
|
||||||
if( fFontCache[ i ].fHeight == height && |
|
||||||
fFontCache[ i ].fWeight == weight && |
|
||||||
fFontCache[ i ].fItalic == italic && |
|
||||||
fFontCache[ i ].fQuality == quality ) |
|
||||||
{ |
|
||||||
if (fFontCache[i].fFace == face) |
|
||||||
return fFontCache[ i ].fFont; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return nil; |
|
||||||
} |
|
||||||
|
|
||||||
HFONT plWinFontCache::IMakeFont( const plString &face, int height, int weight, bool italic, uint32_t quality ) |
|
||||||
{ |
|
||||||
plFontRecord myRec; |
|
||||||
int i; |
|
||||||
|
|
||||||
|
|
||||||
// Find a cached name for us
|
|
||||||
for( i = 0; i < fFontNameCache.GetCount(); i++ ) |
|
||||||
{ |
|
||||||
if (face == fFontNameCache[i]) |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
if( i == fFontNameCache.GetCount() ) |
|
||||||
fFontNameCache.Append(face); |
|
||||||
|
|
||||||
myRec.fFace = fFontNameCache[ i ]; |
|
||||||
myRec.fHeight = height; |
|
||||||
myRec.fWeight = weight; |
|
||||||
myRec.fItalic = italic; |
|
||||||
myRec.fQuality = quality; |
|
||||||
|
|
||||||
myRec.fFont = CreateFontW( height, 0, 0, 0, weight, italic ? TRUE : FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, |
|
||||||
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, face.ToWchar().GetData() ); |
|
||||||
|
|
||||||
if( myRec.fFont != nil ) |
|
||||||
{ |
|
||||||
//#ifdef HS_DEBUGGING
|
|
||||||
#if 1 |
|
||||||
LOGFONT fontInfo; |
|
||||||
|
|
||||||
if( GetObject( myRec.fFont, sizeof( fontInfo ), &fontInfo ) ) |
|
||||||
{ |
|
||||||
const char *err = nil; |
|
||||||
|
|
||||||
if( fontInfo.lfQuality != quality )
|
|
||||||
err = "Quality of created font does not match"; |
|
||||||
if( fontInfo.lfHeight != height ) |
|
||||||
err = "Height of created font does not match"; |
|
||||||
if( fontInfo.lfWeight != weight ) |
|
||||||
err = "Weight of created font does not match"; |
|
||||||
if( static_cast<bool>(fontInfo.lfItalic) != italic ) |
|
||||||
err = "Italic-ness of created font does not match"; |
|
||||||
if( face.CompareI(fontInfo.lfFaceName) != 0 ) |
|
||||||
err = "Face of created font does not match"; |
|
||||||
|
|
||||||
if( err != nil ) |
|
||||||
{ |
|
||||||
static bool triedClearing = false; |
|
||||||
|
|
||||||
if( fontInfo.lfQuality != quality )
|
|
||||||
{ |
|
||||||
plStatusLog::AddLineS( "pipeline.log", "ERROR: CreateFont() failed to return proper font (%s). Using what was given...", err ); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
plStatusLog::AddLineS( "pipeline.log", "ERROR: CreateFont() failed to return proper font (%s). %s", err, triedClearing ? "" : "Clearing cache and retrying..." ); |
|
||||||
if( !triedClearing ) |
|
||||||
{ |
|
||||||
triedClearing = true; |
|
||||||
|
|
||||||
// Didn't work, so get rid of it
|
|
||||||
DeleteObject( myRec.fFont ); |
|
||||||
|
|
||||||
// Clear all fonts and try again
|
|
||||||
Clear(); |
|
||||||
|
|
||||||
// Make sure we reload our custom fonts tho
|
|
||||||
ILoadCustomFonts(); |
|
||||||
|
|
||||||
// Try again
|
|
||||||
HFONT font = IMakeFont( face, height, weight, italic, quality ); |
|
||||||
|
|
||||||
triedClearing = false; |
|
||||||
|
|
||||||
return font; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
#endif |
|
||||||
|
|
||||||
fFontCache.Append( myRec ); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
plStatusLog::AddLineS( "pipeline.log", "ERROR: CreateFont() call FAILED (face: %s, size: %d %s %s)", |
|
||||||
face.c_str(), -height, weight == FW_BOLD ? "bold" : "", italic ? "italic" : "" ); |
|
||||||
} |
|
||||||
|
|
||||||
return myRec.fFont; |
|
||||||
} |
|
||||||
|
|
||||||
HFONT plWinFontCache::GetMeAFont( const plString &face, int height, int weight, bool italic, uint32_t quality ) |
|
||||||
{ |
|
||||||
HFONT font = IFindFont( face, height, weight, italic, quality ); |
|
||||||
if( font == nil ) |
|
||||||
font = IMakeFont( face, height, weight, italic, quality ); |
|
||||||
|
|
||||||
return font; |
|
||||||
} |
|
||||||
|
|
||||||
void plWinFontCache::Clear( void ) |
|
||||||
{ |
|
||||||
int i; |
|
||||||
|
|
||||||
|
|
||||||
if( !fInShutdown ) |
|
||||||
plStatusLog::AddLineS( "pipeline.log", "** Clearing Win32 font cache **" ); |
|
||||||
|
|
||||||
for( i = 0; i < fFontCache.GetCount(); i++ ) |
|
||||||
DeleteObject( fFontCache[ i ].fFont ); |
|
||||||
fFontCache.Reset(); |
|
||||||
|
|
||||||
fFontNameCache.Reset(); |
|
||||||
|
|
||||||
for( i = 0; i < fCustFonts.GetCount(); i++ ) |
|
||||||
{ |
|
||||||
#if (_WIN32_WINNT >= 0x0500) |
|
||||||
if (plDynSurfaceWriter::CanHandleLotsOfThem()) |
|
||||||
RemoveFontResourceExW(fCustFonts[i]->fFilename.AsString().ToWchar(), FR_PRIVATE, 0); |
|
||||||
else |
|
||||||
#endif |
|
||||||
if (RemoveFontResourceW(fCustFonts[i]->fFilename.AsString().ToWchar()) == 0) |
|
||||||
{ |
|
||||||
int q= 0; |
|
||||||
DWORD e = GetLastError(); |
|
||||||
} |
|
||||||
delete fCustFonts[ i ]; |
|
||||||
} |
|
||||||
fCustFonts.Reset(); |
|
||||||
} |
|
||||||
|
|
||||||
void plWinFontCache::FreeFont( HFONT font ) |
|
||||||
{ |
|
||||||
// Currently a no-op, but should do some sort of ref-counting
|
|
||||||
} |
|
||||||
|
|
||||||
void plWinFontCache::LoadCustomFonts( const char *dir ) |
|
||||||
{ |
|
||||||
delete [] fCustFontDir; |
|
||||||
fCustFontDir = ( dir != nil ) ? hsStrcpy( dir ) : nil; |
|
||||||
|
|
||||||
ILoadCustomFonts(); |
|
||||||
} |
|
||||||
|
|
||||||
void plWinFontCache::ILoadCustomFonts( void ) |
|
||||||
{ |
|
||||||
if( fCustFontDir == nil ) |
|
||||||
return; |
|
||||||
|
|
||||||
// Iterate through all the custom fonts in our dir
|
|
||||||
int numAdded; |
|
||||||
|
|
||||||
std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, kCustFontExtension); |
|
||||||
for (auto iter = fonts.begin(); iter != fonts.end(); ++iter) |
|
||||||
{ |
|
||||||
// Note that this call can be translated as "does my OS suck?"
|
|
||||||
#if (_WIN32_WINNT >= 0x0500) |
|
||||||
if( plDynSurfaceWriter::CanHandleLotsOfThem() ) |
|
||||||
numAdded = AddFontResourceExW(iter->AsString().ToWchar(), FR_PRIVATE, 0); |
|
||||||
else |
|
||||||
#endif |
|
||||||
numAdded = AddFontResourceW(iter->AsString().ToWchar()); |
|
||||||
|
|
||||||
if( numAdded > 0 ) |
|
||||||
{ |
|
||||||
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", iter->GetFileName().c_str(), numAdded ); |
|
||||||
fCustFonts.Append(new plCustFont(*iter)); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Unable to load custom font %s", iter->GetFileName().c_str() ); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#endif |
|
@ -1,130 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify |
|
||||||
it under the terms of the GNU General Public License as published by |
|
||||||
the Free Software Foundation, either version 3 of the License, or |
|
||||||
(at your option) any later version. |
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, |
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
GNU General Public License for more details. |
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License |
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// //
|
|
||||||
// plWinFontCache Class Header //
|
|
||||||
// I've stopped keeping track, there are far too many reasons already to //
|
|
||||||
// hate Microsoft. Anyway, this class keeps track of various Win32 fonts we //
|
|
||||||
// allocate because Win98/ME seems to have problems re-allocating the exact //
|
|
||||||
// same freaking goddamn font over and over again. I mean, you'd think //
|
|
||||||
// there'd be a rule somewhere about deterministic behavior when calling //
|
|
||||||
// the exact same function with the exact same parameters over and over... //
|
|
||||||
// Oh, wait... //
|
|
||||||
// //
|
|
||||||
// Cyan, Inc. //
|
|
||||||
// //
|
|
||||||
//// Version History //////////////////////////////////////////////////////////
|
|
||||||
// //
|
|
||||||
// 11.25.2002 mcn - Created. //
|
|
||||||
// //
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef _plWinFontCache_h |
|
||||||
#define _plWinFontCache_h |
|
||||||
|
|
||||||
|
|
||||||
#include "hsColorRGBA.h" |
|
||||||
#include "hsTemplates.h" |
|
||||||
#include "hsWindows.h" // FIXME: Windows header level include :( |
|
||||||
|
|
||||||
#if HS_BUILD_FOR_WIN32 |
|
||||||
|
|
||||||
|
|
||||||
//// Class Definition /////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class plWinFontCache |
|
||||||
{ |
|
||||||
protected:
|
|
||||||
|
|
||||||
class plFontRecord |
|
||||||
{ |
|
||||||
public: |
|
||||||
HFONT fFont; |
|
||||||
|
|
||||||
plString fFace; |
|
||||||
int fHeight; |
|
||||||
int fWeight; |
|
||||||
bool fItalic; |
|
||||||
uint32_t fQuality; |
|
||||||
}; |
|
||||||
|
|
||||||
class plCustFont |
|
||||||
{ |
|
||||||
public: |
|
||||||
plFileName fFilename; |
|
||||||
|
|
||||||
plCustFont(const plFileName &c) { fFilename = c; } |
|
||||||
}; |
|
||||||
|
|
||||||
bool fInShutdown; |
|
||||||
|
|
||||||
hsTArray<plFontRecord> fFontCache; |
|
||||||
hsTArray<plString> fFontNameCache; |
|
||||||
|
|
||||||
char *fCustFontDir; |
|
||||||
hsTArray<plCustFont *> fCustFonts; |
|
||||||
|
|
||||||
plWinFontCache(); |
|
||||||
|
|
||||||
HFONT IFindFont( const plString &face, int height, int weight, bool italic, uint32_t quality ); |
|
||||||
HFONT IMakeFont( const plString &face, int height, int weight, bool italic, uint32_t quality ); |
|
||||||
|
|
||||||
void ILoadCustomFonts( void ); |
|
||||||
|
|
||||||
public: |
|
||||||
|
|
||||||
virtual ~plWinFontCache(); |
|
||||||
static plWinFontCache &GetInstance( void ); |
|
||||||
|
|
||||||
HFONT GetMeAFont( const plString &face, int height, int weight, bool italic, uint32_t quality ); |
|
||||||
void FreeFont( HFONT font ); |
|
||||||
void Clear( void ); |
|
||||||
|
|
||||||
void LoadCustomFonts( const char *dir ); |
|
||||||
|
|
||||||
// Our custom font extension
|
|
||||||
static const char* kCustFontExtension; |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
#endif // HS_BUILD_FOR_WIN32
|
|
||||||
#endif // _plWinFontCache_h
|
|
Loading…
Reference in new issue