Browse Source

osx : use freetype instead of deprecated carbon api

pull/71/head
hymei 3 years ago committed by nillerusr
parent
commit
df78eef85f
  1. 6
      common/vgui_surfacelib/FontManager.h
  2. 5
      common/vgui_surfacelib/vguifont.h
  3. 8
      vgui2/vgui_surfacelib/FontManager.cpp

6
common/vgui_surfacelib/FontManager.h

@ -17,7 +17,7 @@
#include "filesystem.h" #include "filesystem.h"
#include "vguifont.h" #include "vguifont.h"
#ifdef LINUX #if defined(LINUX) || defined(OSX)
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
typedef void *(*FontDataHelper)( const char *pchFontName, int &size, const char *fontFileName ); typedef void *(*FontDataHelper)( const char *pchFontName, int &size, const char *fontFileName );
@ -71,7 +71,7 @@ public:
IFileSystem *FileSystem() { return m_pFileSystem; } IFileSystem *FileSystem() { return m_pFileSystem; }
IMaterialSystem *MaterialSystem() { return m_pMaterialSystem; } IMaterialSystem *MaterialSystem() { return m_pMaterialSystem; }
#ifdef LINUX #if defined(LINUX) || defined(OSX)
FT_Library GetFontLibraryHandle() { return library; } FT_Library GetFontLibraryHandle() { return library; }
void SetFontDataHelper( FontDataHelper helper ) { m_pFontDataHelper = helper; } void SetFontDataHelper( FontDataHelper helper ) { m_pFontDataHelper = helper; }
#endif #endif
@ -96,7 +96,7 @@ private:
CUtlVector<CFontAmalgam> m_FontAmalgams; CUtlVector<CFontAmalgam> m_FontAmalgams;
CUtlVector<font_t *> m_Win32Fonts; CUtlVector<font_t *> m_Win32Fonts;
#ifdef LINUX #if defined(LINUX) || defined(OSX)
FT_Library library; FT_Library library;
FontDataHelper m_pFontDataHelper; FontDataHelper m_pFontDataHelper;
#endif #endif

5
common/vgui_surfacelib/vguifont.h

@ -23,10 +23,7 @@ struct newChar_t
#ifdef WIN32 #ifdef WIN32
#include "Win32Font.h" #include "Win32Font.h"
typedef CWin32Font font_t; typedef CWin32Font font_t;
#elif defined(OSX) #elif defined(LINUX) || defined(OSX)
#include "osxfont.h"
typedef COSXFont font_t;
#elif defined(LINUX)
#include "linuxfont.h" #include "linuxfont.h"
typedef CLinuxFont font_t; typedef CLinuxFont font_t;
#else #else

8
vgui2/vgui_surfacelib/FontManager.cpp

@ -43,7 +43,7 @@ CFontManager::CFontManager()
m_FontAmalgams.AddToTail(); m_FontAmalgams.AddToTail();
m_Win32Fonts.EnsureCapacity( MAX_INITIAL_FONTS ); m_Win32Fonts.EnsureCapacity( MAX_INITIAL_FONTS );
#ifdef LINUX #if defined(LINUX) || defined(OSX)
FT_Error error = FT_Init_FreeType( &library ); FT_Error error = FT_Init_FreeType( &library );
if ( error ) if ( error )
Error( "Unable to initalize freetype library, is it installed?" ); Error( "Unable to initalize freetype library, is it installed?" );
@ -75,7 +75,7 @@ CFontManager::~CFontManager()
{ {
ClearAllFonts(); ClearAllFonts();
m_FontAmalgams.RemoveAll(); m_FontAmalgams.RemoveAll();
#ifdef LINUX #if defined(LINUX) || defined(OSX)
FT_Done_FreeType( library ); FT_Done_FreeType( library );
#endif #endif
} }
@ -280,7 +280,7 @@ font_t *CFontManager::CreateOrFindWin32Font(const char *windowsFontName, int tal
i = m_Win32Fonts.AddToTail(); i = m_Win32Fonts.AddToTail();
m_Win32Fonts[i] = NULL; m_Win32Fonts[i] = NULL;
#ifdef LINUX #if defined(LINUX) || defined(OSX)
int memSize = 0; int memSize = 0;
void *pchFontData = m_pFontDataHelper( windowsFontName, memSize, NULL ); void *pchFontData = m_pFontDataHelper( windowsFontName, memSize, NULL );
@ -750,7 +750,7 @@ void CFontManager::GetKernedCharWidth( vgui::HFont font, wchar_t ch, wchar_t chB
if ( m_FontAmalgams[font].GetFontForChar( chAfter ) != pFont ) if ( m_FontAmalgams[font].GetFontForChar( chAfter ) != pFont )
chAfter = 0; chAfter = 0;
#if defined(LINUX) #if defined(LINUX) || defined(OSX)
pFont->GetKernedCharWidth( ch, chBefore, chAfter, wide, flabcA, flabcC ); pFont->GetKernedCharWidth( ch, chBefore, chAfter, wide, flabcA, flabcC );
#else #else
pFont->GetKernedCharWidth( ch, chBefore, chAfter, wide, flabcA ); pFont->GetKernedCharWidth( ch, chBefore, chAfter, wide, flabcA );

Loading…
Cancel
Save