Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2004-01-23 17:19:44 +0300
committerDaniel Dunbar <daniel@zuster.org>2004-01-23 17:19:44 +0300
commitc427a1985478d72fe643435a1a4215f3b0c4268a (patch)
treee134a8ace1c40d78785f65b8a52248cfe0c691e4 /source/blender/ftfont
parent5d8c7e453746e0114caddb5a5cb11cdac6f5ed3b (diff)
- FTF_TTFont didn't initialize fontm,fontl,fonts to NULL, leads to
possible bad free - FTF_Api.cpp used static C++ object, hard to understand and icky, was probably source of phase4's crashes, replaced with dynamically allocated object and added FTF_End to free it and sensible time.
Diffstat (limited to 'source/blender/ftfont')
-rw-r--r--source/blender/ftfont/FTF_Api.h2
-rw-r--r--source/blender/ftfont/intern/FTF_Api.cpp37
-rw-r--r--source/blender/ftfont/intern/FTF_TTFont.cpp1
3 files changed, 27 insertions, 13 deletions
diff --git a/source/blender/ftfont/FTF_Api.h b/source/blender/ftfont/FTF_Api.h
index 5c6b441df0c..dd8b48a242a 100644
--- a/source/blender/ftfont/FTF_Api.h
+++ b/source/blender/ftfont/FTF_Api.h
@@ -148,6 +148,8 @@ FTF_EXPORT void FTF_SetLanguage(char* str);
*/
FTF_EXPORT void FTF_SetEncoding(char* str);
+FTF_EXPORT void FTF_End(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/ftfont/intern/FTF_Api.cpp b/source/blender/ftfont/intern/FTF_Api.cpp
index cf9171d6ba5..40d904b253f 100644
--- a/source/blender/ftfont/intern/FTF_Api.cpp
+++ b/source/blender/ftfont/intern/FTF_Api.cpp
@@ -45,34 +45,45 @@
#define FTF_EXPORT
-static FTF_TTFont ttfont;
+static FTF_TTFont *_FTF_GetFont(void) {
+ static FTF_TTFont *theFont = NULL;
+
+ if (!theFont) {
+ theFont = new FTF_TTFont();
+ }
+
+ return theFont;
+}
+FTF_EXPORT void FTF_End(void) {
+ delete _FTF_GetFont();
+}
FTF_EXPORT void FTF_SetSize(int size)
{
- ttfont.SetSize(size);
+ _FTF_GetFont()->SetSize(size);
}
FTF_EXPORT int FTF_GetSize(void)
{
- return ttfont.GetSize();
+ return _FTF_GetFont()->GetSize();
}
FTF_EXPORT int FTF_Ascender(void)
{
- return ttfont.Ascender();
+ return _FTF_GetFont()->Ascender();
}
FTF_EXPORT int FTF_Descender(void)
{
- return ttfont.Descender();
+ return _FTF_GetFont()->Descender();
}
FTF_EXPORT void FTF_TransConvString(char* str, char* ustr, unsigned int flag)
{
- ttfont.TransConvString(str, ustr, flag);
+ _FTF_GetFont()->TransConvString(str, ustr, flag);
}
/*
@@ -87,7 +98,7 @@ FTF_EXPORT float FTF_DrawCharacter(char c, unsigned int flag)
/* does color too, using glGet */
FTF_EXPORT float FTF_DrawString(char* str, unsigned int flag)
{
- return ttfont.DrawString(str, flag);
+ return _FTF_GetFont()->DrawString(str, flag);
}
@@ -106,7 +117,7 @@ FTF_EXPORT float FTF_GetCharacterWidth(char c, unsigned int flag)
*/
FTF_EXPORT float FTF_GetStringWidth(char* str, unsigned int flag)
{
- return ttfont.GetStringWidth(str, flag);
+ return _FTF_GetFont()->GetStringWidth(str, flag);
}
@@ -116,7 +127,7 @@ FTF_EXPORT float FTF_GetStringWidth(char* str, unsigned int flag)
*/
FTF_EXPORT void FTF_GetBoundingBox(char* str, float *llx, float *lly, float *llz, float *urx, float *ury, float *urz, unsigned int flag)
{
- ttfont.GetBoundingBox(str, llx, lly, llz, urx, ury, urz, flag);
+ _FTF_GetFont()->GetBoundingBox(str, llx, lly, llz, urx, ury, urz, flag);
}
/**
@@ -125,14 +136,14 @@ FTF_EXPORT void FTF_GetBoundingBox(char* str, float *llx, float *lly, float *llz
*/
FTF_EXPORT int FTF_SetFont(char* str, int size)
{
- return ttfont.SetFont(str, size);
+ return _FTF_GetFont()->SetFont(str, size);
}
/* added bt ton */
FTF_EXPORT void FTF_SetFontSize(char size)
{
- ttfont.SetFontSize( size);
+ _FTF_GetFont()->SetFontSize( size);
}
/**
@@ -141,7 +152,7 @@ FTF_EXPORT void FTF_SetFontSize(char size)
*/
FTF_EXPORT void FTF_SetLanguage(char* str)
{
- ttfont.SetLanguage(str);
+ _FTF_GetFont()->SetLanguage(str);
}
/**
@@ -150,5 +161,5 @@ FTF_EXPORT void FTF_SetLanguage(char* str)
*/
FTF_EXPORT void FTF_SetEncoding(char* str)
{
- ttfont.SetEncoding(str);
+ _FTF_GetFont()->SetEncoding(str);
}
diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp
index ea743139c76..f9fed8d2ea1 100644
--- a/source/blender/ftfont/intern/FTF_TTFont.cpp
+++ b/source/blender/ftfont/intern/FTF_TTFont.cpp
@@ -100,6 +100,7 @@ FTF_TTFont::FTF_TTFont(void)
#endif
font=NULL;
+ fontm= fonts= fontl= NULL;
font_size=FONT_SIZE_DEFAULT;
strcpy(encoding_name, SYSTEM_ENCODING_DEFAULT);