]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - ft2.c
Use `%p` for `mapstart` pointer in `dpsnprintf`,
[xonotic/darkplaces.git] / ft2.c
diff --git a/ft2.c b/ft2.c
index db3021c0e3a327c9a78a2c620d60e83f2a8525ad..392ca0f1fa8b8da102bbb11a71c1594c0a2b1e77 100644 (file)
--- a/ft2.c
+++ b/ft2.c
@@ -1365,7 +1365,7 @@ static inline void incmap_post_process(font_incmap_t *incmap, Uchar ch,
                {
                        chunk = incmap->data_tier2[i];
                        if (chunk == NULL) break;
-                       newdata = (unsigned char *)Mem_Alloc(font_mempool, datasize);
+                       newdata = (unsigned char *)Mem_Alloc(font_mempool, datasize * M);
                        if (bytes_per_pixel == 1)
                                rgba_to_alpha(chunk, newdata, olddata_size);
                        else if (bytes_per_pixel == 4)
@@ -1602,8 +1602,16 @@ static qbool Font_LoadMap(ft2_font_t *font, ft2_font_map_t *mapstart, Uchar _ch,
                // add pointer as a unique part to avoid earlier incmaps' state being trashed
                use_incmap ? (unsigned long)mapstart : 0x0);
        */
-       dpsnprintf(map_identifier, sizeof(map_identifier), "%s_%g_%lx_%u",
-                       font->name, mapstart->intSize, (unsigned long) mapstart, (unsigned) map_startglyph);
+       /*
+        * note 1: it appears that different font instances may have the same metrics, causing this pic being overwritten
+        *         will use startmap's pointer as a unique part to avoid earlier incmaps' dynamic pics being trashed
+        * note 2: if this identifier is made too long, significient performance drop will take place
+        * note 3: blur/outline/shadow are per-font settings, so a pointer to startmap & map size
+        *         already made these unique, hence they are omitted
+        * note 4: font_diskcache is removed, this name can be less meaningful
+        */
+       dpsnprintf(map_identifier, sizeof(map_identifier), "%s_%g_%p_%u",
+                       font->name, mapstart->intSize, mapstart, (unsigned) map_startglyph);
 
        // create a cachepic_t from the data now, or reuse an existing one
        if (developer_font.integer)