truetype: fix truetype font key map
Change-Id: I09dc6798c219ae9d3f1a3745947b28e19fd0f527
diff --git a/minuitwrp/truetype.cpp b/minuitwrp/truetype.cpp
index de92715..8695432 100755
--- a/minuitwrp/truetype.cpp
+++ b/minuitwrp/truetype.cpp
@@ -77,13 +77,14 @@
int error;
TrueTypeFont* res = nullptr;
TrueTypeFontKey* key;
+ std::string fontFileName(filename);
pthread_mutex_lock(&font_data.mutex);
TrueTypeFontKey k = {
.size = size,
.dpi = dpi,
- .path = (char*)filename
+ .path = fontFileName
};
TrueTypeFontMap::iterator ttfIter = font_data.fonts.find(k);
@@ -154,7 +155,7 @@
int new_size = ((int)((float)f->size * scale_value)) - 1;
if (new_size < 1)
new_size = 1;
- const char* file = f->key->path;
+ const char* file = f->key->path.c_str();
int dpi = f->dpi;
return gr_ttf_loadFont(file, new_size, dpi);
}
@@ -182,7 +183,6 @@
TrueTypeFont *d = (TrueTypeFont *)font;
if(--d->refcount == 0)
{
- delete d->key->path;
delete d->key;
FT_Done_Face(d->face);
diff --git a/minuitwrp/truetype.hpp b/minuitwrp/truetype.hpp
index 3ae2090..72b7620 100755
--- a/minuitwrp/truetype.hpp
+++ b/minuitwrp/truetype.hpp
@@ -29,11 +29,11 @@
typedef struct TrueTypeFontKey {
int size;
int dpi;
- char *path;
+ std::string path;
} TrueTypeFontKey;
inline bool operator<(const TrueTypeFontKey &ttfkLeft, const TrueTypeFontKey &ttfkRight) {
- return std::tie(ttfkLeft.size, ttfkLeft.dpi, *ttfkLeft.path) < std::tie(ttfkRight.size, ttfkRight.dpi, *ttfkRight.path);
+ return std::tie(ttfkLeft.size, ttfkLeft.dpi, ttfkLeft.path) < std::tie(ttfkRight.size, ttfkRight.dpi, ttfkRight.path);
}
typedef struct {