summaryrefslogtreecommitdiff
path: root/indra/llrender/llfontfreetype.cpp
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2018-01-09 20:31:21 +0200
committerandreykproductengine <andreykproductengine@lindenlab.com>2018-01-09 20:31:21 +0200
commitfadb3792caa5279d3521dcaad44a6211bfa4bfad (patch)
tree9dbf5af531e6ad3f3e5b4339cf14bf25f77cdafd /indra/llrender/llfontfreetype.cpp
parent0af4e93e7611485b33aec27bd49749c0226dbf29 (diff)
MAINT-8146 Fixed Installing viewer to non default path results in incorrect fonts loading
Diffstat (limited to 'indra/llrender/llfontfreetype.cpp')
-rw-r--r--indra/llrender/llfontfreetype.cpp64
1 files changed, 62 insertions, 2 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp
index de26d19efc..5c1f4ff8b3 100644
--- a/indra/llrender/llfontfreetype.cpp
+++ b/indra/llrender/llfontfreetype.cpp
@@ -106,6 +106,8 @@ LLFontFreetype::LLFontFreetype()
mAscender(0.f),
mDescender(0.f),
mLineHeight(0.f),
+ pFontBuffer(NULL),
+ mBufferSize(0),
mIsFallback(FALSE),
mFTFace(NULL),
mRenderGlyphCount(0),
@@ -128,6 +130,8 @@ LLFontFreetype::~LLFontFreetype()
mCharGlyphInfoMap.clear();
delete mFontBitmapCachep;
+ delete pFontBuffer;
+ disclaimMem(mBufferSize);
// mFallbackFonts cleaned up by LLPointer destructor
}
@@ -143,13 +147,64 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v
int error;
+#ifdef LL_WINDOWS
+
+ if (mBufferSize > 0)
+ {
+ delete pFontBuffer;
+ disclaimMem(mBufferSize);
+ pFontBuffer = NULL;
+ mBufferSize = 0;
+ }
+
+ S32 file_size = 0;
+ LLFILE* file = LLFile::fopen(filename, "rb");
+ if (!file)
+ {
+ return FALSE;
+ }
+
+ if (!fseek(file, 0, SEEK_END))
+ {
+ file_size = ftell(file);
+ fseek(file, 0, SEEK_SET);
+ }
+
+ // Don't delete before FT_Done_Face
+ pFontBuffer = new(std::nothrow) U8[file_size];
+ if (!pFontBuffer)
+ {
+ fclose(file);
+ return FALSE;
+ }
+
+ mBufferSize = fread(pFontBuffer, 1, file_size, file);
+ fclose(file);
+
+ if (mBufferSize != file_size)
+ {
+ delete pFontBuffer;
+ mBufferSize = 0;
+ return FALSE;
+ }
+
+ error = FT_New_Memory_Face( gFTLibrary,
+ (FT_Byte*) pFontBuffer,
+ mBufferSize,
+ 0,
+ &mFTFace);
+#else
error = FT_New_Face( gFTLibrary,
filename.c_str(),
0,
- &mFTFace );
+ &mFTFace);
+#endif
- if (error)
+ if (error)
{
+ delete pFontBuffer;
+ pFontBuffer = NULL;
+ mBufferSize = 0;
return FALSE;
}
@@ -166,10 +221,15 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v
{
// Clean up freetype libs.
FT_Done_Face(mFTFace);
+ delete pFontBuffer;
+ pFontBuffer = NULL;
+ mBufferSize = 0;
mFTFace = NULL;
return FALSE;
}
+ claimMem(mBufferSize);
+
F32 y_max, y_min, x_max, x_min;
F32 ems_per_unit = 1.f/ mFTFace->units_per_EM;
F32 pixels_per_unit = pixels_per_em * ems_per_unit;