WINTERMUTE: Disable fonts, and remove FreeType2.

This commit is contained in:
Einar Johan Trøan Sømåen 2012-05-11 01:49:37 +02:00 committed by Einar Johan Trøan Sømåen
parent 7339ca988f
commit 6acc470bc6
6 changed files with 34 additions and 26 deletions

View File

@ -43,7 +43,7 @@ IMPLEMENT_PERSISTENT(CBFontStorage, true)
//////////////////////////////////////////////////////////////////////////
CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) {
_fTLibrary = NULL;
// _fTLibrary = NULL;
InitFreeType();
}
@ -56,10 +56,12 @@ CBFontStorage::~CBFontStorage() {
//////////////////////////////////////////////////////////////////////////
void CBFontStorage::InitFreeType() {
#if 0
FT_Error error = FT_Init_FreeType(&_fTLibrary);
if (error) {
Game->LOG(0, "Error initializing FreeType library.");
}
#endif
}
//////////////////////////////////////////////////////////////////////////
@ -72,9 +74,9 @@ HRESULT CBFontStorage::Cleanup(bool Warn) {
}
_fonts.RemoveAll();
#if 0
if (_fTLibrary) FT_Done_FreeType(_fTLibrary);
#endif
return S_OK;
}

View File

@ -34,8 +34,8 @@
#include "persistent.h"
#include "coll_templ.h"
#include <ft2build.h>
#include FT_FREETYPE_H
/*#include <ft2build.h>
#include FT_FREETYPE_H*/
namespace WinterMute {
@ -52,13 +52,13 @@ public:
CBArray<CBFont *, CBFont *> _fonts;
HRESULT InitLoop();
FT_Library GetFTLibrary() const {
/* FT_Library GetFTLibrary() const {
return _fTLibrary;
}
}*/
private:
void InitFreeType();
FT_Library _fTLibrary;
//FT_Library _fTLibrary;
};
} // end of namespace WinterMute

View File

@ -26,8 +26,8 @@
* Copyright (c) 2011 Jan Nedoma
*/
#include <ft2build.h>
#include FT_FREETYPE_H
//#include <ft2build.h>
//#include FT_FREETYPE_H
#include "dcgf.h"
#include "BFile.h"
#include "BFontTT.h"
@ -56,10 +56,10 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) {
for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL;
#if 0
_fTFace = NULL;
_fTStream = NULL;
#endif
_glyphCache = NULL;
_ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0;
@ -81,14 +81,14 @@ CBFontTT::~CBFontTT(void) {
delete _glyphCache;
_glyphCache = NULL;
#if 0
if (_fTFace) {
FT_Done_Face(_fTFace);
_fTFace = NULL;
}
delete[] _fTStream;
_fTStream = NULL;
#endif
}
@ -596,7 +596,8 @@ void CBFontTT::AfterLoad() {
//////////////////////////////////////////////////////////////////////////
HRESULT CBFontTT::InitFont() {
if (!_fontFile) return E_FAIL;
warning("BFontTT::InitFont - Not ported yet");
return E_FAIL;
CBFile *file = Game->_fileManager->OpenFile(_fontFile);
if (!file) {
// the requested font file is not in wme file space; try loading a system font
@ -608,7 +609,7 @@ HRESULT CBFontTT::InitFont() {
return E_FAIL;
}
}
#if 0
FT_Error error;
float vertDpi = 96.0;
@ -665,7 +666,7 @@ HRESULT CBFontTT::InitFont() {
_glyphCache = new FontGlyphCache();
_glyphCache->Initialize();
#endif
return S_OK;
}
@ -673,6 +674,7 @@ HRESULT CBFontTT::InitFont() {
//////////////////////////////////////////////////////////////////////////
// I/O bridge between FreeType and WME file system
//////////////////////////////////////////////////////////////////////////
/*
unsigned long CBFontTT::FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) {
CBFile *f = static_cast<CBFile *>(stream->descriptor.pointer);
if (!f) return 0;
@ -694,7 +696,7 @@ void CBFontTT::FTCloseProc(FT_Stream stream) {
Game->_fileManager->CloseFile(f);
stream->descriptor.pointer = NULL;
}
}*/
@ -800,7 +802,7 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight,
float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) {
GlyphInfo *infoLeft = _glyphCache->GetGlyph(leftChar);
GlyphInfo *infoRight = _glyphCache->GetGlyph(rightChar);
#if 0
if (!infoLeft || !infoRight) return 0;
FT_Vector delta;
@ -808,6 +810,8 @@ float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) {
if (error) return 0;
return delta.x * (1.0f / 64.0f);
#endif
return 0;
}
@ -822,6 +826,7 @@ void CBFontTT::PrepareGlyphs(const WideString &text) {
//////////////////////////////////////////////////////////////////////////
void CBFontTT::CacheGlyph(wchar_t ch) {
#if 0
FT_UInt glyphIndex = FT_Get_Char_Index(_fTFace, ch);
if (!glyphIndex) return;
@ -857,6 +862,7 @@ void CBFontTT::CacheGlyph(wchar_t ch) {
_glyphCache->AddGlyph(ch, glyphIndex, _fTFace->glyph, _fTFace->glyph->bitmap.width, _fTFace->glyph->bitmap.rows, pixels, stride);
if (tempBuffer) delete [] tempBuffer;
#endif
}
} // end of namespace WinterMute

View File

@ -127,8 +127,8 @@ public:
HRESULT LoadBuffer(byte *Buffer);
HRESULT LoadFile(char *Filename);
static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count);
static void FTCloseProc(FT_Stream stream);
/* static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count);
static void FTCloseProc(FT_Stream stream);*/
FontGlyphCache *GetGlyphCache() {
return _glyphCache;
@ -157,8 +157,8 @@ private:
CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS];
HRESULT InitFont();
FT_Stream _fTStream;
FT_Face _fTFace;
//FT_Stream _fTStream;
//FT_Face _fTFace;
FontGlyphCache *_glyphCache;

View File

@ -58,7 +58,7 @@ GlyphInfo *FontGlyphCache::GetGlyph(wchar_t ch) {
return it->_value;
}
/*
//////////////////////////////////////////////////////////////////////////
void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride) {
if (stride == 0) stride = width;
@ -67,7 +67,7 @@ void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot
_glyphs[ch]->SetGlyphInfo(glyphSlot->advance.x / 64.f, glyphSlot->advance.y / 64.f, glyphSlot->bitmap_left, glyphSlot->bitmap_top);
_glyphs[ch]->SetGlyphImage(width, height, stride, pixels);
}
*/
//////////////////////////////////////////////////////////////////////////
void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels) {

View File

@ -109,7 +109,7 @@ public:
void Initialize();
bool HasGlyph(wchar_t ch);
GlyphInfo *GetGlyph(wchar_t ch);
void AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride = 0);
//void AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride = 0);
private:
//typedef Common::HashMap<wchar_t, GlyphInfo *> GlyphInfoMap;