truetype: fix truetype font key map

Change-Id: I09dc6798c219ae9d3f1a3745947b28e19fd0f527
This commit is contained in:
bigbiff
2020-09-12 14:25:32 -04:00
parent 8da46fa939
commit fdca6b8a5a
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -77,13 +77,14 @@ void* twrpTruetype::gr_ttf_loadFont(const char *filename, int size, int dpi) {
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 @@ void* twrpTruetype::gr_ttf_scaleFont(void *font, int max_width, int measured_wid
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 @@ void twrpTruetype::gr_ttf_freeFont(void *font) {
TrueTypeFont *d = (TrueTypeFont *)font;
if(--d->refcount == 0)
{
delete d->key->path;
delete d->key;
FT_Done_Face(d->face);
+2 -2
View File
@@ -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 {