https://bugs.documentfoundation.org/show_bug.cgi?id=159529

--- Comment #18 from Patrick Luby <[email protected]> ---
(In reply to Patrick Luby from comment #17)
> Next step is to look in the HarfBuzz portion of the stack and see if there
> is any caching of font table data. hb_face_reference_table() looks like a
> good place to start.

Bad news. It appears to me that the copied font table data is cached by
hb_face_t instances. Don't yet know exactly how we can remove the data after it
is cached.

The font tables that use a massive amount of memory is the 'sbix' font table. I
assume the 'sbix' font table holds all of the bitmaps for emoji fonts.

I see the following memory usage for the 'glyf' and 'sbix' font tables for all
fonts loaded by the FontNameBox. The 'sbix' tables are more than 70% of the
total for all font tables:

Total font tables: 260887001
 glyf font tables: 64345349
 sbix font tables: 189145592

Note: I used the following debug patch to get the above data:

diff --git a/vcl/quartz/CoreTextFont.cxx b/vcl/quartz/CoreTextFont.cxx
index 6248a255c64e..8a29ae846f45 100644
--- a/vcl/quartz/CoreTextFont.cxx
+++ b/vcl/quartz/CoreTextFont.cxx
@@ -216,6 +216,24 @@ hb_blob_t* CoreTextFontFace::GetHbTable(hb_tag_t nTag)
const
         const CFIndex nLength = pData ? CFDataGetLength(pData) : 0;
         if (nLength > 0)
         {
+            static uint32 nAllLength = 0;
+            static uint32 nGlyfLength = 0;
+            static uint32 nSbixLength = 0;
+
+            char aCode[5];
+            uint32_t nSwappedTag = CFSwapInt32(nTag);
+            memcpy(aCode, &nSwappedTag, 4);
+            aCode[4] = '\0';
+
+            nAllLength += nLength;
+            if (!strncmp("glyf", aCode, 4))
+                nGlyfLength += nLength;
+            else if (!strncmp("sbix", aCode, 4))
+                nSbixLength += nLength;
+            fprintf(stderr, "Total font tables: %u\n", nAllLength);
+            fprintf(stderr, " glyf font tables: %u\n", nGlyfLength);
+            fprintf(stderr, " sbix font tables: %u\n", nSbixLength);
+
             auto pBuffer = new UInt8[nLength];
             const CFRange aRange = CFRangeMake(0, nLength);
             CFDataGetBytes(pData, aRange, pBuffer);

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to