summaryrefslogtreecommitdiff
path: root/chromium-125-debian-bad-font-gc2.patch
blob: b718479331bab3f374945a807e86fd91bab82329 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
Chromium 123 was buggy, with tabs regularly hanging/crashing. The culprit
was the GC cleaning up font cache stuff, and deadlocking in a FontCacheKey
destructor:

Thread 54 (Thread 0x7fffc55fe6c0 (LWP 413811) "Chrome_InProcRe"):
#0  0x00007ffff6720719 in syscall () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000055555c1752d9 in partition_alloc::internal::SpinningMutex::LockSlow() ()
#2  0x000055555c185529 in allocator_shim::internal::PartitionFree(allocator_shim::AllocatorDispatch const*, void*, void*) ()
#3  0x000055555f7db46b in blink::FontCacheKey::~FontCacheKey() ()
#4  0x000055555f7db6f4 in WTF::WeakProcessingHashTableHelper<(WTF::WeakHandlingFlag)1, blink::FontCacheKey, WTF::KeyValuePair<blink::FontCacheKey, cppgc::internal::BasicMember<blink::SegmentedFontData const, cppgc::internal::WeakMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer> >, WTF::KeyValuePairExtractor, WTF::HashMapValueTraits<WTF::HashTraits<blink::FontCacheKey>, WTF::HashTraits<cppgc::internal::BasicMember<blink::SegmentedFontData const, cppgc::internal::WeakMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer> > >, WTF::HashTraits<blink::FontCacheKey>, blink::HeapAllocator>::Process(cppgc::LivenessBroker const&, void const*) ()
#5  0x0000555559544bef in cppgc::internal::MarkerBase::ProcessWeakness() ()
#6  0x000055555954487e in cppgc::internal::MarkerBase::LeaveAtomicPause() ()
#7  0x0000555558e8115a in v8::internal::CppHeap::FinishMarkingAndStartSweeping() ()
#8  0x0000555558ebcdc0 in v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) ()
#9  0x0000555558ecfe14 in v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_0::operator()() const ()
#10 0x0000555558ecfb65 in void heap::base::Stack::SetMarkerAndCallbackImpl<v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_0>(heap::base::Stack*, void*, void const*) ()
--Type <RET> for more, q to quit, c to continue without paging--
#11 0x000055555955216b in PushAllRegistersAndIterateStack ()
#12 0x0000555558eb8c19 in v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) ()
#13 0x0000555558eba3eb in v8::internal::Heap::FinalizeIncrementalMarkingAtomically(v8::internal::GarbageCollectionReason) ()
#14 0x0000555558ed20db in v8::internal::IncrementalMarkingJob::Task::RunInternal() ()
#15 0x000055555c0c49d6 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ()
#16 0x000055555c0daf88 in base::sequence_manager::internal::ThreadControllerImpl::DoWork(base::sequence_manager::internal::ThreadControllerImpl::WorkType) ()
#17 0x000055555c0c49d6 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ()
#18 0x000055555c0dd8f9 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) ()
#19 0x000055555c0dd3bf in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ()
#20 0x000055555c0ddd75 in non-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ()
#21 0x000055555c07eb4f in base::MessagePumpDefault::Run(base::MessagePump::Delegate*) ()
#22 0x000055555c0de110 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) ()
#23 0x000055555c0a4c26 in base::RunLoop::Run(base::Location const&) ()
#24 0x000055555c100155 in base::Thread::Run(base::RunLoop*) ()
#25 0x000055555c100342 in base::Thread::ThreadMain() ()


The commit below modified font stuff to go from using scoped_refptrs to
getting cleaned up via GC. Reverting it fixes chromium's behavior for us.
It would be good to get a proper fix for this, but reverting this will
have to do for now.


commit bff9ec6754f7bf97c61d84663ee2ccc5055e9eb3
Author: Ian Kilpatrick <ikilpatrick@chromium.org>
Date:   Tue Feb 13 19:15:19 2024 +0000

    [gc] Make SimpleFontData & FontPlatformData & friends gc'd.
    
    The largest change is making the associated caches for these objects
    weak collections instead of relying on the relatively complex purging
    logic.
    
    https://variable-lizards.glitch.me/ appears not to leak.
    
    There should be no user-visible behaviour change.
    
    Bug: 41490008
    Change-Id: Iba581842459cf31f7f4fe60d83665f393a7d06a3
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5262982
    Reviewed-by: Caleb Raitto <caraitto@chromium.org>
    Reviewed-by: Dominik Röttsches <drott@chromium.org>
    Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1259965}

--- a/third_party/blink/renderer/core/css/binary_data_font_face_source.cc
+++ b/third_party/blink/renderer/core/css/binary_data_font_face_source.cc
@@ -36,10 +36,10 @@ bool BinaryDataFontFaceSource::IsValid()
   return custom_platform_data_.get();
 }
 
-SimpleFontData* BinaryDataFontFaceSource::CreateFontData(
+scoped_refptr<SimpleFontData> BinaryDataFontFaceSource::CreateFontData(
     const FontDescription& font_description,
     const FontSelectionCapabilities& font_selection_capabilities) {
-  return MakeGarbageCollected<SimpleFontData>(
+  return SimpleFontData::Create(
       custom_platform_data_->GetFontPlatformData(
           font_description.EffectiveFontSize(),
           font_description.AdjustedSpecifiedSize(),
@@ -56,7 +56,7 @@ SimpleFontData* BinaryDataFontFaceSource
               : ResolvedFontFeatures(),
           font_description.Orientation(), font_description.VariationSettings(),
           font_description.GetFontPalette()),
-      MakeGarbageCollected<CustomFontData>());
+      CustomFontData::Create());
 }
 
 }  // namespace blink
--- a/third_party/blink/renderer/core/css/binary_data_font_face_source.h
+++ b/third_party/blink/renderer/core/css/binary_data_font_face_source.h
@@ -20,8 +20,9 @@ class BinaryDataFontFaceSource final : p
   bool IsValid() const override;
 
  private:
-  SimpleFontData* CreateFontData(const FontDescription&,
-                                 const FontSelectionCapabilities&) override;
+  scoped_refptr<SimpleFontData> CreateFontData(
+      const FontDescription&,
+      const FontSelectionCapabilities&) override;
 
   scoped_refptr<FontCustomPlatformData> custom_platform_data_;
 };
--- a/third_party/blink/renderer/core/css/css_custom_font_data.h
+++ b/third_party/blink/renderer/core/css/css_custom_font_data.h
@@ -31,18 +31,13 @@ class CSSCustomFontData final : public C
  public:
   enum FallbackVisibility { kInvisibleFallback, kVisibleFallback };
 
-  CSSCustomFontData(CSSFontFaceSource* source, FallbackVisibility visibility)
-      : font_face_source_(source), fallback_visibility_(visibility) {
-    if (source) {
-      is_loading_ = source->IsLoading();
-    }
+  static scoped_refptr<CSSCustomFontData> Create(
+      CSSFontFaceSource* source,
+      FallbackVisibility visibility) {
+    return base::AdoptRef(new CSSCustomFontData(source, visibility));
   }
-  ~CSSCustomFontData() override = default;
 
-  void Trace(Visitor* visitor) const override {
-    visitor->Trace(font_face_source_);
-    CustomFontData::Trace(visitor);
-  }
+  ~CSSCustomFontData() override = default;
 
   bool ShouldSkipDrawing() const override {
     if (font_face_source_) {
@@ -66,7 +61,16 @@ class CSSCustomFontData final : public C
   }
 
  private:
-  Member<CSSFontFaceSource> font_face_source_;
+  CSSCustomFontData(CSSFontFaceSource* source, FallbackVisibility visibility)
+      : font_face_source_(source), fallback_visibility_(visibility) {
+    if (source) {
+      is_loading_ = source->IsLoading();
+    }
+  }
+
+  // TODO(Oilpan): consider moving (Custom)FontFace hierarchy to the heap,
+  // thereby making this reference a Member<>.
+  WeakPersistent<CSSFontFaceSource> font_face_source_;
   FallbackVisibility fallback_visibility_;
   mutable bool is_loading_ = false;
 };
--- a/third_party/blink/renderer/core/css/css_font_face.cc
+++ b/third_party/blink/renderer/core/css/css_font_face.cc
@@ -114,7 +114,7 @@ bool CSSFontFace::FallbackVisibilityChan
   return true;
 }
 
-const SimpleFontData* CSSFontFace::GetFontData(
+scoped_refptr<SimpleFontData> CSSFontFace::GetFontData(
     const FontDescription& font_description) {
   if (!IsValid()) {
     return nullptr;
@@ -140,7 +140,7 @@ const SimpleFontData* CSSFontFace::GetFo
       return nullptr;
     }
 
-    if (const SimpleFontData* result =
+    if (scoped_refptr<SimpleFontData> result =
             source->GetFontData(size_adjusted_description,
                                 font_face_->GetFontSelectionCapabilities())) {
       // The font data here is created using the primary font's description.
@@ -149,7 +149,7 @@ const SimpleFontData* CSSFontFace::GetFo
       if (size_adjusted_description.HasSizeAdjust()) {
         if (auto adjusted_size =
                 FontSizeFunctions::MetricsMultiplierAdjustedFontSize(
-                    result, size_adjusted_description)) {
+                    result.get(), size_adjusted_description)) {
           size_adjusted_description.SetAdjustedSize(adjusted_size.value());
           result =
               source->GetFontData(size_adjusted_description,
--- a/third_party/blink/renderer/core/css/css_font_face.h
+++ b/third_party/blink/renderer/core/css/css_font_face.h
@@ -76,7 +76,7 @@ class CORE_EXPORT CSSFontFace final : pu
   bool FontLoaded(CSSFontFaceSource*);
   bool FallbackVisibilityChanged(RemoteFontFaceSource*);
 
-  const SimpleFontData* GetFontData(const FontDescription&);
+  scoped_refptr<SimpleFontData> GetFontData(const FontDescription&);
 
   FontFace::LoadStatusType LoadStatus() const {
     return font_face_->LoadStatus();
--- a/third_party/blink/renderer/core/css/css_font_face_source.cc
+++ b/third_party/blink/renderer/core/css/css_font_face_source.cc
@@ -31,11 +31,22 @@
 #include "third_party/blink/renderer/platform/fonts/font_face_creation_params.h"
 #include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
 
+namespace {
+// An excessive amount of SimpleFontData objects is generated from
+// CSSFontFaceSource if a lot of varying FontDescriptions point to a web
+// font. These FontDescriptions can vary in size, font-feature-settings or
+// font-variation settings. Well known cases are animations of font-variation
+// settings, compare crbug.com/778352. For a start, let's reduce this number to
+// 1024, which is still a large number and should have enough steps for font
+// animations from the same font face source, but avoids unbounded growth.
+const size_t kMaxCachedFontData = 1024;
+}  // namespace
+
 namespace blink {
 
 CSSFontFaceSource::~CSSFontFaceSource() = default;
 
-const SimpleFontData* CSSFontFaceSource::GetFontData(
+scoped_refptr<SimpleFontData> CSSFontFaceSource::GetFontData(
     const FontDescription& font_description,
     const FontSelectionCapabilities& font_selection_capabilities) {
   // If the font hasn't loaded or an error occurred, then we've got nothing.
@@ -53,12 +64,52 @@ const SimpleFontData* CSSFontFaceSource:
   FontCacheKey key =
       font_description.CacheKey(FontFaceCreationParams(), is_unique_match);
 
-  auto result = font_data_table_.insert(key, nullptr);
-  if (result.is_new_entry) {
-    result.stored_value->value =
-        CreateFontData(font_description, font_selection_capabilities);
+  // Get or create the font data. Take care to avoid dangling references into
+  // font_data_table_, because it is modified below during pruning.
+  scoped_refptr<SimpleFontData> font_data;
+  {
+    auto* it = font_data_table_.insert(key, nullptr).stored_value;
+    if (!it->value) {
+      it->value = CreateFontData(font_description, font_selection_capabilities);
+    }
+    font_data = it->value;
+  }
+
+  font_cache_key_age.PrependOrMoveToFirst(key);
+  PruneOldestIfNeeded();
+
+  DCHECK_LE(font_data_table_.size(), kMaxCachedFontData);
+  // No release, because fontData is a reference to a RefPtr that is held in the
+  // font_data_table_.
+  return font_data;
+}
+
+void CSSFontFaceSource::PruneOldestIfNeeded() {
+  if (font_cache_key_age.size() > kMaxCachedFontData) {
+    DCHECK_EQ(font_cache_key_age.size() - 1, kMaxCachedFontData);
+    const FontCacheKey& key = font_cache_key_age.back();
+    auto font_data_entry = font_data_table_.Take(key);
+    font_cache_key_age.pop_back();
+    DCHECK_EQ(font_cache_key_age.size(), kMaxCachedFontData);
+    if (font_data_entry && font_data_entry->GetCustomFontData()) {
+      font_data_entry->GetCustomFontData()->ClearFontFaceSource();
+    }
+  }
+}
+
+void CSSFontFaceSource::PruneTable() {
+  if (font_data_table_.empty()) {
+    return;
+  }
+
+  for (const auto& item : font_data_table_) {
+    SimpleFontData* font_data = item.value.get();
+    if (font_data && font_data->GetCustomFontData()) {
+      font_data->GetCustomFontData()->ClearFontFaceSource();
+    }
   }
-  return result.stored_value->value.Get();
+  font_cache_key_age.clear();
+  font_data_table_.clear();
 }
 
 }  // namespace blink
--- a/third_party/blink/renderer/core/css/css_font_face_source.h
+++ b/third_party/blink/renderer/core/css/css_font_face_source.h
@@ -30,9 +30,7 @@
 #include "third_party/blink/renderer/core/css/font_display.h"
 #include "third_party/blink/renderer/platform/fonts/font_cache_key.h"
 #include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
 #include "third_party/blink/renderer/platform/heap/garbage_collected.h"
-#include "third_party/blink/renderer/platform/heap/member.h"
 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
 #include "third_party/blink/renderer/platform/wtf/hash_map.h"
 #include "third_party/blink/renderer/platform/wtf/linked_hash_set.h"
@@ -71,8 +69,8 @@ class CORE_EXPORT CSSFontFaceSource
     return nullptr;
   }
 
-  const SimpleFontData* GetFontData(const FontDescription&,
-                                    const FontSelectionCapabilities&);
+  scoped_refptr<SimpleFontData> GetFontData(const FontDescription&,
+                                            const FontSelectionCapabilities&);
 
   // TODO(https://crbug.com/947461): IsLocalFontAvailable must not have a
   // FontDescription argument.
@@ -93,29 +91,28 @@ class CORE_EXPORT CSSFontFaceSource
   virtual bool HadBlankText() { return false; }
   virtual void PaintRequested() {}
 
-  virtual void Trace(Visitor* visitor) const {
-    visitor->Trace(font_data_table_);
-  }
+  virtual void Trace(Visitor* visitor) const {}
 
  protected:
   CSSFontFaceSource() = default;
-  virtual const SimpleFontData* CreateFontData(
+  virtual scoped_refptr<SimpleFontData> CreateFontData(
       const FontDescription&,
       const FontSelectionCapabilities&) = 0;
-
-  void ClearTable() { font_data_table_.clear(); }
+  void PruneTable();
 
   // Report the font lookup for metrics collection. Only used for local font
   // face sources currently.
   virtual void ReportFontLookup(const FontDescription& font_description,
-                                const SimpleFontData* font_data,
+                                SimpleFontData* font_data,
                                 bool is_loading_fallback = false) {}
 
  private:
-  using FontDataTable =
-      HeapHashMap<FontCacheKey, WeakMember<const SimpleFontData>>;
+  void PruneOldestIfNeeded();
+  using FontDataTable = HashMap<FontCacheKey, scoped_refptr<SimpleFontData>>;
+  using FontCacheKeyAgeList = LinkedHashSet<FontCacheKey>;
 
   FontDataTable font_data_table_;
+  FontCacheKeyAgeList font_cache_key_age;
 };
 
 }  // namespace blink
--- a/third_party/blink/renderer/core/css/css_font_selector.cc
+++ b/third_party/blink/renderer/core/css/css_font_selector.cc
@@ -162,7 +162,7 @@ void CSSFontSelector::FontCacheInvalidat
   DispatchInvalidationCallbacks(FontInvalidationReason::kGeneralInvalidation);
 }
 
-const FontData* CSSFontSelector::GetFontData(
+scoped_refptr<FontData> CSSFontSelector::GetFontData(
     const FontDescription& font_description,
     const FontFamily& font_family) {
   const auto& family_name = font_family.FamilyName();
@@ -252,13 +252,13 @@ const FontData* CSSFontSelector::GetFont
       family_name, request_description.GetScript(),
       request_description.GenericFamily(), settings_family_name);
 
-  const SimpleFontData* font_data =
+  scoped_refptr<SimpleFontData> font_data =
       FontCache::Get().GetFontData(request_description, settings_family_name);
   if (font_data && request_description.HasSizeAdjust()) {
     DCHECK(RuntimeEnabledFeatures::CSSFontSizeAdjustEnabled());
     if (auto adjusted_size =
             FontSizeFunctions::MetricsMultiplierAdjustedFontSize(
-                font_data, request_description)) {
+                font_data.get(), request_description)) {
       FontDescription size_adjusted_description(request_description);
       size_adjusted_description.SetAdjustedSize(adjusted_size.value());
       font_data = FontCache::Get().GetFontData(size_adjusted_description,
--- a/third_party/blink/renderer/core/css/css_font_selector.h
+++ b/third_party/blink/renderer/core/css/css_font_selector.h
@@ -49,8 +49,8 @@ class CORE_EXPORT CSSFontSelector : publ
 
   unsigned Version() const override { return font_face_cache_->Version(); }
 
-  const FontData* GetFontData(const FontDescription&,
-                              const FontFamily&) override;
+  scoped_refptr<FontData> GetFontData(const FontDescription&,
+                                      const FontFamily&) override;
 
   void FontFaceInvalidated(FontInvalidationReason) override;
 
--- a/third_party/blink/renderer/core/css/css_font_selector_base.cc
+++ b/third_party/blink/renderer/core/css/css_font_selector_base.cc
@@ -87,21 +87,21 @@ void CSSFontSelectorBase::ReportFailedLo
 void CSSFontSelectorBase::ReportFontLookupByUniqueOrFamilyName(
     const AtomicString& name,
     const FontDescription& font_description,
-    const SimpleFontData* resulting_font_data) {
+    scoped_refptr<SimpleFontData> resulting_font_data) {
   if (FontMatchingMetrics* font_matching_metrics = GetFontMatchingMetrics()) {
     font_matching_metrics->ReportFontLookupByUniqueOrFamilyName(
-        name, font_description, resulting_font_data);
+        name, font_description, resulting_font_data.get());
   }
 }
 
 void CSSFontSelectorBase::ReportFontLookupByUniqueNameOnly(
     const AtomicString& name,
     const FontDescription& font_description,
-    const SimpleFontData* resulting_font_data,
+    scoped_refptr<SimpleFontData> resulting_font_data,
     bool is_loading_fallback) {
   if (FontMatchingMetrics* font_matching_metrics = GetFontMatchingMetrics()) {
     font_matching_metrics->ReportFontLookupByUniqueNameOnly(
-        name, font_description, resulting_font_data, is_loading_fallback);
+        name, font_description, resulting_font_data.get(), is_loading_fallback);
   }
 }
 
@@ -109,20 +109,20 @@ void CSSFontSelectorBase::ReportFontLook
     UChar32 fallback_character,
     FontFallbackPriority fallback_priority,
     const FontDescription& font_description,
-    const SimpleFontData* resulting_font_data) {
+    scoped_refptr<SimpleFontData> resulting_font_data) {
   if (FontMatchingMetrics* font_matching_metrics = GetFontMatchingMetrics()) {
     font_matching_metrics->ReportFontLookupByFallbackCharacter(
         fallback_character, fallback_priority, font_description,
-        resulting_font_data);
+        resulting_font_data.get());
   }
 }
 
 void CSSFontSelectorBase::ReportLastResortFallbackFontLookup(
     const FontDescription& font_description,
-    const SimpleFontData* resulting_font_data) {
+    scoped_refptr<SimpleFontData> resulting_font_data) {
   if (FontMatchingMetrics* font_matching_metrics = GetFontMatchingMetrics()) {
     font_matching_metrics->ReportLastResortFallbackFontLookup(
-        font_description, resulting_font_data);
+        font_description, resulting_font_data.get());
   }
 }
 
--- a/third_party/blink/renderer/core/css/css_font_selector_base.h
+++ b/third_party/blink/renderer/core/css/css_font_selector_base.h
@@ -46,23 +46,23 @@ class CORE_EXPORT CSSFontSelectorBase :
   void ReportFontLookupByUniqueOrFamilyName(
       const AtomicString& name,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) override;
+      scoped_refptr<SimpleFontData> resulting_font_data) override;
 
   void ReportFontLookupByUniqueNameOnly(
       const AtomicString& name,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data,
+      scoped_refptr<SimpleFontData> resulting_font_data,
       bool is_loading_fallback = false) override;
 
   void ReportFontLookupByFallbackCharacter(
       UChar32 fallback_character,
       FontFallbackPriority fallback_priority,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) override;
+      scoped_refptr<SimpleFontData> resulting_font_data) override;
 
   void ReportLastResortFallbackFontLookup(
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) override;
+      scoped_refptr<SimpleFontData> resulting_font_data) override;
 
   void ReportFontFamilyLookupByGenericFamily(
       const AtomicString& generic_font_family_name,
--- a/third_party/blink/renderer/core/css/css_segmented_font_face.cc
+++ b/third_party/blink/renderer/core/css/css_segmented_font_face.cc
@@ -38,16 +38,42 @@
 #include "third_party/blink/renderer/platform/fonts/segmented_font_data.h"
 #include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
 
+// See comment below in CSSSegmentedFontFace::GetFontData - the cache from
+// CSSSegmentedFontFace (which represents a group of @font-face declarations
+// with identical FontSelectionCapabilities but differing by unicode-range) to
+// FontData/SegmentedFontData, (i.e. the actual font blobs that can be used for
+// shaping and painting retrieved from a CSSFontFaceSource) is usually small
+// (less than a dozen, up to tens) for non-animation-cases, but grows fast to
+// thousands when animating variable font parameters. Set a limit until we start
+// dropping cache entries in animation scenarios.
+static constexpr size_t kFontDataTableMaxSize = 250;
+
 namespace blink {
 
+// static
+CSSSegmentedFontFace* CSSSegmentedFontFace::Create(
+    FontSelectionCapabilities capabilities) {
+  return MakeGarbageCollected<CSSSegmentedFontFace>(capabilities);
+}
+
 CSSSegmentedFontFace::CSSSegmentedFontFace(
     FontSelectionCapabilities font_selection_capabilities)
     : font_selection_capabilities_(font_selection_capabilities),
+      font_data_table_(kFontDataTableMaxSize),
       font_faces_(MakeGarbageCollected<FontFaceList>()),
       approximate_character_count_(0) {}
 
 CSSSegmentedFontFace::~CSSSegmentedFontFace() = default;
 
+void CSSSegmentedFontFace::PruneTable() {
+  // Make sure the glyph page tree prunes out all uses of this custom font.
+  if (!font_data_table_.size()) {
+    return;
+  }
+
+  font_data_table_.Clear();
+}
+
 bool CSSSegmentedFontFace::IsValid() const {
   // Valid if at least one font face is valid.
   return font_faces_->ForEachUntilTrue(
@@ -57,12 +83,12 @@ bool CSSSegmentedFontFace::IsValid() con
 }
 
 void CSSSegmentedFontFace::FontFaceInvalidated() {
-  font_data_table_.clear();
+  PruneTable();
 }
 
 void CSSSegmentedFontFace::AddFontFace(FontFace* font_face,
                                        bool css_connected) {
-  font_data_table_.clear();
+  PruneTable();
   font_face->CssFontFace()->AddSegmentedFontFace(this);
   font_faces_->Insert(font_face, css_connected);
 }
@@ -72,11 +98,11 @@ void CSSSegmentedFontFace::RemoveFontFac
     return;
   }
 
-  font_data_table_.clear();
+  PruneTable();
   font_face->CssFontFace()->RemoveSegmentedFontFace(this);
 }
 
-const FontData* CSSSegmentedFontFace::GetFontData(
+scoped_refptr<FontData> CSSSegmentedFontFace::GetFontData(
     const FontDescription& font_description) {
   if (!IsValid()) {
     return nullptr;
@@ -98,16 +124,16 @@ const FontData* CSSSegmentedFontFace::Ge
   // usually only a small number of FontData/SegmentedFontData instances created
   // per CSSSegmentedFontFace. Whereas in variable font animations, this number
   // grows rapidly.
-  auto it = font_data_table_.find(key);
+  auto it = font_data_table_.Get(key);
   if (it != font_data_table_.end()) {
-    const SegmentedFontData* cached_font_data = it->value.Get();
+    scoped_refptr<SegmentedFontData> cached_font_data = it->second;
     if (cached_font_data && cached_font_data->NumFaces()) {
       return cached_font_data;
     }
   }
 
-  SegmentedFontData* created_font_data =
-      MakeGarbageCollected<SegmentedFontData>();
+  scoped_refptr<SegmentedFontData> created_font_data =
+      SegmentedFontData::Create();
 
   FontDescription requested_font_description(font_description);
   const FontSelectionRequest& font_selection_request =
@@ -126,16 +152,26 @@ const FontData* CSSSegmentedFontFace::Ge
     if (!font_face->CssFontFace()->IsValid()) {
       return;
     }
-    if (const SimpleFontData* face_font_data =
+    if (scoped_refptr<SimpleFontData> face_font_data =
             font_face->CssFontFace()->GetFontData(requested_font_description)) {
       DCHECK(!face_font_data->IsSegmented());
-      created_font_data->AppendFace(MakeGarbageCollected<FontDataForRangeSet>(
-          std::move(face_font_data), font_face->CssFontFace()->Ranges()));
+      if (face_font_data->IsCustomFont()) {
+        created_font_data->AppendFace(base::AdoptRef(new FontDataForRangeSet(
+            std::move(face_font_data), font_face->CssFontFace()->Ranges())));
+      } else {
+        created_font_data->AppendFace(
+            base::AdoptRef(new FontDataForRangeSetFromCache(
+                std::move(face_font_data),
+                font_face->CssFontFace()->Ranges())));
+      }
     }
   });
 
   if (created_font_data->NumFaces()) {
-    font_data_table_.insert(std::move(key), created_font_data);
+    scoped_refptr<SegmentedFontData> put_to_cache(created_font_data);
+    font_data_table_.Put(std::move(key), std::move(put_to_cache));
+    // No release, we have a reference to an object in the cache which should
+    // retain the ref count it has.
     return created_font_data;
   }
 
@@ -186,7 +222,6 @@ void CSSSegmentedFontFace::Match(const S
 }
 
 void CSSSegmentedFontFace::Trace(Visitor* visitor) const {
-  visitor->Trace(font_data_table_);
   visitor->Trace(font_faces_);
 }
 
--- a/third_party/blink/renderer/core/css/css_segmented_font_face.h
+++ b/third_party/blink/renderer/core/css/css_segmented_font_face.h
@@ -32,7 +32,6 @@
 #include "third_party/blink/renderer/platform/fonts/font_cache_key.h"
 #include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
 #include "third_party/blink/renderer/platform/fonts/segmented_font_data.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
 #include "third_party/blink/renderer/platform/heap/collection_support/heap_linked_hash_set.h"
 #include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
 #include "third_party/blink/renderer/platform/heap/garbage_collected.h"
@@ -84,6 +83,8 @@ class FontFaceList : public GarbageColle
 class CSSSegmentedFontFace final
     : public GarbageCollected<CSSSegmentedFontFace> {
  public:
+  static CSSSegmentedFontFace* Create(FontSelectionCapabilities);
+
   explicit CSSSegmentedFontFace(FontSelectionCapabilities);
   ~CSSSegmentedFontFace();
 
@@ -99,7 +100,7 @@ class CSSSegmentedFontFace final
   void RemoveFontFace(FontFace*);
   bool IsEmpty() const { return font_faces_->IsEmpty(); }
 
-  const FontData* GetFontData(const FontDescription&);
+  scoped_refptr<FontData> GetFontData(const FontDescription&);
 
   bool CheckFont(UChar32) const;
   void Match(const String&, HeapVector<Member<FontFace>>*) const;
@@ -112,11 +113,12 @@ class CSSSegmentedFontFace final
   void Trace(Visitor*) const;
 
  private:
+  void PruneTable();
   bool IsValid() const;
 
   FontSelectionCapabilities font_selection_capabilities_;
 
-  HeapHashMap<FontCacheKey, WeakMember<const SegmentedFontData>>
+  base::HashingLRUCache<FontCacheKey, scoped_refptr<SegmentedFontData>>
       font_data_table_;
 
   // All non-CSS-connected FontFaces are stored after the CSS-connected ones.
--- a/third_party/blink/renderer/core/css/font_face_cache.cc
+++ b/third_party/blink/renderer/core/css/font_face_cache.cc
@@ -85,8 +85,8 @@ void FontFaceCache::CapabilitiesSet::Add
   const auto result =
       map_.insert(font_face->GetFontSelectionCapabilities(), nullptr);
   if (result.is_new_entry) {
-    result.stored_value->value = MakeGarbageCollected<CSSSegmentedFontFace>(
-        font_face->GetFontSelectionCapabilities());
+    result.stored_value->value =
+        CSSSegmentedFontFace::Create(font_face->GetFontSelectionCapabilities());
   }
 
   result.stored_value->value->AddFontFace(font_face, css_connected);
--- a/third_party/blink/renderer/core/css/local_font_face_source.cc
+++ b/third_party/blink/renderer/core/css/local_font_face_source.cc
@@ -52,22 +52,23 @@ bool LocalFontFaceSource::IsLocalFontAva
   return font_available;
 }
 
-const SimpleFontData* LocalFontFaceSource::CreateLoadingFallbackFontData(
+scoped_refptr<SimpleFontData>
+LocalFontFaceSource::CreateLoadingFallbackFontData(
     const FontDescription& font_description) {
   FontCachePurgePreventer font_cache_purge_preventer;
-  const SimpleFontData* temporary_font =
-      FontCache::Get().GetLastResortFallbackFont(font_description);
+  scoped_refptr<SimpleFontData> temporary_font =
+      FontCache::Get().GetLastResortFallbackFont(font_description,
+                                                 kDoNotRetain);
   if (!temporary_font) {
     NOTREACHED();
     return nullptr;
   }
-  CSSCustomFontData* css_font_data = MakeGarbageCollected<CSSCustomFontData>(
-      this, CSSCustomFontData::kVisibleFallback);
-  return MakeGarbageCollected<SimpleFontData>(&temporary_font->PlatformData(),
-                                              css_font_data);
+  scoped_refptr<CSSCustomFontData> css_font_data =
+      CSSCustomFontData::Create(this, CSSCustomFontData::kVisibleFallback);
+  return SimpleFontData::Create(temporary_font->PlatformData(), css_font_data);
 }
 
-const SimpleFontData* LocalFontFaceSource::CreateFontData(
+scoped_refptr<SimpleFontData> LocalFontFaceSource::CreateFontData(
     const FontDescription& font_description,
     const FontSelectionCapabilities&) {
   if (!IsValid()) {
@@ -84,9 +85,9 @@ const SimpleFontData* LocalFontFaceSourc
   }
 
   if (IsValid() && IsLoading()) {
-    const SimpleFontData* fallback_font_data =
+    scoped_refptr<SimpleFontData> fallback_font_data =
         CreateLoadingFallbackFontData(font_description);
-    ReportFontLookup(font_description, fallback_font_data,
+    ReportFontLookup(font_description, fallback_font_data.get(),
                      true /* is_loading_fallback */);
     return fallback_font_data;
   }
@@ -110,10 +111,10 @@ const SimpleFontData* LocalFontFaceSourc
 #endif
   // TODO(https://crbug.com/1302264): Enable passing down of font-palette
   // information here (font_description.GetFontPalette()).
-  const SimpleFontData* font_data = FontCache::Get().GetFontData(
+  scoped_refptr<SimpleFontData> font_data = FontCache::Get().GetFontData(
       unstyled_description, font_name_, AlternateFontName::kLocalUniqueFace);
-  histograms_.Record(font_data);
-  ReportFontLookup(unstyled_description, font_data);
+  histograms_.Record(font_data.get());
+  ReportFontLookup(unstyled_description, font_data.get());
   return font_data;
 }
 
@@ -132,7 +133,7 @@ void LocalFontFaceSource::BeginLoadIfNee
 }
 
 void LocalFontFaceSource::NotifyFontUniqueNameLookupReady() {
-  ClearTable();
+  PruneTable();
 
   if (face_->FontLoaded(this)) {
     font_selector_->FontFaceInvalidated(
@@ -168,7 +169,7 @@ void LocalFontFaceSource::Trace(Visitor*
 
 void LocalFontFaceSource::ReportFontLookup(
     const FontDescription& font_description,
-    const SimpleFontData* font_data,
+    SimpleFontData* font_data,
     bool is_loading_fallback) {
   font_selector_->ReportFontLookupByUniqueNameOnly(
       font_name_, font_description, font_data, is_loading_fallback);
--- a/third_party/blink/renderer/core/css/local_font_face_source.h
+++ b/third_party/blink/renderer/core/css/local_font_face_source.h
@@ -48,15 +48,16 @@ class LocalFontFaceSource final : public
   void NotifyFontUniqueNameLookupReady();
 
  protected:
-  const SimpleFontData* CreateLoadingFallbackFontData(const FontDescription&);
+  scoped_refptr<SimpleFontData> CreateLoadingFallbackFontData(
+      const FontDescription&);
 
  private:
-  const SimpleFontData* CreateFontData(
+  scoped_refptr<SimpleFontData> CreateFontData(
       const FontDescription&,
       const FontSelectionCapabilities&) override;
 
   void ReportFontLookup(const FontDescription& font_description,
-                        const SimpleFontData* font_data,
+                        SimpleFontData* font_data,
                         bool is_loading_fallback = false) override;
 
   class LocalFontHistograms {
--- a/third_party/blink/renderer/core/css/offscreen_font_selector.cc
+++ b/third_party/blink/renderer/core/css/offscreen_font_selector.cc
@@ -39,7 +39,7 @@ void OffscreenFontSelector::RegisterForI
 void OffscreenFontSelector::UnregisterForInvalidationCallbacks(
     FontSelectorClient* client) {}
 
-const FontData* OffscreenFontSelector::GetFontData(
+scoped_refptr<FontData> OffscreenFontSelector::GetFontData(
     const FontDescription& font_description,
     const FontFamily& font_family) {
   const auto& family_name = font_family.FamilyName();
@@ -60,11 +60,11 @@ const FontData* OffscreenFontSelector::G
       family_name, font_description.GetScript(),
       font_description.GenericFamily(), settings_family_name);
 
-  const auto* font_data =
+  auto font_data =
       FontCache::Get().GetFontData(font_description, settings_family_name);
 
   ReportFontLookupByUniqueOrFamilyName(settings_family_name, font_description,
-                                       font_data);
+                                       font_data.get());
 
   return font_data;
 }
--- a/third_party/blink/renderer/core/css/offscreen_font_selector.h
+++ b/third_party/blink/renderer/core/css/offscreen_font_selector.h
@@ -26,8 +26,8 @@ class CORE_EXPORT OffscreenFontSelector
 
   unsigned Version() const override { return 1; }
 
-  const FontData* GetFontData(const FontDescription&,
-                              const FontFamily&) override;
+  scoped_refptr<FontData> GetFontData(const FontDescription&,
+                                      const FontFamily&) override;
 
   void RegisterForInvalidationCallbacks(FontSelectorClient*) override;
   void UnregisterForInvalidationCallbacks(FontSelectorClient*) override;
--- a/third_party/blink/renderer/core/css/remote_font_face_source.cc
+++ b/third_party/blink/renderer/core/css/remote_font_face_source.cc
@@ -240,7 +240,8 @@ void RemoteFontFaceSource::NotifyFinishe
   }
 
   ClearResource();
-  ClearTable();
+
+  PruneTable();
 
   if (GetDocument()) {
     if (!GetDocument()->RenderingHasBegun()) {
@@ -305,7 +306,7 @@ bool RemoteFontFaceSource::UpdatePeriod(
   // Invalidate the font if its fallback visibility has changed.
   if (IsLoading() && period_ != new_period &&
       (period_ == kBlockPeriod || new_period == kBlockPeriod)) {
-    ClearTable();
+    PruneTable();
     if (face_->FallbackVisibilityChanged(this)) {
       font_selector_->FontFaceInvalidated(
           FontInvalidationReason::kGeneralInvalidation);
@@ -349,7 +350,7 @@ bool RemoteFontFaceSource::IsLowPriority
   return is_intervention_triggered_;
 }
 
-const SimpleFontData* RemoteFontFaceSource::CreateFontData(
+scoped_refptr<SimpleFontData> RemoteFontFaceSource::CreateFontData(
     const FontDescription& font_description,
     const FontSelectionCapabilities& font_selection_capabilities) {
   if (period_ == kFailurePeriod || !IsValid()) {
@@ -362,7 +363,7 @@ const SimpleFontData* RemoteFontFaceSour
 
   histograms_.RecordFallbackTime();
 
-  return MakeGarbageCollected<SimpleFontData>(
+  return SimpleFontData::Create(
       custom_font_data_->GetFontPlatformData(
           font_description.EffectiveFontSize(),
           font_description.AdjustedSpecifiedSize(),
@@ -379,24 +380,25 @@ const SimpleFontData* RemoteFontFaceSour
               : ResolvedFontFeatures(),
           font_description.Orientation(), font_description.VariationSettings(),
           font_description.GetFontPalette()),
-      MakeGarbageCollected<CustomFontData>());
+      CustomFontData::Create());
 }
 
-const SimpleFontData* RemoteFontFaceSource::CreateLoadingFallbackFontData(
+scoped_refptr<SimpleFontData>
+RemoteFontFaceSource::CreateLoadingFallbackFontData(
     const FontDescription& font_description) {
   // This temporary font is not retained and should not be returned.
   FontCachePurgePreventer font_cache_purge_preventer;
-  const SimpleFontData* temporary_font =
-      FontCache::Get().GetLastResortFallbackFont(font_description);
+  scoped_refptr<SimpleFontData> temporary_font =
+      FontCache::Get().GetLastResortFallbackFont(font_description,
+                                                 kDoNotRetain);
   if (!temporary_font) {
     DUMP_WILL_BE_NOTREACHED_NORETURN();
     return nullptr;
   }
-  CSSCustomFontData* css_font_data = MakeGarbageCollected<CSSCustomFontData>(
+  scoped_refptr<CSSCustomFontData> css_font_data = CSSCustomFontData::Create(
       this, period_ == kBlockPeriod ? CSSCustomFontData::kInvisibleFallback
                                     : CSSCustomFontData::kVisibleFallback);
-  return MakeGarbageCollected<SimpleFontData>(&temporary_font->PlatformData(),
-                                              css_font_data);
+  return SimpleFontData::Create(temporary_font->PlatformData(), css_font_data);
 }
 
 void RemoteFontFaceSource::BeginLoadIfNeeded() {
--- a/third_party/blink/renderer/core/css/remote_font_face_source.h
+++ b/third_party/blink/renderer/core/css/remote_font_face_source.h
@@ -66,10 +66,11 @@ class RemoteFontFaceSource final : publi
   void Trace(Visitor*) const override;
 
  protected:
-  const SimpleFontData* CreateFontData(
+  scoped_refptr<SimpleFontData> CreateFontData(
       const FontDescription&,
       const FontSelectionCapabilities&) override;
-  const SimpleFontData* CreateLoadingFallbackFontData(const FontDescription&);
+  scoped_refptr<SimpleFontData> CreateLoadingFallbackFontData(
+      const FontDescription&);
 
  private:
   // Periods of the Font Display Timeline.
--- a/third_party/blink/renderer/core/frame/font_matching_metrics.cc
+++ b/third_party/blink/renderer/core/frame/font_matching_metrics.cc
@@ -127,7 +127,7 @@ void FontMatchingMetrics::ReportLocalFon
 }
 
 void FontMatchingMetrics::InsertFontHashIntoMap(IdentifiableTokenKey input_key,
-                                                const SimpleFontData* font_data,
+                                                SimpleFontData* font_data,
                                                 TokenToTokenHashMap& hash_map) {
   DCHECK(IdentifiabilityStudyShouldSampleFonts());
   if (hash_map.Contains(input_key)) {
@@ -160,7 +160,7 @@ FontMatchingMetrics::GetTokenBuilderWith
 void FontMatchingMetrics::ReportFontLookupByUniqueOrFamilyName(
     const AtomicString& name,
     const FontDescription& font_description,
-    const SimpleFontData* resulting_font_data) {
+    SimpleFontData* resulting_font_data) {
   Dactyloscoper::TraceFontLookup(
       execution_context_, name, font_description,
       Dactyloscoper::FontLookupType::kUniqueOrFamilyName);
@@ -184,7 +184,7 @@ void FontMatchingMetrics::ReportFontLook
 void FontMatchingMetrics::ReportFontLookupByUniqueNameOnly(
     const AtomicString& name,
     const FontDescription& font_description,
-    const SimpleFontData* resulting_font_data,
+    SimpleFontData* resulting_font_data,
     bool is_loading_fallback) {
   // We ignore lookups that result in loading fallbacks for now as they should
   // only be temporary.
@@ -217,7 +217,7 @@ void FontMatchingMetrics::ReportFontLook
     UChar32 fallback_character,
     FontFallbackPriority fallback_priority,
     const FontDescription& font_description,
-    const SimpleFontData* resulting_font_data) {
+    SimpleFontData* resulting_font_data) {
   if (!IdentifiabilityStudySettings::Get()->ShouldSampleType(
           IdentifiableSurface::Type::kLocalFontLookupByFallbackCharacter)) {
     return;
@@ -236,7 +236,7 @@ void FontMatchingMetrics::ReportFontLook
 
 void FontMatchingMetrics::ReportLastResortFallbackFontLookup(
     const FontDescription& font_description,
-    const SimpleFontData* resulting_font_data) {
+    SimpleFontData* resulting_font_data) {
   if (!IdentifiabilityStudySettings::Get()->ShouldSampleType(
           IdentifiableSurface::Type::kLocalFontLookupAsLastResort)) {
     return;
@@ -361,8 +361,7 @@ void FontMatchingMetrics::PublishAllMetr
   PublishEmojiGlyphMetrics();
 }
 
-int64_t FontMatchingMetrics::GetHashForFontData(
-    const SimpleFontData* font_data) {
+int64_t FontMatchingMetrics::GetHashForFontData(SimpleFontData* font_data) {
   return font_data ? FontGlobalContext::Get()
                          .GetOrComputeTypefaceDigest(font_data->PlatformData())
                          .ToUkmMetricValue()
@@ -370,7 +369,7 @@ int64_t FontMatchingMetrics::GetHashForF
 }
 
 IdentifiableToken FontMatchingMetrics::GetPostScriptNameTokenForFontData(
-    const SimpleFontData* font_data) {
+    SimpleFontData* font_data) {
   DCHECK(font_data);
   return FontGlobalContext::Get().GetOrComputePostScriptNameDigest(
       font_data->PlatformData());
--- a/third_party/blink/renderer/core/frame/font_matching_metrics.h
+++ b/third_party/blink/renderer/core/frame/font_matching_metrics.h
@@ -100,16 +100,15 @@ class FontMatchingMetrics {
   void ReportFontLookupByUniqueOrFamilyName(
       const AtomicString& name,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data);
+      SimpleFontData* resulting_font_data);
 
   // Reports a local font was looked up by a name and font description. This
   // only includes lookups where the name is allowed to match PostScript names
   // and full font names, but not family names.
-  void ReportFontLookupByUniqueNameOnly(
-      const AtomicString& name,
-      const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data,
-      bool is_loading_fallback = false);
+  void ReportFontLookupByUniqueNameOnly(const AtomicString& name,
+                                        const FontDescription& font_description,
+                                        SimpleFontData* resulting_font_data,
+                                        bool is_loading_fallback = false);
 
   // Reports a font was looked up by a fallback character, fallback priority,
   // and a font description.
@@ -117,12 +116,12 @@ class FontMatchingMetrics {
       UChar32 fallback_character,
       FontFallbackPriority fallback_priority,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data);
+      SimpleFontData* resulting_font_data);
 
   // Reports a last-resort fallback font was looked up by a font description.
   void ReportLastResortFallbackFontLookup(
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data);
+      SimpleFontData* resulting_font_data);
 
   // Reports a generic font family name was matched according to the script and
   // the user's preferences to a font family name.
@@ -171,7 +170,7 @@ class FontMatchingMetrics {
   // nullptr, then the typeface digest will also be saved with its PostScript
   // name in |font_load_postscript_name_|.
   void InsertFontHashIntoMap(IdentifiableTokenKey input_key,
-                             const SimpleFontData* font_data,
+                             SimpleFontData* font_data,
                              TokenToTokenHashMap& hash_map);
 
   // Reports a local font's existence was looked up by a name, but its actual
@@ -194,14 +193,14 @@ class FontMatchingMetrics {
 
   // Get a hash that uniquely represents the font data. Returns 0 if |font_data|
   // is nullptr.
-  int64_t GetHashForFontData(const SimpleFontData* font_data);
+  int64_t GetHashForFontData(SimpleFontData* font_data);
 
   void Initialize();
 
   // Get a token that uniquely represents the typeface's PostScript name. May
   // represent the empty string if no PostScript name was found.
   IdentifiableToken GetPostScriptNameTokenForFontData(
-      const SimpleFontData* font_data);
+      SimpleFontData* font_data);
 
   TokenToTokenHashMap font_lookups_by_unique_or_family_name_;
   TokenToTokenHashMap font_lookups_by_unique_name_only_;
--- a/third_party/blink/renderer/core/html/forms/internal_popup_menu.cc
+++ b/third_party/blink/renderer/core/html/forms/internal_popup_menu.cc
@@ -132,8 +132,8 @@ class PopupMenuCSSFontSelector : public
 
   // We don't override willUseFontData() for now because the old PopupListBox
   // only worked with fonts loaded when opening the popup.
-  const FontData* GetFontData(const FontDescription&,
-                              const FontFamily&) override;
+  scoped_refptr<FontData> GetFontData(const FontDescription&,
+                                      const FontFamily&) override;
 
   void Trace(Visitor*) const override;
 
@@ -152,7 +152,7 @@ PopupMenuCSSFontSelector::PopupMenuCSSFo
 
 PopupMenuCSSFontSelector::~PopupMenuCSSFontSelector() = default;
 
-const FontData* PopupMenuCSSFontSelector::GetFontData(
+scoped_refptr<FontData> PopupMenuCSSFontSelector::GetFontData(
     const FontDescription& description,
     const FontFamily& font_family) {
   return owner_font_selector_->GetFontData(description, font_family);
--- a/third_party/blink/renderer/core/inspector/inspector_css_agent.cc
+++ b/third_party/blink/renderer/core/inspector/inspector_css_agent.cc
@@ -122,7 +122,6 @@
 #include "third_party/blink/renderer/platform/fonts/font_custom_platform_data.h"
 #include "third_party/blink/renderer/platform/fonts/shaping/caching_word_shaper.h"
 #include "third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/clear_collection_scope.h"
 #include "third_party/blink/renderer/platform/heap/garbage_collected.h"
 #include "third_party/blink/renderer/platform/text/text_run.h"
 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
@@ -200,10 +199,10 @@ HeapVector<Member<CSSStyleRule>> FilterD
 }
 
 void CollectPlatformFontsFromRunFontDataList(
-    const HeapVector<ShapeResult::RunFontData>& run_font_data_list,
+    const Vector<ShapeResult::RunFontData>& run_font_data_list,
     HashMap<std::pair<int, String>, std::pair<int, String>>* font_stats) {
   for (const auto& run_font_data : run_font_data_list) {
-    const auto* simple_font_data = run_font_data.font_data_.Get();
+    const auto* simple_font_data = run_font_data.font_data_;
     String family_name = simple_font_data->PlatformData().FontFamilyName();
     if (family_name.IsNull())
       family_name = "";
@@ -1733,8 +1732,7 @@ void InspectorCSSAgent::CollectPlatformF
     if (!shape_result) {
       continue;
     }
-    HeapVector<ShapeResult::RunFontData> run_font_data_list;
-    ClearCollectionScope clear_scope(&run_font_data_list);
+    Vector<ShapeResult::RunFontData> run_font_data_list;
     shape_result->GetRunFontData(&run_font_data_list);
     CollectPlatformFontsFromRunFontDataList(run_font_data_list, font_stats);
   }
--- a/third_party/blink/renderer/core/layout/inline/inline_box_state.cc
+++ b/third_party/blink/renderer/core/layout/inline/inline_box_state.cc
@@ -19,7 +19,6 @@
 #include "third_party/blink/renderer/core/style/computed_style.h"
 #include "third_party/blink/renderer/core/svg/svg_length_functions.h"
 #include "third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/clear_collection_scope.h"
 
 namespace blink {
 
@@ -169,8 +168,7 @@ void InlineBoxState::EnsureTextMetrics(c
 
 void InlineBoxState::AccumulateUsedFonts(const ShapeResultView* shape_result) {
   const auto baseline_type = style->GetFontBaseline();
-  HeapHashSet<Member<const SimpleFontData>> fallback_fonts;
-  ClearCollectionScope clear_scope(&fallback_fonts);
+  HashSet<const SimpleFontData*> fallback_fonts;
   shape_result->FallbackFonts(&fallback_fonts);
   for (const SimpleFontData* const fallback_font : fallback_fonts) {
     FontHeight fallback_metrics =
--- a/third_party/blink/renderer/core/layout/inline/ruby_utils.cc
+++ b/third_party/blink/renderer/core/layout/inline/ruby_utils.cc
@@ -12,7 +12,6 @@
 #include "third_party/blink/renderer/core/layout/layout_object_inlines.h"
 #include "third_party/blink/renderer/core/layout/physical_box_fragment.h"
 #include "third_party/blink/renderer/platform/fonts/font_height.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/clear_collection_scope.h"
 
 namespace blink {
 
@@ -33,10 +32,11 @@ std::tuple<LayoutUnit, LayoutUnit> Adjus
       primary_font_data->GetFontMetrics().FixedAscent(font_baseline);
   const LayoutUnit primary_descent = line_height - primary_ascent;
 
+  DCHECK(IsMainThread());
+  DEFINE_STATIC_LOCAL(Vector<ShapeResult::RunFontData>, run_fonts, ());
+  DCHECK_EQ(run_fonts.size(), 0u);
   // We don't use ShapeResultView::FallbackFonts() because we can't know if the
   // primary font is actually used with FallbackFonts().
-  HeapVector<ShapeResult::RunFontData> run_fonts;
-  ClearCollectionScope clear_scope(&run_fonts);
   shape_view.GetRunFontData(&run_fonts);
   const LayoutUnit kNoDiff = LayoutUnit::Max();
   LayoutUnit over_diff = kNoDiff;
@@ -60,6 +60,7 @@ std::tuple<LayoutUnit, LayoutUnit> Adjus
     over_diff = std::min(over_diff, current_over_diff);
     under_diff = std::min(under_diff, current_under_diff);
   }
+  run_fonts.resize(0);
   if (over_diff == kNoDiff)
     over_diff = LayoutUnit();
   if (under_diff == kNoDiff)
@@ -956,8 +957,7 @@ FontHeight ComputeEmHeight(const Logical
     FontHeight result_height;
     // We don't use ShapeResultView::FallbackFonts() because we can't know if
     // the primary font is actually used with FallbackFonts().
-    HeapVector<ShapeResult::RunFontData> run_fonts;
-    ClearCollectionScope clear_scope(&run_fonts);
+    Vector<ShapeResult::RunFontData> run_fonts;
     shape_result_view->GetRunFontData(&run_fonts);
     for (const auto& run_font : run_fonts) {
       const SimpleFontData* font_data = run_font.font_data_;
--- a/third_party/blink/renderer/core/layout/layout_font_accessor_win.cc
+++ b/third_party/blink/renderer/core/layout/layout_font_accessor_win.cc
@@ -16,7 +16,6 @@
 #include "third_party/blink/renderer/platform/fonts/font_platform_data.h"
 #include "third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h"
 #include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/clear_collection_scope.h"
 
 namespace blink {
 
@@ -36,8 +35,7 @@ void GetFontsUsedByFragment(const Physic
             shape_result_view->PrimaryFont()->PlatformData().FontFamilyName();
         if (!font_family.empty())
           result.font_names.insert(font_family);
-        HeapHashSet<Member<const SimpleFontData>> fallback_font_data;
-        ClearCollectionScope clear_scope(&fallback_font_data);
+        HashSet<const SimpleFontData*> fallback_font_data;
         shape_result_view->FallbackFonts(&fallback_font_data);
         for (const SimpleFontData* font_data : fallback_font_data) {
           result.font_names.insert(font_data->PlatformData().FontFamilyName());
--- a/third_party/blink/renderer/modules/font_access/font_metadata.cc
+++ b/third_party/blink/renderer/modules/font_access/font_metadata.cc
@@ -77,7 +77,7 @@ void FontMetadata::BlobImpl(ScriptPromis
   SetUpFontUniqueLookupIfNecessary();
 
   FontDescription description;
-  const SimpleFontData* font_data =
+  scoped_refptr<SimpleFontData> font_data =
       FontCache::Get().GetFontData(description, AtomicString(postscriptName),
                                    AlternateFontName::kLocalUniqueFace);
   if (!font_data) {
--- a/third_party/blink/renderer/platform/BUILD.gn
+++ b/third_party/blink/renderer/platform/BUILD.gn
@@ -621,6 +621,7 @@ component("platform") {
     "fonts/font_cache_memory_dump_provider.h",
     "fonts/font_custom_platform_data.cc",
     "fonts/font_custom_platform_data.h",
+    "fonts/font_data.cc",
     "fonts/font_data.h",
     "fonts/font_data_cache.cc",
     "fonts/font_data_cache.h",
--- a/third_party/blink/renderer/platform/fonts/android/font_cache_android.cc
+++ b/third_party/blink/renderer/platform/fonts/android/font_cache_android.cc
@@ -127,7 +127,7 @@ sk_sp<SkTypeface> FontCache::CreateLocal
   return nullptr;
 }
 
-const SimpleFontData* FontCache::PlatformFallbackFontForCharacter(
+scoped_refptr<SimpleFontData> FontCache::PlatformFallbackFontForCharacter(
     const FontDescription& font_description,
     UChar32 c,
     const SimpleFontData*,
@@ -158,7 +158,7 @@ const SimpleFontData* FontCache::Platfor
   if (fallback_priority == FontFallbackPriority::kEmojiEmoji &&
       base::FeatureList::IsEnabled(features::kGMSCoreEmoji)) {
     auto skia_fallback_is_noto_color_emoji = [&]() {
-      const FontPlatformData* skia_fallback_result = GetFontPlatformData(
+      FontPlatformData* skia_fallback_result = GetFontPlatformData(
           font_description, FontFaceCreationParams(family_name));
 
       // Determining the PostScript name is required as Skia on Android gives
@@ -175,14 +175,15 @@ const SimpleFontData* FontCache::Platfor
     };
 
     if (family_name.empty() || skia_fallback_is_noto_color_emoji()) {
-      const FontPlatformData* emoji_gms_core_font = GetFontPlatformData(
+      FontPlatformData* emoji_gms_core_font = GetFontPlatformData(
           font_description,
           FontFaceCreationParams(AtomicString(kNotoColorEmojiCompat)));
       if (emoji_gms_core_font) {
         SkTypeface* probe_coverage_typeface = emoji_gms_core_font->Typeface();
         if (probe_coverage_typeface &&
             probe_coverage_typeface->unicharToGlyph(c)) {
-          return FontDataFromFontPlatformData(emoji_gms_core_font);
+          return FontDataFromFontPlatformData(emoji_gms_core_font,
+                                              kDoNotRetain);
         }
       }
     }
@@ -192,10 +193,12 @@ const SimpleFontData* FontCache::Platfor
   // font was not found or an OEM emoji font was not to be overridden.
 
   if (family_name.empty())
-    return GetLastResortFallbackFont(font_description);
+    return GetLastResortFallbackFont(font_description, kDoNotRetain);
 
-  return FontDataFromFontPlatformData(GetFontPlatformData(
-      font_description, FontFaceCreationParams(family_name)));
+  return FontDataFromFontPlatformData(
+      GetFontPlatformData(font_description,
+                          FontFaceCreationParams(family_name)),
+      kDoNotRetain);
 }
 
 // static
--- a/third_party/blink/renderer/platform/fonts/custom_font_data.h
+++ b/third_party/blink/renderer/platform/fonts/custom_font_data.h
@@ -22,8 +22,8 @@
 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_CUSTOM_FONT_DATA_H_
 
 #include "base/memory/scoped_refptr.h"
-#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
+#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"
 
 namespace blink {
 
@@ -34,17 +34,22 @@ namespace blink {
 //  * `BinaryDataFontFaceSource` as loaded font resource
 //  * `LocalFontFaceSource` as derived class `CSSCustomFontData`
 //  * `RemoteFontFaceSource` as derived class `CSSCustomFontData`
-class PLATFORM_EXPORT CustomFontData : public GarbageCollected<CustomFontData> {
+class PLATFORM_EXPORT CustomFontData : public RefCounted<CustomFontData> {
  public:
-  CustomFontData() = default;
+  static scoped_refptr<CustomFontData> Create() {
+    return base::AdoptRef(new CustomFontData());
+  }
+
   virtual ~CustomFontData() = default;
-  virtual void Trace(Visitor*) const {}
 
   virtual void BeginLoadIfNeeded() const {}
   virtual bool IsLoading() const { return false; }
   virtual bool IsLoadingFallback() const { return false; }
   virtual bool ShouldSkipDrawing() const { return false; }
   virtual bool IsPendingDataUrl() const { return false; }
+
+ protected:
+  CustomFontData() = default;
 };
 
 }  // namespace blink
--- a/third_party/blink/renderer/platform/fonts/font_cache.cc
+++ b/third_party/blink/renderer/platform/fonts/font_cache.cc
@@ -87,7 +87,10 @@ FontCache& FontCache::Get() {
   return FontGlobalContext::GetFontCache();
 }
 
-FontCache::FontCache() : font_manager_(sk_ref_sp(static_font_manager_)) {
+FontCache::FontCache()
+    : font_manager_(sk_ref_sp(static_font_manager_)),
+      font_platform_data_cache_(FontPlatformDataCache::Create()),
+      font_data_cache_(FontDataCache::Create()) {
 #if BUILDFLAG(IS_WIN)
   if (!font_manager_ || should_use_test_font_mgr) {
     // This code path is only for unit tests. This SkFontMgr does not work in
@@ -113,14 +116,12 @@ FontCache::~FontCache() = default;
 
 void FontCache::Trace(Visitor* visitor) const {
   visitor->Trace(font_cache_clients_);
-  visitor->Trace(font_platform_data_cache_);
-  visitor->Trace(fallback_list_shaper_cache_);
-  visitor->Trace(font_data_cache_);
   visitor->Trace(font_fallback_map_);
+  visitor->Trace(fallback_list_shaper_cache_);
 }
 
 #if !BUILDFLAG(IS_MAC)
-const FontPlatformData* FontCache::SystemFontPlatformData(
+FontPlatformData* FontCache::SystemFontPlatformData(
     const FontDescription& font_description) {
   const AtomicString& family = FontCache::SystemFontFamily();
 #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) || \
@@ -135,7 +136,7 @@ const FontPlatformData* FontCache::Syste
 }
 #endif
 
-const FontPlatformData* FontCache::GetFontPlatformData(
+FontPlatformData* FontCache::GetFontPlatformData(
     const FontDescription& font_description,
     const FontFaceCreationParams& creation_params,
     AlternateFontName alternate_font_name) {
@@ -153,7 +154,7 @@ const FontPlatformData* FontCache::GetFo
   }
 #endif
 
-  return font_platform_data_cache_.GetOrCreateFontPlatformData(
+  return font_platform_data_cache_->GetOrCreateFontPlatformData(
       this, font_description, creation_params, alternate_font_name);
 }
 
@@ -175,26 +176,34 @@ void FontCache::AcceptLanguagesChanged(c
   Get().InvalidateShapeCache();
 }
 
-const SimpleFontData* FontCache::GetFontData(
+scoped_refptr<SimpleFontData> FontCache::GetFontData(
     const FontDescription& font_description,
     const AtomicString& family,
-    AlternateFontName altername_font_name) {
-  if (const FontPlatformData* platform_data = GetFontPlatformData(
+    AlternateFontName altername_font_name,
+    ShouldRetain should_retain) {
+  if (FontPlatformData* platform_data = GetFontPlatformData(
           font_description,
           FontFaceCreationParams(
               AdjustFamilyNameToAvoidUnsupportedFonts(family)),
           altername_font_name)) {
     return FontDataFromFontPlatformData(
-        platform_data, font_description.SubpixelAscentDescent());
+        platform_data, should_retain, font_description.SubpixelAscentDescent());
   }
 
   return nullptr;
 }
 
-const SimpleFontData* FontCache::FontDataFromFontPlatformData(
+scoped_refptr<SimpleFontData> FontCache::FontDataFromFontPlatformData(
     const FontPlatformData* platform_data,
+    ShouldRetain should_retain,
     bool subpixel_ascent_descent) {
-  return font_data_cache_.Get(platform_data, subpixel_ascent_descent);
+#if DCHECK_IS_ON()
+  if (should_retain == kDoNotRetain)
+    DCHECK(purge_prevent_count_);
+#endif
+
+  return font_data_cache_->Get(platform_data, should_retain,
+                               subpixel_ascent_descent);
 }
 
 bool FontCache::IsPlatformFamilyMatchAvailable(
@@ -223,7 +232,15 @@ String FontCache::FirstAvailableOrFirst(
       gfx::FontList::FirstAvailableOrFirst(families.Utf8().c_str()));
 }
 
-const SimpleFontData* FontCache::FallbackFontForCharacter(
+SimpleFontData* FontCache::GetNonRetainedLastResortFallbackFont(
+    const FontDescription& font_description) {
+  auto font = GetLastResortFallbackFont(font_description, kDoNotRetain);
+  if (font)
+    font->AddRef();
+  return font.get();
+}
+
+scoped_refptr<SimpleFontData> FontCache::FallbackFontForCharacter(
     const FontDescription& description,
     UChar32 lookup_char,
     const SimpleFontData* font_data_to_substitute,
@@ -240,12 +257,21 @@ const SimpleFontData* FontCache::Fallbac
       Character::IsNonCharacter(lookup_char))
     return nullptr;
   base::ElapsedTimer timer;
-  const SimpleFontData* result = PlatformFallbackFontForCharacter(
+  scoped_refptr<SimpleFontData> result = PlatformFallbackFontForCharacter(
       description, lookup_char, font_data_to_substitute, fallback_priority);
   FontPerformance::AddSystemFallbackFontTime(timer.Elapsed());
   return result;
 }
 
+void FontCache::ReleaseFontData(const SimpleFontData* font_data) {
+  font_data_cache_->Release(font_data);
+}
+
+void FontCache::PurgePlatformFontDataCache() {
+  TRACE_EVENT0("fonts,ui", "FontCache::PurgePlatformFontDataCache");
+  font_platform_data_cache_->Purge(*font_data_cache_);
+}
+
 void FontCache::PurgeFallbackListShaperCache() {
   TRACE_EVENT0("fonts,ui", "FontCache::PurgeFallbackListShaperCache");
   for (auto& shape_cache : fallback_list_shaper_cache_.Values()) {
@@ -257,13 +283,17 @@ void FontCache::InvalidateShapeCache() {
   PurgeFallbackListShaperCache();
 }
 
-void FontCache::Purge() {
+void FontCache::Purge(PurgeSeverity purge_severity) {
   // Ideally we should never be forcing the purge while the
   // FontCachePurgePreventer is in scope, but we call purge() at any timing
   // via MemoryPressureListenerRegistry.
   if (purge_prevent_count_)
     return;
 
+  if (!font_data_cache_->Purge(purge_severity))
+    return;
+
+  PurgePlatformFontDataCache();
   PurgeFallbackListShaperCache();
 }
 
@@ -279,15 +309,14 @@ uint16_t FontCache::Generation() {
 
 void FontCache::Invalidate() {
   TRACE_EVENT0("fonts,ui", "FontCache::Invalidate");
-  font_platform_data_cache_.Clear();
-  font_data_cache_.Clear();
+  font_platform_data_cache_->Clear();
   generation_++;
 
   for (const auto& client : font_cache_clients_) {
     client->FontCacheInvalidated();
   }
 
-  Purge();
+  Purge(kForcePurge);
 }
 
 void FontCache::CrashWithFontInfo(const FontDescription* font_description) {
@@ -320,6 +349,16 @@ void FontCache::CrashWithFontInfo(const
   CHECK(false);
 }
 
+void FontCache::DumpFontPlatformDataCache(
+    base::trace_event::ProcessMemoryDump* memory_dump) {
+  DCHECK(IsMainThread());
+  base::trace_event::MemoryAllocatorDump* dump =
+      memory_dump->CreateAllocatorDump("font_caches/font_platform_data_cache");
+  dump->AddScalar("size", "bytes", font_platform_data_cache_->ByteSize());
+  memory_dump->AddSuballocation(dump->guid(),
+                                WTF::Partitions::kAllocatedObjectPoolName);
+}
+
 void FontCache::DumpShapeResultCache(
     base::trace_event::ProcessMemoryDump* memory_dump) {
   DCHECK(IsMainThread());
--- a/third_party/blink/renderer/platform/fonts/font_cache.h
+++ b/third_party/blink/renderer/platform/fonts/font_cache.h
@@ -36,13 +36,13 @@
 #include <string>
 
 #include "base/gtest_prod_util.h"
+#include "base/memory/scoped_refptr.h"
 #include "build/build_config.h"
 #include "third_party/blink/renderer/platform/fonts/fallback_list_composite_key.h"
 #include "third_party/blink/renderer/platform/fonts/font_cache_client.h"
 #include "third_party/blink/renderer/platform/fonts/font_data_cache.h"
 #include "third_party/blink/renderer/platform/fonts/font_face_creation_params.h"
 #include "third_party/blink/renderer/platform/fonts/font_fallback_priority.h"
-#include "third_party/blink/renderer/platform/fonts/font_platform_data_cache.h"
 #include "third_party/blink/renderer/platform/fonts/shaping/shape_cache.h"
 #include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
@@ -75,6 +75,7 @@ class FontFaceCreationParams;
 class FontFallbackMap;
 class FontGlobalContext;
 class FontPlatformData;
+class FontPlatformDataCache;
 class SimpleFontData;
 class WebFontPrewarmer;
 
@@ -106,7 +107,9 @@ class PLATFORM_EXPORT FontCache final {
 
   void Trace(Visitor*) const;
 
-  const SimpleFontData* FallbackFontForCharacter(
+  void ReleaseFontData(const SimpleFontData*);
+
+  scoped_refptr<SimpleFontData> FallbackFontForCharacter(
       const FontDescription&,
       UChar32,
       const SimpleFontData* font_data_to_substitute,
@@ -115,11 +118,14 @@ class PLATFORM_EXPORT FontCache final {
   // Also implemented by the platform.
   void PlatformInit();
 
-  const SimpleFontData* GetFontData(
+  scoped_refptr<SimpleFontData> GetFontData(
       const FontDescription&,
       const AtomicString&,
-      AlternateFontName = AlternateFontName::kAllowAlternate);
-  const SimpleFontData* GetLastResortFallbackFont(const FontDescription&);
+      AlternateFontName = AlternateFontName::kAllowAlternate,
+      ShouldRetain = kRetain);
+  scoped_refptr<SimpleFontData> GetLastResortFallbackFont(const FontDescription&,
+                                                   ShouldRetain = kRetain);
+  SimpleFontData* GetNonRetainedLastResortFallbackFont(const FontDescription&);
 
   // Should be used in determining whether family names listed in font-family:
   // ... are available locally. Only returns true if family name matches.
@@ -212,12 +218,12 @@ class PLATFORM_EXPORT FontCache final {
     return *status_font_family_name_;
   }
 
-  const SimpleFontData* GetFallbackFamilyNameFromHardcodedChoices(
+  scoped_refptr<SimpleFontData> GetFallbackFamilyNameFromHardcodedChoices(
       const FontDescription&,
       UChar32 codepoint,
       FontFallbackPriority fallback_priority);
 
-  const SimpleFontData* GetDWriteFallbackFamily(
+  scoped_refptr<SimpleFontData> GetDWriteFallbackFamily(
       const FontDescription&,
       UChar32 codepoint,
       FontFallbackPriority fallback_priority);
@@ -245,8 +251,9 @@ class PLATFORM_EXPORT FontCache final {
                                   gfx::FallbackFontData*);
 #endif  // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
 
-  const SimpleFontData* FontDataFromFontPlatformData(
+  scoped_refptr<SimpleFontData> FontDataFromFontPlatformData(
       const FontPlatformData*,
+      ShouldRetain = kRetain,
       bool subpixel_ascent_descent = false);
 
   void InvalidateShapeCache();
@@ -254,6 +261,7 @@ class PLATFORM_EXPORT FontCache final {
   static void CrashWithFontInfo(const FontDescription*);
 
   // Memory reporting
+  void DumpFontPlatformDataCache(base::trace_event::ProcessMemoryDump*);
   void DumpShapeResultCache(base::trace_event::ProcessMemoryDump*);
 
   FontFallbackMap& GetFontFallbackMap();
@@ -268,7 +276,7 @@ class PLATFORM_EXPORT FontCache final {
   // elements.
   using Bcp47Vector = WTF::Vector<const char*, 4>;
 
-  const SimpleFontData* PlatformFallbackFontForCharacter(
+  scoped_refptr<SimpleFontData> PlatformFallbackFontForCharacter(
       const FontDescription&,
       UChar32,
       const SimpleFontData* font_data_to_substitute,
@@ -283,26 +291,26 @@ class PLATFORM_EXPORT FontCache final {
   friend class FontGlobalContext;
   FontCache();
 
-  void Purge();
+  void Purge(PurgeSeverity = kPurgeIfNeeded);
 
   void DisablePurging() { purge_prevent_count_++; }
   void EnablePurging() {
     DCHECK(purge_prevent_count_);
     if (!--purge_prevent_count_)
-      Purge();
+      Purge(kPurgeIfNeeded);
   }
 
   // FIXME: This method should eventually be removed.
-  const FontPlatformData* GetFontPlatformData(
+  FontPlatformData* GetFontPlatformData(
       const FontDescription&,
       const FontFaceCreationParams&,
       AlternateFontName = AlternateFontName::kAllowAlternate);
 #if !BUILDFLAG(IS_MAC)
-  const FontPlatformData* SystemFontPlatformData(const FontDescription&);
+  FontPlatformData* SystemFontPlatformData(const FontDescription&);
 #endif  // !BUILDFLAG(IS_MAC)
 
   // These methods are implemented by each platform.
-  const FontPlatformData* CreateFontPlatformData(
+  std::unique_ptr<FontPlatformData> CreateFontPlatformData(
       const FontDescription&,
       const FontFaceCreationParams&,
       float font_size,
@@ -321,8 +329,9 @@ class PLATFORM_EXPORT FontCache final {
 #endif  // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) ||
         // BUILDFLAG(IS_CHROMEOS)
 
-  const SimpleFontData* FallbackOnStandardFontStyle(const FontDescription&,
-                                                    UChar32);
+  scoped_refptr<SimpleFontData> FallbackOnStandardFontStyle(
+      const FontDescription&,
+      UChar32);
 
   // Don't purge if this count is > 0;
   int purge_prevent_count_ = 0;
@@ -356,16 +365,17 @@ class PLATFORM_EXPORT FontCache final {
   uint16_t generation_ = 0;
   bool platform_init_ = false;
   HeapHashSet<WeakMember<FontCacheClient>> font_cache_clients_;
-  FontPlatformDataCache font_platform_data_cache_;
+  std::unique_ptr<FontPlatformDataCache> font_platform_data_cache_;
   HeapHashMap<FallbackListCompositeKey,
               WeakMember<ShapeCache>,
               FallbackListCompositeKeyTraits>
       fallback_list_shaper_cache_;
 
-  FontDataCache font_data_cache_;
+  std::unique_ptr<FontDataCache> font_data_cache_;
 
   Member<FontFallbackMap> font_fallback_map_;
 
+  void PurgePlatformFontDataCache();
   void PurgeFallbackListShaperCache();
 
   friend class SimpleFontData;  // For fontDataFromFontPlatformData
--- a/third_party/blink/renderer/platform/fonts/font_cache_memory_dump_provider.cc
+++ b/third_party/blink/renderer/platform/fonts/font_cache_memory_dump_provider.cc
@@ -21,6 +21,7 @@ bool FontCacheMemoryDumpProvider::OnMemo
   DCHECK(IsMainThread());
   if (auto* context = FontGlobalContext::TryGet()) {
     FontCache& cache = context->GetFontCache();
+    cache.DumpFontPlatformDataCache(memory_dump);
     cache.DumpShapeResultCache(memory_dump);
   }
   return true;
--- a/third_party/blink/renderer/platform/fonts/font_custom_platform_data.cc
+++ b/third_party/blink/renderer/platform/fonts/font_custom_platform_data.cc
@@ -103,7 +103,7 @@ FontCustomPlatformData::~FontCustomPlatf
   }
 }
 
-const FontPlatformData* FontCustomPlatformData::GetFontPlatformData(
+FontPlatformData FontCustomPlatformData::GetFontPlatformData(
     float size,
     float adjusted_specified_size,
     bool bold,
@@ -276,11 +276,10 @@ const FontPlatformData* FontCustomPlatfo
       return_typeface = palette_typeface;
     }
   }
-  return MakeGarbageCollected<FontPlatformData>(
-      std::move(return_typeface), std::string(), size,
-      synthetic_bold && !base_typeface_->isBold(),
-      synthetic_italic && !base_typeface_->isItalic(), text_rendering,
-      resolved_font_features, orientation);
+  return FontPlatformData(std::move(return_typeface), std::string(), size,
+                          synthetic_bold && !base_typeface_->isBold(),
+                          synthetic_italic && !base_typeface_->isItalic(),
+                          text_rendering, resolved_font_features, orientation);
 }
 
 Vector<VariationAxis> FontCustomPlatformData::GetVariationAxes() const {
--- a/third_party/blink/renderer/platform/fonts/font_custom_platform_data.h
+++ b/third_party/blink/renderer/platform/fonts/font_custom_platform_data.h
@@ -68,7 +68,7 @@ class PLATFORM_EXPORT FontCustomPlatform
   // adjusted_specified_size should come from AdjustedSpecifiedSize() of
   // FontDescription. The latter is needed for correctly applying
   // font-optical-sizing: auto; independent of zoom level.
-  const FontPlatformData* GetFontPlatformData(
+  FontPlatformData GetFontPlatformData(
       float size,
       float adjusted_specified_size,
       bool bold,
--- /dev/null
+++ b/third_party/blink/renderer/platform/fonts/font_data.cc
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "third_party/blink/renderer/platform/fonts/font_data.h"
+
+namespace blink {
+
+FontData::~FontData() = default;
+
+}  // namespace blink
--- a/third_party/blink/renderer/platform/fonts/font_data.h
+++ b/third_party/blink/renderer/platform/fonts/font_data.h
@@ -27,24 +27,23 @@
 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_DATA_H_
 
 #include "base/memory/scoped_refptr.h"
-#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
 #include "third_party/blink/renderer/platform/wtf/forward.h"
 #include "third_party/blink/renderer/platform/wtf/text/wtf_uchar.h"
+#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"
 
 namespace blink {
 
 class SimpleFontData;
 
-class PLATFORM_EXPORT FontData : public GarbageCollected<FontData> {
+class PLATFORM_EXPORT FontData : public RefCounted<FontData> {
  public:
   FontData() = default;
   FontData(const FontData&) = delete;
   FontData& operator=(const FontData&) = delete;
-  virtual ~FontData() = default;
 
-  virtual void Trace(Visitor*) const {}
+  virtual ~FontData();
 
   virtual const SimpleFontData* FontDataForCharacter(UChar32) const = 0;
   virtual bool IsCustomFont() const = 0;
--- a/third_party/blink/renderer/platform/fonts/font_data_cache.cc
+++ b/third_party/blink/renderer/platform/fonts/font_data_cache.cc
@@ -36,8 +36,23 @@
 
 namespace blink {
 
-const SimpleFontData* FontDataCache::Get(const FontPlatformData* platform_data,
-                                         bool subpixel_ascent_descent) {
+#if !BUILDFLAG(IS_ANDROID)
+const unsigned kCMaxInactiveFontData = 250;
+const unsigned kCTargetInactiveFontData = 200;
+#else
+const unsigned kCMaxInactiveFontData = 225;
+const unsigned kCTargetInactiveFontData = 200;
+#endif
+
+// static
+std::unique_ptr<FontDataCache> FontDataCache::Create() {
+  return std::make_unique<FontDataCache>();
+}
+
+scoped_refptr<SimpleFontData> FontDataCache::Get(
+    const FontPlatformData* platform_data,
+    ShouldRetain should_retain,
+    bool subpixel_ascent_descent) {
   if (!platform_data)
     return nullptr;
 
@@ -50,12 +65,98 @@ const SimpleFontData* FontDataCache::Get
     return nullptr;
   }
 
-  auto add_result = cache_.insert(platform_data, nullptr);
-  if (add_result.is_new_entry) {
-    add_result.stored_value->value = MakeGarbageCollected<SimpleFontData>(
-        platform_data, nullptr, subpixel_ascent_descent);
+  Cache::iterator result = cache_.find(platform_data);
+  if (result == cache_.end()) {
+    std::pair<scoped_refptr<SimpleFontData>, unsigned> new_value(
+        SimpleFontData::Create(*platform_data, nullptr,
+                               subpixel_ascent_descent),
+        should_retain == kRetain ? 1 : 0);
+    // The new SimpleFontData takes a copy of the incoming FontPlatformData
+    // object. The incoming key may be temporary. So, for cache storage, take
+    // the address of the newly created FontPlatformData that is copied an owned
+    // by SimpleFontData.
+    cache_.Set(&new_value.first->PlatformData(), new_value);
+    if (should_retain == kDoNotRetain)
+      inactive_font_data_.insert(new_value.first);
+    return std::move(new_value.first);
+  }
+
+  if (!result.Get()->value.second) {
+    DCHECK(inactive_font_data_.Contains(result.Get()->value.first));
+    inactive_font_data_.erase(result.Get()->value.first);
+  }
+
+  if (should_retain == kRetain) {
+    result.Get()->value.second++;
+  } else if (!result.Get()->value.second) {
+    // If shouldRetain is DoNotRetain and count is 0, we want to remove the
+    // fontData from m_inactiveFontData (above) and re-add here to update LRU
+    // position.
+    inactive_font_data_.insert(result.Get()->value.first);
+  }
+
+  return result.Get()->value.first;
+}
+
+bool FontDataCache::Contains(const FontPlatformData* font_platform_data) const {
+  return cache_.Contains(font_platform_data);
+}
+
+void FontDataCache::Release(const SimpleFontData* font_data) {
+  DCHECK(!font_data->IsCustomFont());
+
+  Cache::iterator it = cache_.find(&(font_data->PlatformData()));
+  if (it == cache_.end())
+    return;
+
+  DCHECK(it->value.second);
+  if (!--it->value.second)
+    inactive_font_data_.insert(it->value.first);
+}
+
+bool FontDataCache::Purge(PurgeSeverity purge_severity) {
+  if (purge_severity == kForcePurge)
+    return PurgeLeastRecentlyUsed(INT_MAX);
+
+  if (inactive_font_data_.size() > kCMaxInactiveFontData)
+    return PurgeLeastRecentlyUsed(inactive_font_data_.size() -
+                                  kCTargetInactiveFontData);
+
+  return false;
+}
+
+bool FontDataCache::PurgeLeastRecentlyUsed(int count) {
+  // Guard against reentry when e.g. a deleted FontData releases its small caps
+  // FontData.
+  if (is_purging_)
+    return false;
+
+  base::AutoReset<bool> is_purging_auto_reset(&is_purging_, true);
+
+  Vector<scoped_refptr<SimpleFontData>, 20> font_data_to_delete;
+  auto end = inactive_font_data_.end();
+  auto it = inactive_font_data_.begin();
+  for (int i = 0; i < count && it != end; ++it, ++i) {
+    const scoped_refptr<SimpleFontData>& font_data = *it;
+    cache_.erase(&(font_data->PlatformData()));
+    // We should not delete SimpleFontData here because deletion can modify
+    // m_inactiveFontData. See http://trac.webkit.org/changeset/44011
+    font_data_to_delete.push_back(font_data);
+  }
+
+  if (it == end) {
+    // Removed everything
+    inactive_font_data_.clear();
+  } else {
+    for (int i = 0; i < count; ++i)
+      inactive_font_data_.erase(inactive_font_data_.begin());
   }
-  return add_result.stored_value->value;
+
+  bool did_work = font_data_to_delete.size();
+
+  font_data_to_delete.clear();
+
+  return did_work;
 }
 
 }  // namespace blink
--- a/third_party/blink/renderer/platform/fonts/font_data_cache.h
+++ b/third_party/blink/renderer/platform/fonts/font_data_cache.h
@@ -33,10 +33,14 @@
 
 #include "third_party/blink/renderer/platform/fonts/font_platform_data.h"
 #include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
+#include "third_party/blink/renderer/platform/wtf/hash_map.h"
+#include "third_party/blink/renderer/platform/wtf/linked_hash_set.h"
 
 namespace blink {
 
+enum ShouldRetain { kRetain, kDoNotRetain };
+enum PurgeSeverity { kPurgeIfNeeded, kForcePurge };
+
 struct FontDataCacheKeyHashTraits : GenericHashTraits<const FontPlatformData*> {
   STATIC_ONLY(FontDataCacheKeyHashTraits);
   static unsigned GetHash(const FontPlatformData* platform_data) {
@@ -51,24 +55,36 @@ struct FontDataCacheKeyHashTraits : Gene
 };
 
 class FontDataCache final {
-  DISALLOW_NEW();
+  USING_FAST_MALLOC(FontDataCache);
 
  public:
+  static std::unique_ptr<FontDataCache> Create();
+
   FontDataCache() = default;
   FontDataCache(const FontDataCache&) = delete;
   FontDataCache& operator=(const FontDataCache&) = delete;
 
-  void Trace(Visitor* visitor) const { visitor->Trace(cache_); }
-
-  const SimpleFontData* Get(const FontPlatformData*,
-                            bool subpixel_ascent_descent = false);
-  void Clear() { cache_.clear(); }
+  scoped_refptr<SimpleFontData> Get(const FontPlatformData*,
+                                    ShouldRetain = kRetain,
+                                    bool subpixel_ascent_descent = false);
+  bool Contains(const FontPlatformData*) const;
+  void Release(const SimpleFontData*);
+
+  // Purges items in FontDataCache according to provided severity.
+  // Returns true if any removal of cache items actually occurred.
+  bool Purge(PurgeSeverity);
 
  private:
-  HeapHashMap<Member<const FontPlatformData>,
-              WeakMember<const SimpleFontData>,
-              FontDataCacheKeyHashTraits>
-      cache_;
+  bool PurgeLeastRecentlyUsed(int count);
+
+  typedef HashMap<const FontPlatformData*,
+                  std::pair<scoped_refptr<SimpleFontData>, unsigned>,
+                  FontDataCacheKeyHashTraits>
+      Cache;
+
+  Cache cache_;
+  LinkedHashSet<scoped_refptr<SimpleFontData>> inactive_font_data_;
+  bool is_purging_ = false;
 };
 
 }  // namespace blink
--- a/third_party/blink/renderer/platform/fonts/font_data_for_range_set.cc
+++ b/third_party/blink/renderer/platform/fonts/font_data_for_range_set.cc
@@ -13,4 +13,10 @@ FontDataForRangeSet::FontDataForRangeSet
   range_set_ = other.range_set_;
 }
 
+FontDataForRangeSetFromCache::~FontDataForRangeSetFromCache() {
+  if (font_data_ && !font_data_->IsCustomFont()) {
+    FontCache::Get().ReleaseFontData(font_data_.get());
+  }
+}
+
 }  // namespace blink
--- a/third_party/blink/renderer/platform/fonts/font_data_for_range_set.h
+++ b/third_party/blink/renderer/platform/fonts/font_data_for_range_set.h
@@ -37,19 +37,17 @@ namespace blink {
 class SimpleFontData;
 
 class PLATFORM_EXPORT FontDataForRangeSet
-    : public GarbageCollected<FontDataForRangeSet> {
+    : public RefCounted<FontDataForRangeSet> {
  public:
   explicit FontDataForRangeSet(
-      const SimpleFontData* font_data = nullptr,
+      scoped_refptr<SimpleFontData> font_data = nullptr,
       scoped_refptr<UnicodeRangeSet> range_set = nullptr)
-      : font_data_(font_data), range_set_(std::move(range_set)) {}
+      : font_data_(std::move(font_data)), range_set_(std::move(range_set)) {}
 
   FontDataForRangeSet(const FontDataForRangeSet& other);
 
   virtual ~FontDataForRangeSet() = default;
 
-  void Trace(Visitor* visitor) const { visitor->Trace(font_data_); }
-
   bool Contains(UChar32 test_char) const {
     return !range_set_ || range_set_->Contains(test_char);
   }
@@ -57,8 +55,8 @@ class PLATFORM_EXPORT FontDataForRangeSe
     return !range_set_ || range_set_->IsEntireRange();
   }
   UnicodeRangeSet* Ranges() const { return range_set_.get(); }
-  bool HasFontData() const { return font_data_; }
-  const SimpleFontData* FontData() const { return font_data_.Get(); }
+  bool HasFontData() const { return font_data_.get(); }
+  const SimpleFontData* FontData() const { return font_data_.get(); }
 
   // TODO(xiaochengh): |FontData::IsLoadingFallback()| returns true if the
   // FontData is a pending custom font. We should rename it for better clarity.
@@ -71,10 +69,20 @@ class PLATFORM_EXPORT FontDataForRangeSe
   }
 
  protected:
-  Member<const SimpleFontData> font_data_;
+  scoped_refptr<SimpleFontData> font_data_;
   scoped_refptr<UnicodeRangeSet> range_set_;
 };
 
+class PLATFORM_EXPORT FontDataForRangeSetFromCache
+    : public FontDataForRangeSet {
+ public:
+  explicit FontDataForRangeSetFromCache(
+      scoped_refptr<SimpleFontData> font_data,
+      scoped_refptr<UnicodeRangeSet> range_set = nullptr)
+      : FontDataForRangeSet(std::move(font_data), std::move(range_set)) {}
+  ~FontDataForRangeSetFromCache() override;
+};
+
 }  // namespace blink
 
 #endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_DATA_FOR_RANGE_SET_H_
--- a/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc
+++ b/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc
@@ -60,8 +60,8 @@ void FontFallbackIterator::WillUseRange(
   selector->WillUseRange(font_description_, family, range_set);
 }
 
-FontDataForRangeSet* FontFallbackIterator::UniqueOrNext(
-    FontDataForRangeSet* candidate,
+scoped_refptr<FontDataForRangeSet> FontFallbackIterator::UniqueOrNext(
+    scoped_refptr<FontDataForRangeSet> candidate,
     const Vector<UChar32>& hint_list) {
   if (!candidate->HasFontData())
     return Next(hint_list);
@@ -104,18 +104,18 @@ bool FontFallbackIterator::NeedsHintList
   return font_data->IsSegmented();
 }
 
-FontDataForRangeSet* FontFallbackIterator::Next(
+scoped_refptr<FontDataForRangeSet> FontFallbackIterator::Next(
     const Vector<UChar32>& hint_list) {
   if (fallback_stage_ == kOutOfLuck)
-    return MakeGarbageCollected<FontDataForRangeSet>();
+    return base::AdoptRef(new FontDataForRangeSet());
 
   if (fallback_stage_ == kFallbackPriorityFonts) {
     // Only try one fallback priority font,
     // then proceed to regular system fallback.
     fallback_stage_ = kSystemFonts;
-    FontDataForRangeSet* fallback_priority_font_range =
-        MakeGarbageCollected<FontDataForRangeSet>(
-            FallbackPriorityFont(hint_list[0]));
+    scoped_refptr<FontDataForRangeSet> fallback_priority_font_range =
+        base::AdoptRef(
+            new FontDataForRangeSet(FallbackPriorityFont(hint_list[0])));
     if (fallback_priority_font_range->HasFontData())
       return UniqueOrNext(std::move(fallback_priority_font_range), hint_list);
     return Next(hint_list);
@@ -123,11 +123,11 @@ FontDataForRangeSet* FontFallbackIterato
 
   if (fallback_stage_ == kSystemFonts) {
     // We've reached pref + system fallback.
-    const SimpleFontData* system_font = UniqueSystemFontForHintList(hint_list);
+    scoped_refptr<SimpleFontData> system_font = UniqueSystemFontForHintList(hint_list);
     if (system_font) {
       // Fallback fonts are not retained in the FontDataCache.
-      return UniqueOrNext(
-          MakeGarbageCollected<FontDataForRangeSet>(system_font), hint_list);
+      return UniqueOrNext(base::AdoptRef(new FontDataForRangeSet(system_font)),
+                          hint_list);
     }
 
     // If we don't have options from the system fallback anymore or had
@@ -137,16 +137,18 @@ FontDataForRangeSet* FontFallbackIterato
     // LastResort font, not just Times or Arial.
     FontCache& font_cache = FontCache::Get();
     fallback_stage_ = kFirstCandidateForNotdefGlyph;
-    const SimpleFontData* last_resort =
-        font_cache.GetLastResortFallbackFont(font_description_);
+    scoped_refptr<SimpleFontData> last_resort =
+        font_cache.GetLastResortFallbackFont(font_description_).get();
 
     if (FontSelector* font_selector = font_fallback_list_->GetFontSelector()) {
-      font_selector->ReportLastResortFallbackFontLookup(font_description_,
-                                                        last_resort);
+      font_selector->ReportLastResortFallbackFontLookup(
+          font_description_,
+          last_resort.get());
     }
 
-    return UniqueOrNext(MakeGarbageCollected<FontDataForRangeSet>(last_resort),
-                        hint_list);
+    return UniqueOrNext(
+        base::AdoptRef(new FontDataForRangeSetFromCache(last_resort)),
+        hint_list);
   }
 
   if (fallback_stage_ == kFirstCandidateForNotdefGlyph) {
@@ -177,13 +179,13 @@ FontDataForRangeSet* FontFallbackIterato
     // Skip forward to the next font family for the next call to next().
     current_font_data_index_++;
     if (!font_data->IsLoading()) {
-      SimpleFontData* non_segmented =
+      scoped_refptr<SimpleFontData> non_segmented =
           const_cast<SimpleFontData*>(To<SimpleFontData>(font_data));
       // The fontData object that we have here is tracked in m_fontList of
       // FontFallbackList and gets released in the font cache when the
       // FontFallbackList is destroyed.
       return UniqueOrNext(
-          MakeGarbageCollected<FontDataForRangeSet>(non_segmented), hint_list);
+          base::AdoptRef(new FontDataForRangeSet(non_segmented)), hint_list);
     }
     return Next(hint_list);
   }
@@ -197,7 +199,7 @@ FontDataForRangeSet* FontFallbackIterato
   }
 
   DCHECK_LT(segmented_face_index_, segmented->NumFaces());
-  FontDataForRangeSet* current_segmented_face =
+  scoped_refptr<FontDataForRangeSet> current_segmented_face =
       segmented->FaceAt(segmented_face_index_);
   segmented_face_index_++;
 
@@ -208,7 +210,7 @@ FontDataForRangeSet* FontFallbackIterato
     current_font_data_index_++;
   }
 
-  if (RangeSetContributesForHint(hint_list, current_segmented_face)) {
+  if (RangeSetContributesForHint(hint_list, current_segmented_face.get())) {
     const SimpleFontData* current_segmented_face_font_data =
         current_segmented_face->FontData();
     if (const CustomFontData* current_segmented_face_custom_font_data =
@@ -222,15 +224,17 @@ FontDataForRangeSet* FontFallbackIterato
   return Next(hint_list);
 }
 
-const SimpleFontData* FontFallbackIterator::FallbackPriorityFont(UChar32 hint) {
-  const SimpleFontData* font_data = FontCache::Get().FallbackFontForCharacter(
-      font_description_, hint,
-      font_fallback_list_->PrimarySimpleFontData(font_description_),
-      font_fallback_priority_);
+scoped_refptr<SimpleFontData> FontFallbackIterator::FallbackPriorityFont(
+    UChar32 hint) {
+  scoped_refptr<SimpleFontData> font_data =
+      FontCache::Get().FallbackFontForCharacter(
+          font_description_, hint,
+          font_fallback_list_->PrimarySimpleFontData(font_description_),
+          font_fallback_priority_);
 
   if (FontSelector* font_selector = font_fallback_list_->GetFontSelector()) {
     font_selector->ReportFontLookupByFallbackCharacter(
-        hint, font_fallback_priority_, font_description_, font_data);
+        hint, font_fallback_priority_, font_description_, font_data.get());
   }
   return font_data;
 }
@@ -255,7 +259,7 @@ static inline unsigned ChooseHintIndex(c
   return 0;
 }
 
-const SimpleFontData* FontFallbackIterator::UniqueSystemFontForHintList(
+scoped_refptr<SimpleFontData> FontFallbackIterator::UniqueSystemFontForHintList(
     const Vector<UChar32>& hint_list) {
   // When we're asked for a fallback for the same characters again, we give up
   // because the shaper must have previously tried shaping with the font
@@ -270,13 +274,13 @@ const SimpleFontData* FontFallbackIterat
     return nullptr;
   previously_asked_for_hint_.insert(hint);
 
-  const SimpleFontData* font_data = font_cache.FallbackFontForCharacter(
+  scoped_refptr<SimpleFontData> font_data = font_cache.FallbackFontForCharacter(
       font_description_, hint,
       font_fallback_list_->PrimarySimpleFontData(font_description_));
 
   if (FontSelector* font_selector = font_fallback_list_->GetFontSelector()) {
     font_selector->ReportFontLookupByFallbackCharacter(
-        hint, FontFallbackPriority::kText, font_description_, font_data);
+        hint, FontFallbackPriority::kText, font_description_, font_data.get());
   }
   return font_data;
 }
--- a/third_party/blink/renderer/platform/fonts/font_fallback_iterator.h
+++ b/third_party/blink/renderer/platform/fonts/font_fallback_iterator.h
@@ -5,13 +5,14 @@
 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_FALLBACK_ITERATOR_H_
 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_FALLBACK_ITERATOR_H_
 
+#include "base/memory/scoped_refptr.h"
 #include "third_party/blink/renderer/platform/fonts/font_data_for_range_set.h"
 #include "third_party/blink/renderer/platform/fonts/font_fallback_priority.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
 #include "third_party/blink/renderer/platform/wtf/hash_set.h"
 #include "third_party/blink/renderer/platform/wtf/ref_counted.h"
 #include "third_party/blink/renderer/platform/wtf/text/wtf_uchar.h"
+#include "third_party/blink/renderer/platform/wtf/vector.h"
 
 namespace blink {
 
@@ -48,7 +48,7 @@
   // Some system fallback APIs (Windows, Android) require a character, or a
   // portion of the string to be passed.  On Mac and Linux, we get a list of
   // fonts without passing in characters.
-  FontDataForRangeSet* Next(const Vector<UChar32>& hint_list);
+  scoped_refptr<FontDataForRangeSet> Next(const Vector<UChar32>& hint_list);
 
   void Reset();
 
@@ -50,11 +51,12 @@ class FontFallbackIterator {
   bool AlreadyLoadingRangeForHintChar(UChar32 hint_char);
   void WillUseRange(const AtomicString& family, const FontDataForRangeSet&);
 
-  FontDataForRangeSet* UniqueOrNext(FontDataForRangeSet* candidate,
-                                    const Vector<UChar32>& hint_list);
+  scoped_refptr<FontDataForRangeSet> UniqueOrNext(
+      scoped_refptr<FontDataForRangeSet> candidate,
+      const Vector<UChar32>& hint_list);
 
-  const SimpleFontData* FallbackPriorityFont(UChar32 hint);
-  const SimpleFontData* UniqueSystemFontForHintList(
+  scoped_refptr<SimpleFontData> FallbackPriorityFont(UChar32 hint);
+  scoped_refptr<SimpleFontData> UniqueSystemFontForHintList(
       const Vector<UChar32>& hint_list);
 
   const FontDescription& font_description_;
@@ -82,8 +84,8 @@ class FontFallbackIterator {
   // candidate to be used for rendering the .notdef glyph, and set HasNext() to
   // false.
   HashSet<uint32_t> unique_font_data_for_range_sets_returned_;
-  FontDataForRangeSet* first_candidate_ = nullptr;
-  HeapVector<Member<FontDataForRangeSet>> tracked_loading_range_sets_;
+  scoped_refptr<FontDataForRangeSet> first_candidate_;
+  Vector<scoped_refptr<FontDataForRangeSet>> tracked_loading_range_sets_;
   FontFallbackPriority font_fallback_priority_;
 };
 
--- a/third_party/blink/renderer/platform/fonts/font_fallback_list.cc
+++ b/third_party/blink/renderer/platform/fonts/font_fallback_list.cc
@@ -52,9 +52,17 @@ FontFallbackList::FontFallbackList(FontS
       is_invalid_(false),
       nullify_primary_font_data_for_test_(false) {}
 
+FontFallbackList::~FontFallbackList() {
+  unsigned num_fonts = font_list_.size();
+  for (unsigned i = 0; i < num_fonts; ++i) {
+    if (!font_list_[i]->IsCustomFont()) {
+      DCHECK(!font_list_[i]->IsSegmented());
+      FontCache::Get().ReleaseFontData(To<SimpleFontData>(font_list_[i].get()));
+    }
+  }
+}
+
 void FontFallbackList::Trace(Visitor* visitor) const {
-  visitor->Trace(font_list_);
-  visitor->Trace(cached_primary_simple_font_data_);
   visitor->Trace(font_selector_);
   visitor->Trace(ng_shape_cache_);
   visitor->Trace(shape_cache_);
@@ -98,8 +106,8 @@ const SimpleFontData* FontFallbackList::
         return font_data->FontDataForCharacter(kSpaceCharacter);
 
       FontCache& font_cache = FontCache::Get();
-      const SimpleFontData* last_resort_fallback =
-          font_cache.GetLastResortFallbackFont(font_description);
+      SimpleFontData* last_resort_fallback =
+          font_cache.GetLastResortFallbackFont(font_description).get();
       DCHECK(last_resort_fallback);
       return last_resort_fallback;
     }
@@ -137,7 +145,7 @@ const SimpleFontData* FontFallbackList::
   }
 }
 
-const FontData* FontFallbackList::GetFontData(
+scoped_refptr<FontData> FontFallbackList::GetFontData(
     const FontDescription& font_description) {
   const FontFamily* curr_family = &font_description.Family();
   for (int i = 0; curr_family && i < family_index_; i++)
@@ -148,7 +156,7 @@ const FontData* FontFallbackList::GetFon
     if (!font_selector_) {
       // Don't query system fonts for empty font family name.
       if (!curr_family->FamilyName().empty()) {
-        if (auto* result = FontCache::Get().GetFontData(
+        if (auto result = FontCache::Get().GetFontData(
                 font_description, curr_family->FamilyName())) {
           return result;
         }
@@ -156,7 +164,7 @@ const FontData* FontFallbackList::GetFon
       continue;
     }
 
-    const FontData* result =
+    scoped_refptr<FontData> result =
         font_selector_->GetFontData(font_description, *curr_family);
     // Don't query system fonts for empty font family name.
     if (!result && !curr_family->FamilyName().empty()) {
@@ -164,7 +172,7 @@ const FontData* FontFallbackList::GetFon
                                             curr_family->FamilyName());
       font_selector_->ReportFontLookupByUniqueOrFamilyName(
           curr_family->FamilyName(), font_description,
-          DynamicTo<SimpleFontData>(result));
+          DynamicTo<SimpleFontData>(result.get()));
     }
     if (result) {
       font_selector_->ReportSuccessfulFontFamilyMatch(
@@ -181,18 +189,18 @@ const FontData* FontFallbackList::GetFon
     FontFamily font_family;
     font_family.SetFamily(font_family_names::kWebkitStandard,
                           FontFamily::Type::kGenericFamily);
-    if (const FontData* data =
+    if (scoped_refptr<FontData> data =
             font_selector_->GetFontData(font_description, font_family)) {
       return data;
     }
   }
 
   // Still no result. Hand back our last resort fallback font.
-  auto* last_resort =
+  auto last_resort =
       FontCache::Get().GetLastResortFallbackFont(font_description);
   if (font_selector_) {
     font_selector_->ReportLastResortFallbackFontLookup(font_description,
-                                                       last_resort);
+                                                       last_resort.get());
   }
   return last_resort;
 }
@@ -202,7 +210,7 @@ const FontData* FontFallbackList::FontDa
     unsigned realized_font_index) {
   // This fallback font is already in our list.
   if (realized_font_index < font_list_.size())
-    return font_list_[realized_font_index].Get();
+    return font_list_[realized_font_index].get();
 
   // Make sure we're not passing in some crazy value here.
   DCHECK_EQ(realized_font_index, font_list_.size());
@@ -216,7 +224,7 @@ const FontData* FontFallbackList::FontDa
   // the same spot in the list twice.  GetFontData will adjust our
   // |family_index_| as it scans for the right font to make.
   DCHECK_EQ(FontCache::Get().Generation(), generation_);
-  const FontData* result = GetFontData(font_description);
+  scoped_refptr<FontData> result = GetFontData(font_description);
   if (result) {
     font_list_.push_back(result);
     if (result->IsLoadingFallback())
@@ -224,7 +232,7 @@ const FontData* FontFallbackList::FontDa
     if (result->IsCustomFont())
       has_custom_font_ = true;
   }
-  return result;
+  return result.get();
 }
 
 bool FontFallbackList::ComputeCanShapeWordByWord(
--- a/third_party/blink/renderer/platform/fonts/font_fallback_list.h
+++ b/third_party/blink/renderer/platform/fonts/font_fallback_list.h
@@ -49,6 +49,7 @@ class PLATFORM_EXPORT FontFallbackList
 
   FontFallbackList(const FontFallbackList&) = delete;
   FontFallbackList& operator=(const FontFallbackList&) = delete;
+  ~FontFallbackList();
 
   void Trace(Visitor*) const;
 
@@ -116,7 +117,7 @@ class PLATFORM_EXPORT FontFallbackList
   bool HasCustomFont() const { return has_custom_font_; }
 
  private:
-  const FontData* GetFontData(const FontDescription&);
+  scoped_refptr<FontData> GetFontData(const FontDescription&);
 
   const SimpleFontData* DeterminePrimarySimpleFontData(const FontDescription&);
   const SimpleFontData* DeterminePrimarySimpleFontDataCore(
@@ -124,8 +125,8 @@ class PLATFORM_EXPORT FontFallbackList
 
   bool ComputeCanShapeWordByWord(const FontDescription&);
 
-  HeapVector<Member<const FontData>, 1> font_list_;
-  Member<const SimpleFontData> cached_primary_simple_font_data_ = nullptr;
+  Vector<scoped_refptr<FontData>, 1> font_list_;
+  const SimpleFontData* cached_primary_simple_font_data_ = nullptr;
   const Member<FontSelector> font_selector_;
   int family_index_ = 0;
   const uint16_t generation_;
--- a/third_party/blink/renderer/platform/fonts/font_platform_data.cc
+++ b/third_party/blink/renderer/platform/fonts/font_platform_data.cc
@@ -158,10 +158,6 @@ FontPlatformData::FontPlatformData(sk_sp
 
 FontPlatformData::~FontPlatformData() = default;
 
-void FontPlatformData::Trace(Visitor* visitor) const {
-  visitor->Trace(harfbuzz_face_);
-}
-
 #if BUILDFLAG(IS_MAC)
 CTFontRef FontPlatformData::CtFont() const {
   return SkTypeface_GetCTFontRef(typeface_.get());
@@ -213,10 +209,11 @@ SkTypeface* FontPlatformData::Typeface()
 
 HarfBuzzFace* FontPlatformData::GetHarfBuzzFace() const {
   if (!harfbuzz_face_) {
-    harfbuzz_face_ = MakeGarbageCollected<HarfBuzzFace>(this, UniqueID());
+    harfbuzz_face_ =
+        HarfBuzzFace::Create(const_cast<FontPlatformData*>(this), UniqueID());
   }
 
-  return harfbuzz_face_.Get();
+  return harfbuzz_face_.get();
 }
 
 bool FontPlatformData::HasSpaceInLigaturesOrKerning(
@@ -246,7 +243,7 @@ unsigned FontPlatformData::GetHash() con
 }
 
 #if !BUILDFLAG(IS_MAC)
-bool FontPlatformData::FontContainsCharacter(UChar32 character) const {
+bool FontPlatformData::FontContainsCharacter(UChar32 character) {
   return CreateSkFont().unicharToGlyph(character);
 }
 #endif
--- a/third_party/blink/renderer/platform/fonts/font_platform_data.h
+++ b/third_party/blink/renderer/platform/fonts/font_platform_data.h
@@ -39,8 +39,6 @@
 #include "third_party/blink/renderer/platform/fonts/font_orientation.h"
 #include "third_party/blink/renderer/platform/fonts/resolved_font_features.h"
 #include "third_party/blink/renderer/platform/fonts/small_caps_iterator.h"
-#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
-#include "third_party/blink/renderer/platform/heap/member.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
 #include "third_party/blink/renderer/platform/wtf/forward.h"
@@ -61,8 +59,9 @@ namespace blink {
 class HarfBuzzFace;
 class OpenTypeVerticalData;
 
-class PLATFORM_EXPORT FontPlatformData
-    : public GarbageCollected<FontPlatformData> {
+class PLATFORM_EXPORT FontPlatformData {
+  USING_FAST_MALLOC(FontPlatformData);
+
  public:
   // Used for deleted values in the font cache's hash tables. The hash table
   // will create us with this structure, and it will compare other values
@@ -83,8 +82,6 @@ class PLATFORM_EXPORT FontPlatformData
                    FontOrientation = FontOrientation::kHorizontal);
   ~FontPlatformData();
 
-  void Trace(Visitor*) const;
-
 #if BUILDFLAG(IS_MAC)
   // Returns nullptr for FreeType backed SkTypefaces, compare
   // FontCustomPlatformData, which are used for variable fonts on Mac OS
@@ -129,7 +126,7 @@ class PLATFORM_EXPORT FontPlatformData
 
   bool IsHashTableDeletedValue() const { return is_hash_table_deleted_value_; }
 #if !BUILDFLAG(IS_MAC)
-  bool FontContainsCharacter(UChar32 character) const;
+  bool FontContainsCharacter(UChar32 character);
 #endif
 
 #if !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_MAC)
@@ -185,7 +182,7 @@ class PLATFORM_EXPORT FontPlatformData
   WebFontRenderStyle style_;
 #endif
 
-  mutable Member<HarfBuzzFace> harfbuzz_face_;
+  mutable scoped_refptr<HarfBuzzFace> harfbuzz_face_;
   bool is_hash_table_deleted_value_ = false;
 };
 
--- a/third_party/blink/renderer/platform/fonts/font_platform_data_cache.cc
+++ b/third_party/blink/renderer/platform/fonts/font_platform_data_cache.cc
@@ -38,13 +38,20 @@
 
 namespace blink {
 
+// static
+std::unique_ptr<FontPlatformDataCache> FontPlatformDataCache::Create() {
+  return std::make_unique<FontPlatformDataCache>();
+}
+
 FontPlatformDataCache::FontPlatformDataCache()
     : font_size_limit_(std::nextafter(
           (static_cast<float>(std::numeric_limits<unsigned>::max()) - 2.f) /
               static_cast<float>(blink::FontCacheKey::PrecisionMultiplier()),
           0.f)) {}
 
-const FontPlatformData* FontPlatformDataCache::GetOrCreateFontPlatformData(
+FontPlatformDataCache::~FontPlatformDataCache() = default;
+
+FontPlatformData* FontPlatformDataCache::GetOrCreateFontPlatformData(
     FontCache* font_cache,
     const FontDescription& font_description,
     const FontFaceCreationParams& creation_params,
@@ -60,13 +67,15 @@ const FontPlatformData* FontPlatformData
 
   auto it = map_.find(key);
   if (it != map_.end()) {
-    return it->value.Get();
+    return it->value.get();
   }
 
-  if (const FontPlatformData* result = font_cache->CreateFontPlatformData(
-          font_description, creation_params, size, alternate_font_name)) {
-    map_.insert(key, result);
-    return result;
+  if (std::unique_ptr<FontPlatformData> result =
+          font_cache->CreateFontPlatformData(font_description, creation_params,
+                                             size, alternate_font_name)) {
+    FontPlatformData* result_ptr = result.get();
+    map_.insert(key, std::move(result));
+    return result_ptr;
   }
 
   if (alternate_font_name != AlternateFontName::kAllowAlternate ||
@@ -82,16 +91,35 @@ const FontPlatformData* FontPlatformData
     return nullptr;
 
   FontFaceCreationParams create_by_alternate_family(alternate_name);
-  if (const FontPlatformData* result = GetOrCreateFontPlatformData(
+  if (FontPlatformData* result = GetOrCreateFontPlatformData(
           font_cache, font_description, create_by_alternate_family,
           AlternateFontName::kNoAlternate)) {
     // Cache the platform_data under the old name.
     // "accessibility/font-changed.html" reaches here.
-    map_.insert(key, result);
+    map_.insert(key, std::make_unique<FontPlatformData>(*result));
     return result;
   }
 
   return nullptr;
 }
 
+size_t FontPlatformDataCache::ByteSize() const {
+  return map_.size() * sizeof(std::unique_ptr<FontPlatformData>);
+}
+
+void FontPlatformDataCache::Clear() {
+  map_.clear();
+}
+
+void FontPlatformDataCache::Purge(const FontDataCache& font_data_cache) {
+  Vector<FontCacheKey> keys_to_remove;
+  keys_to_remove.ReserveInitialCapacity(map_.size());
+  for (auto& entry : map_) {
+    if (entry.value && !font_data_cache.Contains(entry.value.get())) {
+      keys_to_remove.push_back(entry.key);
+    }
+  }
+  map_.RemoveAll(keys_to_remove);
+}
+
 }  // namespace blink
--- a/third_party/blink/renderer/platform/fonts/font_platform_data_cache.h
+++ b/third_party/blink/renderer/platform/fonts/font_platform_data_cache.h
@@ -31,13 +31,13 @@
 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_PLATFORM_DATA_CACHE_H_
 
 #include "third_party/blink/renderer/platform/fonts/font_cache_key.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
-#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
+#include "third_party/blink/renderer/platform/wtf/hash_map.h"
 
 namespace blink {
 
 enum class AlternateFontName;
 class FontCache;
+class FontDataCache;
 class FontDescription;
 class FontFaceCreationParams;
 class FontPlatformData;
@@ -45,23 +45,30 @@ class FontPlatformData;
 // `FontPlatformDataCache` is the shared cache mapping from `FontDescription`
 // to `FontPlatformData`.
 class FontPlatformDataCache final {
-  DISALLOW_NEW();
-
  public:
+  static std::unique_ptr<FontPlatformDataCache> Create();
+
   FontPlatformDataCache();
+  ~FontPlatformDataCache();
+
+  FontPlatformDataCache(const FontPlatformDataCache&) = delete;
+  FontPlatformDataCache(FontPlatformDataCache&&) = delete;
 
-  void Trace(Visitor* visitor) const { visitor->Trace(map_); }
+  FontPlatformDataCache operator=(const FontPlatformDataCache&) = delete;
+  FontPlatformDataCache operator=(FontPlatformDataCache&&) = delete;
 
-  const FontPlatformData* GetOrCreateFontPlatformData(
+  FontPlatformData* GetOrCreateFontPlatformData(
       FontCache* font_cache,
       const FontDescription& font_description,
       const FontFaceCreationParams& creation_params,
       AlternateFontName alternate_font_name);
 
-  void Clear() { map_.clear(); }
+  size_t ByteSize() const;
+  void Clear();
+  void Purge(const FontDataCache& font_data_cache);
 
  private:
-  HeapHashMap<FontCacheKey, WeakMember<const FontPlatformData>> map_;
+  HashMap<FontCacheKey, std::unique_ptr<FontPlatformData>> map_;
 
   // A maximum float value to which we limit incoming font sizes. This is the
   // smallest float so that multiplying it by
--- a/third_party/blink/renderer/platform/fonts/font_selector.h
+++ b/third_party/blink/renderer/platform/fonts/font_selector.h
@@ -53,8 +53,8 @@ class UseCounter;
 class PLATFORM_EXPORT FontSelector : public FontCacheClient {
  public:
   ~FontSelector() override = default;
-  virtual const FontData* GetFontData(const FontDescription&,
-                                      const FontFamily&) = 0;
+  virtual scoped_refptr<FontData> GetFontData(const FontDescription&,
+                                              const FontFamily&) = 0;
 
   // TODO(crbug.com/542629): The String variant of this method should be
   // replaced with a better approach, now that we only have complex text.
@@ -92,7 +92,7 @@ class PLATFORM_EXPORT FontSelector : pub
   virtual void ReportFontLookupByUniqueOrFamilyName(
       const AtomicString& name,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) = 0;
+      scoped_refptr<SimpleFontData> resulting_font_data) = 0;
 
   // Called whenever a page attempts to find a local font based on a name. This
   // only includes lookups where the name is allowed to match PostScript names
@@ -100,7 +100,7 @@ class PLATFORM_EXPORT FontSelector : pub
   virtual void ReportFontLookupByUniqueNameOnly(
       const AtomicString& name,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data,
+      scoped_refptr<SimpleFontData> resulting_font_data,
       bool is_loading_fallback = false) = 0;
 
   // Called whenever a page attempts to find a local font based on a fallback
@@ -109,12 +109,12 @@ class PLATFORM_EXPORT FontSelector : pub
       UChar32 fallback_character,
       FontFallbackPriority fallback_priority,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) = 0;
+      scoped_refptr<SimpleFontData> resulting_font_data) = 0;
 
   // Called whenever a page attempts to find a last-resort font.
   virtual void ReportLastResortFallbackFontLookup(
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) = 0;
+      scoped_refptr<SimpleFontData> resulting_font_data) = 0;
 
   virtual void ReportNotDefGlyph() const = 0;
 
--- a/third_party/blink/renderer/platform/fonts/fuchsia/font_cache_fuchsia.cc
+++ b/third_party/blink/renderer/platform/fonts/fuchsia/font_cache_fuchsia.cc
@@ -45,7 +45,7 @@ void FontCache::SetSystemFontFamily(cons
   MutableSystemFontFamily() = family_name;
 }
 
-const SimpleFontData* FontCache::PlatformFallbackFontForCharacter(
+scoped_refptr<SimpleFontData> FontCache::PlatformFallbackFontForCharacter(
     const FontDescription& font_description,
     UChar32 character,
     const SimpleFontData* font_data_to_substitute,
@@ -67,12 +67,12 @@ const SimpleFontData* FontCache::Platfor
                           !typeface->isItalic() &&
                           font_description.SyntheticItalicAllowed();
 
-  const auto* font_data = MakeGarbageCollected<FontPlatformData>(
+  auto font_data = std::make_unique<FontPlatformData>(
       std::move(typeface), std::string(), font_description.EffectiveFontSize(),
       synthetic_bold, synthetic_italic, font_description.TextRendering(),
       ResolvedFontFeatures(), font_description.Orientation());
 
-  return FontDataFromFontPlatformData(font_data);
+  return FontDataFromFontPlatformData(font_data.get(), kDoNotRetain);
 }
 
 }  // namespace blink
--- a/third_party/blink/renderer/platform/fonts/linux/font_cache_linux.cc
+++ b/third_party/blink/renderer/platform/fonts/linux/font_cache_linux.cc
@@ -62,7 +62,7 @@ bool FontCache::GetFontForCharacter(UCha
   }
 }
 
-const SimpleFontData* FontCache::PlatformFallbackFontForCharacter(
+scoped_refptr<SimpleFontData> FontCache::PlatformFallbackFontForCharacter(
     const FontDescription& font_description,
     UChar32 c,
     const SimpleFontData*,
@@ -77,9 +77,11 @@ const SimpleFontData* FontCache::Platfor
     AtomicString family_name = GetFamilyNameForCharacter(
         font_manager_.get(), c, font_description, nullptr, fallback_priority);
     if (family_name.empty())
-      return GetLastResortFallbackFont(font_description);
-    return FontDataFromFontPlatformData(GetFontPlatformData(
-        font_description, FontFaceCreationParams(family_name)));
+      return GetLastResortFallbackFont(font_description, kDoNotRetain);
+    return FontDataFromFontPlatformData(
+        GetFontPlatformData(font_description,
+                            FontFaceCreationParams(family_name)),
+        kDoNotRetain);
   }
 
   if (fallback_priority == FontFallbackPriority::kEmojiEmoji) {
@@ -94,7 +96,7 @@ const SimpleFontData* FontCache::Platfor
   if (fallback_priority != FontFallbackPriority::kEmojiEmoji &&
       (font_description.Style() == kItalicSlopeValue ||
        font_description.Weight() >= kBoldThreshold)) {
-    const SimpleFontData* font_data =
+    scoped_refptr<SimpleFontData> font_data =
         FallbackOnStandardFontStyle(font_description, c);
     if (font_data)
       return font_data;
@@ -137,16 +139,16 @@ const SimpleFontData* FontCache::Platfor
     description.SetStyle(kNormalSlopeValue);
   }
 
-  const FontPlatformData* substitute_platform_data =
+  FontPlatformData* substitute_platform_data =
       GetFontPlatformData(description, creation_params);
   if (!substitute_platform_data)
     return nullptr;
 
-  FontPlatformData* platform_data =
-      MakeGarbageCollected<FontPlatformData>(*substitute_platform_data);
+  std::unique_ptr<FontPlatformData> platform_data(
+      new FontPlatformData(*substitute_platform_data));
   platform_data->SetSyntheticBold(should_set_synthetic_bold);
   platform_data->SetSyntheticItalic(should_set_synthetic_italic);
-  return FontDataFromFontPlatformData(platform_data);
+  return FontDataFromFontPlatformData(platform_data.get(), kDoNotRetain);
 }
 
 }  // namespace blink
--- a/third_party/blink/renderer/platform/fonts/segmented_font_data.h
+++ b/third_party/blink/renderer/platform/fonts/segmented_font_data.h
@@ -28,7 +28,6 @@
 
 #include "third_party/blink/renderer/platform/fonts/font_data.h"
 #include "third_party/blink/renderer/platform/fonts/font_data_for_range_set.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
 #include "third_party/blink/renderer/platform/wtf/casting.h"
 
@@ -38,21 +37,20 @@ class SimpleFontData;
 
 class PLATFORM_EXPORT SegmentedFontData : public FontData {
  public:
-  SegmentedFontData() = default;
-
-  void Trace(Visitor* visitor) const override {
-    visitor->Trace(faces_);
-    FontData::Trace(visitor);
+  static scoped_refptr<SegmentedFontData> Create() {
+    return base::AdoptRef(new SegmentedFontData);
   }
 
-  void AppendFace(FontDataForRangeSet* font_data_for_range_set) {
+  void AppendFace(scoped_refptr<FontDataForRangeSet> font_data_for_range_set) {
     faces_.push_back(std::move(font_data_for_range_set));
   }
   unsigned NumFaces() const { return faces_.size(); }
-  FontDataForRangeSet* FaceAt(unsigned i) const { return faces_[i].Get(); }
+  scoped_refptr<FontDataForRangeSet> FaceAt(unsigned i) const { return faces_[i]; }
   bool ContainsCharacter(UChar32) const;
 
  private:
+  SegmentedFontData() = default;
+
   const SimpleFontData* FontDataForCharacter(UChar32) const override;
 
   bool IsCustomFont() const override;
@@ -61,7 +59,7 @@ class PLATFORM_EXPORT SegmentedFontData
   bool IsSegmented() const override;
   bool ShouldSkipDrawing() const override;
 
-  HeapVector<Member<FontDataForRangeSet>, 1> faces_;
+  Vector<scoped_refptr<FontDataForRangeSet>, 1> faces_;
 };
 
 template <>
--- a/third_party/blink/renderer/platform/fonts/shaping/caching_word_shaper.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/caching_word_shaper.cc
@@ -127,7 +127,7 @@ Vector<double> CachingWordShaper::Indivi
                                             total_width);
 }
 
-HeapVector<ShapeResult::RunFontData> CachingWordShaper::GetRunFontData(
+Vector<ShapeResult::RunFontData> CachingWordShaper::GetRunFontData(
     const TextRun& run) const {
   ShapeResultBuffer buffer;
   ShapeResultsForRun(GetShapeCache(), &font_, run, &buffer);
--- a/third_party/blink/renderer/platform/fonts/shaping/caching_word_shaper.h
+++ b/third_party/blink/renderer/platform/fonts/shaping/caching_word_shaper.h
@@ -26,6 +26,7 @@
 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_CACHING_WORD_SHAPER_H_
 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_CACHING_WORD_SHAPER_H_
 
+#include "base/memory/scoped_refptr.h"
 #include "third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.h"
 #include "third_party/blink/renderer/platform/text/text_run.h"
 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
@@ -59,7 +60,7 @@ class PLATFORM_EXPORT CachingWordShaper
   CharacterRange GetCharacterRange(const TextRun&, unsigned from, unsigned to);
   Vector<double> IndividualCharacterAdvances(const TextRun&);
 
-  HeapVector<ShapeResult::RunFontData> GetRunFontData(const TextRun&) const;
+  Vector<ShapeResult::RunFontData> GetRunFontData(const TextRun&) const;
 
   GlyphData EmphasisMarkGlyphData(const TextRun&) const;
 
--- a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.cc
@@ -62,8 +62,7 @@
 
 namespace blink {
 
-HarfBuzzFace::HarfBuzzFace(const FontPlatformData* platform_data,
-                           uint64_t unique_id)
+HarfBuzzFace::HarfBuzzFace(FontPlatformData* platform_data, uint64_t unique_id)
     : platform_data_(platform_data), unique_id_(unique_id) {
   HbFontCacheEntry* const cache_entry =
       FontGlobalContext::GetHarfBuzzFontCache().RefOrNew(unique_id_,
@@ -76,10 +76,6 @@
   FontGlobalContext::GetHarfBuzzFontCache().Remove(unique_id_);
 }
 
-void HarfBuzzFace::Trace(Visitor* visitor) const {
-  visitor->Trace(platform_data_);
-}
-
 bool HarfBuzzFace::ignore_variation_selectors_ = false;
 
 static hb_bool_t HarfBuzzGetGlyph(hb_font_t* hb_font,
@@ -426,8 +421,7 @@ static hb_blob_t* HarfBuzzSkiaGetTable(h
 }
 
 // TODO(yosin): We should move |CreateFace()| to "harfbuzz_font_cache.cc".
-static hb::unique_ptr<hb_face_t> CreateFace(
-    const FontPlatformData* platform_data) {
+static hb::unique_ptr<hb_face_t> CreateFace(FontPlatformData* platform_data) {
   hb::unique_ptr<hb_face_t> face;
 
   sk_sp<SkTypeface> typeface = sk_ref_sp(platform_data->Typeface());
@@ -475,9 +469,8 @@ static scoped_refptr<HbFontCacheEntry> C
   return cache_entry;
 }
 
-HbFontCacheEntry* HarfBuzzFontCache::RefOrNew(
-    uint64_t unique_id,
-    const FontPlatformData* platform_data) {
+HbFontCacheEntry* HarfBuzzFontCache::RefOrNew(uint64_t unique_id,
+                                              FontPlatformData* platform_data) {
   const auto& result = font_map_.insert(unique_id, nullptr);
   if (result.is_new_entry) {
     hb::unique_ptr<hb_face_t> face = CreateFace(platform_data);
--- a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.h
+++ b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.h
@@ -34,11 +34,10 @@
 #include "third_party/blink/renderer/platform/fonts/glyph.h"
 #include "third_party/blink/renderer/platform/fonts/typesetting_features.h"
 #include "third_party/blink/renderer/platform/fonts/unicode_range_set.h"
-#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
-#include "third_party/blink/renderer/platform/heap/member.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
 #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
+#include "third_party/blink/renderer/platform/wtf/ref_counted.h"
 #include "third_party/blink/renderer/platform/wtf/text/character_names.h"
 
 #include <hb.h>
@@ -53,15 +52,19 @@
 // |HarfBuzzFace| is a thread specific data associated to |FontPlatformData|,
 // hold by |HarfBuzzFontCache|.
 class PLATFORM_EXPORT HarfBuzzFace final
-    : public GarbageCollected<HarfBuzzFace> {
+    : public RefCounted<HarfBuzzFace> {
+  USING_FAST_MALLOC(HarfBuzzFace);
+
  public:
-  HarfBuzzFace(const FontPlatformData* platform_data, uint64_t);
+  static scoped_refptr<HarfBuzzFace> Create(FontPlatformData* platform_data,
+                                            uint64_t unique_id) {
+    return base::AdoptRef(new HarfBuzzFace(platform_data, unique_id));
+  }
+
   HarfBuzzFace(const HarfBuzzFace&) = delete;
   HarfBuzzFace& operator=(const HarfBuzzFace&) = delete;
   ~HarfBuzzFace();
 
-  void Trace(Visitor*) const;
-
   enum VerticalLayoutCallbacks { kPrepareForVerticalLayout, kNoVerticalLayout };
 
   // In order to support the restricting effect of unicode-range optionally a
@@ -102,10 +105,11 @@
   }
 
  private:
+  HarfBuzzFace(FontPlatformData* platform_data, uint64_t);
 
   void PrepareHarfBuzzFontData();
 
-  Member<const FontPlatformData> platform_data_;
+  FontPlatformData* const platform_data_;
   const uint64_t unique_id_;
   // TODO(crbug.com/1489080): When briefly given MiraclePtr protection,
   // these members were both found dangling.
--- a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_font_cache.h
+++ b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_font_cache.h
@@ -49,7 +49,7 @@ class HarfBuzzFontCache final {
   ~HarfBuzzFontCache();
 
   HbFontCacheEntry* RefOrNew(uint64_t unique_id,
-                             const FontPlatformData* platform_data);
+                             FontPlatformData* platform_data);
   void Remove(uint64_t unique_id);
 
  private:
--- a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc
@@ -798,7 +798,7 @@
     fallback_chars_hint.ReserveInitialCapacity(range_data->end -
                                                range_data->start);
   }
-  FontDataForRangeSet* current_font_data_for_range_set = nullptr;
+  scoped_refptr<FontDataForRangeSet> current_font_data_for_range_set = nullptr;
   FallbackFontStage fallback_stage = kIntermediate;
   while (!range_data->reshape_queue.empty()) {
     ReshapeQueueItem current_queue_item = range_data->reshape_queue.TakeFirst();
@@ -867,7 +867,7 @@
     if (needs_caps_handling) {
       case_map_intend = caps_support.NeedsCaseChange(small_caps_behavior);
       if (caps_support.NeedsSyntheticFont(small_caps_behavior)) {
-        adjusted_font = font_data->SmallCapsFontData(font_description);
+        adjusted_font = font_data->SmallCapsFontData(font_description).get();
       }
     }
 
--- a/third_party/blink/renderer/platform/fonts/shaping/shape_result.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result.cc
@@ -79,10 +79,9 @@ ASSERT_SIZE(ShapeResult::RunInfo, SameSi
 
 struct SameSizeAsShapeResult {
   float width;
-  UntracedMember<void*> deprecated_ink_bounds_;
-  Vector<int> runs_;
-  Vector<int> character_position_;
-  UntracedMember<void*> primary_font_;
+  UntracedMember<void*> member;
+  Vector<int> vectors[2];
+  void *pointer;
   unsigned start_index_;
   unsigned num_characters_;
   unsigned bitfields : 32;
@@ -396,7 +395,7 @@ void ShapeResult::RunInfo::CharacterInde
   }
 }
 
-ShapeResult::ShapeResult(const SimpleFontData* font_data,
+ShapeResult::ShapeResult(scoped_refptr<const SimpleFontData> font_data,
                          unsigned start_index,
                          unsigned num_characters,
                          TextDirection direction)
@@ -436,7 +435,6 @@ void ShapeResult::Trace(Visitor* visitor
   visitor->Trace(deprecated_ink_bounds_);
   visitor->Trace(runs_);
   visitor->Trace(character_position_);
-  visitor->Trace(primary_font_);
 }
 
 size_t ShapeResult::ByteSize() const {
@@ -736,10 +734,10 @@ bool ShapeResult::HasFallbackFonts(const
   return false;
 }
 
-void ShapeResult::GetRunFontData(HeapVector<RunFontData>* font_data) const {
+void ShapeResult::GetRunFontData(Vector<RunFontData>* font_data) const {
   for (const auto& run : runs_) {
     font_data->push_back(
-        RunFontData({run->font_data_.Get(), run->glyph_data_.size()}));
+        RunFontData({run->font_data_.get(), run->glyph_data_.size()}));
   }
 }
 
@@ -754,7 +752,7 @@ float ShapeResult::ForEachGlyphImpl(floa
   for (const auto& glyph_data : run.glyph_data_) {
     glyph_callback(context, run.start_index_ + glyph_data.character_index,
                    glyph_data.glyph, *glyph_offsets, total_advance,
-                   is_horizontal, run.canvas_rotation_, run.font_data_.Get());
+                   is_horizontal, run.canvas_rotation_, run.font_data_.get());
     total_advance += glyph_data.advance;
     ++glyph_offsets;
   }
@@ -789,7 +787,7 @@ float ShapeResult::ForEachGlyphImpl(floa
   auto total_advance = initial_advance;
   unsigned run_start = run.start_index_ + index_offset;
   bool is_horizontal = HB_DIRECTION_IS_HORIZONTAL(run.direction_);
-  const SimpleFontData* font_data = run.font_data_.Get();
+  const SimpleFontData* font_data = run.font_data_.get();
 
   if (run.IsLtr()) {  // Left-to-right
     for (const auto& glyph_data : run.glyph_data_) {
@@ -1679,7 +1677,7 @@ unsigned ShapeResult::CopyRangeInternal(
 ShapeResult* ShapeResult::SubRange(unsigned start_offset,
                                    unsigned end_offset) const {
   ShapeResult* sub_range =
-      MakeGarbageCollected<ShapeResult>(primary_font_.Get(), 0, 0, Direction());
+      MakeGarbageCollected<ShapeResult>(primary_font_.get(), 0, 0, Direction());
   CopyRange(start_offset, end_offset, sub_range);
   return sub_range;
 }
--- a/third_party/blink/renderer/platform/fonts/shaping/shape_result.h
+++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result.h
@@ -139,7 +139,7 @@ typedef void (*GraphemeClusterCallback)(
 
 class PLATFORM_EXPORT ShapeResult : public GarbageCollected<ShapeResult> {
  public:
-  ShapeResult(const SimpleFontData*,
+  ShapeResult(scoped_refptr<const SimpleFontData>,
               unsigned start_index,
               unsigned num_characters,
               TextDirection);
@@ -152,7 +152,7 @@ class PLATFORM_EXPORT ShapeResult : publ
   void Trace(Visitor*) const;
 
   static ShapeResult* CreateEmpty(const ShapeResult& other) {
-    return MakeGarbageCollected<ShapeResult>(other.primary_font_.Get(), 0, 0,
+    return MakeGarbageCollected<ShapeResult>(other.primary_font_, 0, 0,
                                              other.Direction());
   }
   static const ShapeResult* CreateForTabulationCharacters(
@@ -184,7 +184,7 @@ class PLATFORM_EXPORT ShapeResult : publ
   LayoutUnit SnappedWidth() const { return LayoutUnit::FromFloatCeil(width_); }
   unsigned NumCharacters() const { return num_characters_; }
   unsigned NumGlyphs() const { return num_glyphs_; }
-  const SimpleFontData* PrimaryFont() const { return primary_font_.Get(); }
+  const SimpleFontData* PrimaryFont() const { return primary_font_.get(); }
   bool HasFallbackFonts(const SimpleFontData* primary_font) const;
 
   // TODO(eae): Remove start_x and return value once ShapeResultBuffer has been
@@ -350,12 +350,10 @@ class PLATFORM_EXPORT ShapeResult : publ
 
   // Computes the list of fonts along with the number of glyphs for each font.
   struct RunFontData {
-    DISALLOW_NEW();
-    void Trace(Visitor* visitor) const { visitor->Trace(font_data_); }
-    Member<SimpleFontData> font_data_;
+    SimpleFontData* font_data_;
     wtf_size_t glyph_count_;
   };
-  void GetRunFontData(HeapVector<RunFontData>* font_data) const;
+  void GetRunFontData(Vector<RunFontData>* font_data) const;
 
   // Iterates over, and calls the specified callback function, for all the
   // glyphs. Also tracks (and returns) a seeded total advance.
@@ -510,7 +510,7 @@
   // index to x-position and O(log n) time, using binary search, from
   // x-position to character index.
   mutable HeapVector<ShapeResultCharacterData> character_position_;
-  Member<const SimpleFontData> primary_font_;
+  scoped_refptr<const SimpleFontData> primary_font_;
 
   unsigned start_index_ = 0;
   unsigned num_characters_ = 0;
@@ -570,6 +568,5 @@ PLATFORM_EXPORT std::ostream& operator<<
 }  // namespace blink
 
 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::ShapeResult::ShapeRange)
-WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::ShapeResult::RunFontData)
 
 #endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_SHAPE_RESULT_H_
--- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.cc
@@ -249,8 +249,8 @@ int ShapeResultBuffer::OffsetForPosition
   return total_offset;
 }
 
-HeapVector<ShapeResult::RunFontData> ShapeResultBuffer::GetRunFontData() const {
-  HeapVector<ShapeResult::RunFontData> font_data;
+Vector<ShapeResult::RunFontData> ShapeResultBuffer::GetRunFontData() const {
+  Vector<ShapeResult::RunFontData> font_data;
   for (const auto& result : results_)
     result->GetRunFontData(&font_data);
   return font_data;
@@ -264,9 +264,10 @@ GlyphData ShapeResultBuffer::EmphasisMar
       if (run->glyph_data_.IsEmpty())
         continue;
 
-      return GlyphData(run->glyph_data_[0].glyph,
-                       run->font_data_->EmphasisMarkFontData(font_description),
-                       run->CanvasRotation());
+      return GlyphData(
+          run->glyph_data_[0].glyph,
+          run->font_data_->EmphasisMarkFontData(font_description).get(),
+          run->CanvasRotation());
     }
   }
 
--- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.h
+++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.h
@@ -5,6 +5,7 @@
 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_SHAPE_RESULT_BUFFER_H_
 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_SHAPE_RESULT_BUFFER_H_
 
+#include "base/memory/scoped_refptr.h"
 #include "third_party/blink/renderer/platform/fonts/shaping/shape_result.h"
 #include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
@@ -47,7 +48,7 @@ class PLATFORM_EXPORT ShapeResultBuffer
                                              TextDirection,
                                              float total_width) const;
 
-  HeapVector<ShapeResult::RunFontData> GetRunFontData() const;
+  Vector<ShapeResult::RunFontData> GetRunFontData() const;
 
   GlyphData EmphasisMarkGlyphData(const FontDescription&) const;
 
--- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_inline_headers.h
+++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_inline_headers.h
@@ -79,7 +79,7 @@ struct ShapeResult::RunInfo final
         direction_(other.direction_),
         canvas_rotation_(other.canvas_rotation_) {}
 
-  void Trace(Visitor* visitor) const { visitor->Trace(font_data_); }
+  void Trace(Visitor*) const {}
 
   unsigned NumGlyphs() const { return glyph_data_.size(); }
   bool IsLtr() const { return HB_DIRECTION_IS_FORWARD(direction_); }
@@ -130,7 +130,7 @@ struct ShapeResult::RunInfo final
       return nullptr;
 
     auto* run = MakeGarbageCollected<RunInfo>(
-        font_data_.Get(), direction_, canvas_rotation_, script_,
+        font_data_.get(), direction_, canvas_rotation_, script_,
         start_index_ + start, number_of_glyphs, number_of_characters);
 
     run->glyph_data_.CopyFromRange(glyphs);
@@ -154,7 +154,7 @@ struct ShapeResult::RunInfo final
       return nullptr;
     DCHECK_LT(start_index_, other.start_index_);
     auto* run = MakeGarbageCollected<RunInfo>(
-        font_data_.Get(), direction_, canvas_rotation_, script_, start_index_,
+        font_data_.get(), direction_, canvas_rotation_, script_, start_index_,
         glyph_data_.size() + other.glyph_data_.size(),
         num_characters_ + other.num_characters_);
     // Note: We populate |graphemes_| on demand, e.g. hit testing.
@@ -374,7 +374,7 @@ struct ShapeResult::RunInfo final
   }
 
   GlyphDataCollection glyph_data_;
-  Member<SimpleFontData> font_data_;
+  scoped_refptr<SimpleFontData> font_data_;
 
   // graphemes_[i] is the number of graphemes up to (and including) the ith
   // character in the run.
--- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_test_info.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_test_info.cc
@@ -54,7 +54,7 @@ float ShapeResultTestInfo::AdvanceForTes
 
 SimpleFontData* ShapeResultTestInfo::FontDataForTesting(
     unsigned run_index) const {
-  return runs_[run_index]->font_data_.Get();
+  return runs_[run_index]->font_data_.get();
 }
 
 Vector<unsigned> ShapeResultTestInfo::CharacterIndexesForTesting() const {
--- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_view.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_view.cc
@@ -28,9 +28,7 @@ ShapeResultView::RunInfoPart::RunInfoPar
       start_index_(start_index),
       offset_(offset),
       num_characters_(num_characters),
-      width_(width) {
-  static_assert(std::is_trivially_destructible<RunInfoPart>::value, "");
-}
+      width_(width) {}
 
 void ShapeResultView::RunInfoPart::Trace(Visitor* visitor) const {
   visitor->Trace(run_);
@@ -74,10 +72,7 @@ unsigned ShapeResultView::CharacterIndex
 // |InitData| provides values of const member variables of |ShapeResultView|
 // for constructor.
 struct ShapeResultView::InitData {
-  STACK_ALLOCATED();
-
- public:
-  const SimpleFontData* primary_font = nullptr;
+  scoped_refptr<const SimpleFontData> primary_font;
   unsigned start_index = 0;
   unsigned char_index_offset = 0;
   TextDirection direction = TextDirection::kLtr;
@@ -188,7 +183,7 @@ ShapeResult* ShapeResultView::CreateShap
   new_result->runs_.ReserveInitialCapacity(parts_.size());
   for (const auto& part : RunsOrParts()) {
     auto* new_run = MakeGarbageCollected<ShapeResult::RunInfo>(
-        part.run_->font_data_.Get(), part.run_->direction_,
+        part.run_->font_data_.get(), part.run_->direction_,
         part.run_->canvas_rotation_, part.run_->script_, part.start_index_,
         part.NumGlyphs(), part.num_characters_);
     new_run->glyph_data_.CopyFromRange(part.range_);
@@ -364,21 +359,21 @@ unsigned ShapeResultView::PreviousSafeTo
 }
 
 void ShapeResultView::GetRunFontData(
-    HeapVector<ShapeResult::RunFontData>* font_data) const {
+    Vector<ShapeResult::RunFontData>* font_data) const {
   for (const auto& part : RunsOrParts()) {
     font_data->push_back(ShapeResult::RunFontData(
-        {part.run_->font_data_.Get(),
+        {part.run_->font_data_.get(),
          static_cast<wtf_size_t>(part.end() - part.begin())}));
   }
 }
 
 void ShapeResultView::FallbackFonts(
-    HeapHashSet<Member<const SimpleFontData>>* fallback) const {
+    HashSet<const SimpleFontData*>* fallback) const {
   DCHECK(fallback);
   DCHECK(primary_font_);
   for (const auto& part : RunsOrParts()) {
     if (part.run_->font_data_ && part.run_->font_data_ != primary_font_) {
-      fallback->insert(part.run_->font_data_.Get());
+      fallback->insert(part.run_->font_data_.get());
     }
   }
 }
@@ -392,7 +387,7 @@ float ShapeResultView::ForEachGlyphImpl(
   const auto& run = part.run_;
   auto total_advance = initial_advance;
   bool is_horizontal = HB_DIRECTION_IS_HORIZONTAL(run->direction_);
-  const SimpleFontData* font_data = run->font_data_.Get();
+  const SimpleFontData* font_data = run->font_data_.get();
   const unsigned character_index_offset_for_glyph_data =
       CharacterIndexOffsetForGlyphData(part);
   for (const auto& glyph_data : part) {
@@ -435,7 +430,7 @@ float ShapeResultView::ForEachGlyphImpl(
   auto total_advance = initial_advance;
   const auto& run = part.run_;
   bool is_horizontal = HB_DIRECTION_IS_HORIZONTAL(run->direction_);
-  const SimpleFontData* font_data = run->font_data_.Get();
+  const SimpleFontData* font_data = run->font_data_.get();
   const unsigned character_index_offset_for_glyph_data =
       CharacterIndexOffsetForGlyphData(part);
   if (run->IsLtr()) {  // Left-to-right
--- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h
+++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h
@@ -10,7 +10,6 @@
 #include "third_party/blink/renderer/platform/fonts/shaping/shape_result.h"
 #include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
 #include "third_party/blink/renderer/platform/geometry/layout_unit.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
 #include "third_party/blink/renderer/platform/text/text_direction.h"
 #include "third_party/blink/renderer/platform/wtf/forward.h"
@@ -111,10 +110,7 @@ class PLATFORM_EXPORT ShapeResultView fi
   ShapeResultView& operator=(const ShapeResultView&) = delete;
   ~ShapeResultView() = default;
 
-  void Trace(Visitor* visitor) const {
-    visitor->Trace(parts_);
-    visitor->Trace(primary_font_);
-  }
+  void Trace(Visitor* visitor) const { visitor->Trace(parts_); }
 
   ShapeResult* CreateShapeResult() const;
 
@@ -130,7 +126,7 @@ class PLATFORM_EXPORT ShapeResultView fi
   bool IsLtr() const { return blink::IsLtr(Direction()); }
   bool IsRtl() const { return blink::IsRtl(Direction()); }
   bool HasVerticalOffsets() const { return has_vertical_offsets_; }
-  void FallbackFonts(HeapHashSet<Member<const SimpleFontData>>* fallback) const;
+  void FallbackFonts(HashSet<const SimpleFontData*>* fallback) const;
 
   unsigned PreviousSafeToBreakOffset(unsigned index) const;
 
@@ -155,8 +151,10 @@ class PLATFORM_EXPORT ShapeResultView fi
   // bounds.
   gfx::RectF ComputeInkBounds() const;
 
-  const SimpleFontData* PrimaryFont() const { return primary_font_.Get(); }
-  void GetRunFontData(HeapVector<ShapeResult::RunFontData>*) const;
+  scoped_refptr<const SimpleFontData> PrimaryFont() const {
+    return primary_font_;
+  }
+  void GetRunFontData(Vector<ShapeResult::RunFontData>*) const;
 
   void ExpandRangeToIncludePartialGlyphs(unsigned* from, unsigned* to) const;
 
@@ -288,8 +286,7 @@ class PLATFORM_EXPORT ShapeResultView fi
 
   unsigned StartIndexOffsetForRun() const { return char_index_offset_; }
 
-  HeapVector<RunInfoPart, 1> parts_;
-  Member<const SimpleFontData> const primary_font_;
+  scoped_refptr<const SimpleFontData> const primary_font_;
 
   const unsigned start_index_;
 
@@ -311,6 +308,8 @@ class PLATFORM_EXPORT ShapeResultView fi
   // with ShapeResult::SubRange
   const unsigned char_index_offset_;
 
+  HeapVector<RunInfoPart, 1> parts_;
+
  private:
   friend class ShapeResult;
 
--- a/third_party/blink/renderer/platform/fonts/simple_font_data.cc
+++ b/third_party/blink/renderer/platform/fonts/simple_font_data.cc
@@ -76,14 +76,14 @@ constexpr int32_t kFontObjectsMemoryCons
 constexpr int32_t kFontObjectsMemoryConsumption = 2128;
 #endif
 
-SimpleFontData::SimpleFontData(const FontPlatformData* platform_data,
-                               const CustomFontData* custom_data,
+SimpleFontData::SimpleFontData(const FontPlatformData& platform_data,
+                               scoped_refptr<CustomFontData> custom_data,
                                bool subpixel_ascent_descent,
                                const FontMetricsOverride& metrics_override)
     : platform_data_(platform_data),
-      font_(platform_data->size() ? platform_data->CreateSkFont()
+      font_(platform_data_.size() ? platform_data.CreateSkFont()
                                   : skia::DefaultFont()),
-      custom_font_data_(custom_data) {
+      custom_font_data_(std::move(custom_data)) {
   // Every time new SimpleFontData instance is created, Skia will ask
   // FreeType to get the metrics for glyphs by invoking
   // af_face_globals_get_metrics. There FT will allocate style_metrics_size
@@ -111,7 +111,7 @@ SimpleFontData::~SimpleFontData() {
 
 void SimpleFontData::PlatformInit(bool subpixel_ascent_descent,
                                   const FontMetricsOverride& metrics_override) {
-  if (!platform_data_->size()) {
+  if (!platform_data_.size()) {
     font_metrics_.Reset();
     avg_char_width_ = 0;
     max_char_width_ = 0;
@@ -126,7 +126,7 @@ void SimpleFontData::PlatformInit(bool s
   float descent;
 
   FontMetrics::AscentDescentWithHacks(
-      ascent, descent, *platform_data_, font_, subpixel_ascent_descent,
+      ascent, descent, platform_data_, font_, subpixel_ascent_descent,
       metrics_override.ascent_override, metrics_override.descent_override);
 
   font_metrics_.SetAscent(ascent);
@@ -164,7 +164,7 @@ void SimpleFontData::PlatformInit(bool s
 
   float line_gap;
   if (metrics_override.line_gap_override) {
-    line_gap = *metrics_override.line_gap_override * platform_data_->size();
+    line_gap = *metrics_override.line_gap_override * platform_data_.size();
   } else {
     line_gap = SkScalarToFloat(metrics.fLeading);
   }
@@ -261,39 +261,45 @@ bool SimpleFontData::IsSegmented() const
   return false;
 }
 
-SimpleFontData* SimpleFontData::SmallCapsFontData(
+scoped_refptr<SimpleFontData> SimpleFontData::SmallCapsFontData(
     const FontDescription& font_description) const {
-  if (!small_caps_) {
-    small_caps_ =
+  if (!derived_font_data_)
+    derived_font_data_ = std::make_unique<DerivedFontData>();
+  if (!derived_font_data_->small_caps) {
+    derived_font_data_->small_caps =
         CreateScaledFontData(font_description, kSmallCapsFontSizeMultiplier);
   }
-  return small_caps_;
+
+  return derived_font_data_->small_caps;
 }
 
-SimpleFontData* SimpleFontData::EmphasisMarkFontData(
+scoped_refptr<SimpleFontData> SimpleFontData::EmphasisMarkFontData(
     const FontDescription& font_description) const {
-  if (!emphasis_mark_) {
-    emphasis_mark_ =
+  if (!derived_font_data_)
+    derived_font_data_ = std::make_unique<DerivedFontData>();
+  if (!derived_font_data_->emphasis_mark) {
+    derived_font_data_->emphasis_mark =
         CreateScaledFontData(font_description, kEmphasisMarkFontSizeMultiplier);
   }
-  return emphasis_mark_;
+
+  return derived_font_data_->emphasis_mark;
 }
 
-SimpleFontData* SimpleFontData::CreateScaledFontData(
+scoped_refptr<SimpleFontData> SimpleFontData::CreateScaledFontData(
     const FontDescription& font_description,
     float scale_factor) const {
   const float scaled_size =
       lroundf(font_description.ComputedSize() * scale_factor);
-  return MakeGarbageCollected<SimpleFontData>(
-      MakeGarbageCollected<FontPlatformData>(*platform_data_, scaled_size),
-      IsCustomFont() ? MakeGarbageCollected<CustomFontData>() : nullptr);
+  return SimpleFontData::Create(
+      FontPlatformData(platform_data_, scaled_size),
+      IsCustomFont() ? CustomFontData::Create() : nullptr);
 }
 
-SimpleFontData* SimpleFontData::MetricsOverriddenFontData(
+scoped_refptr<SimpleFontData> SimpleFontData::MetricsOverriddenFontData(
     const FontMetricsOverride& metrics_override) const {
-  return MakeGarbageCollected<SimpleFontData>(
-      platform_data_, custom_font_data_, false /* subpixel_ascent_descent */,
-      metrics_override);
+  return base::AdoptRef(new SimpleFontData(platform_data_, custom_font_data_,
+                                           false /* subpixel_ascent_descent */,
+                                           metrics_override));
 }
 
 // Internal leadings can be distributed to ascent and descent.
@@ -346,7 +352,7 @@ static std::pair<int16_t, int16_t> TypoA
 
 void SimpleFontData::ComputeNormalizedTypoAscentAndDescent() const {
   // Compute em height metrics from OS/2 sTypoAscender and sTypoDescender.
-  SkTypeface* typeface = platform_data_->Typeface();
+  SkTypeface* typeface = platform_data_.Typeface();
   auto [typo_ascender, typo_descender] = TypoAscenderAndDescender(typeface);
   if (typo_ascender > 0 &&
       TrySetNormalizedTypoAscentAndDescent(typo_ascender, typo_descender)) {
@@ -433,7 +439,7 @@ const std::optional<float>& SimpleFontDa
     }
 
     // Compute vertical advance if the orientation is `kVerticalUpright`.
-    const HarfBuzzFace* hb_face = platform_data_->GetHarfBuzzFace();
+    const HarfBuzzFace* hb_face = platform_data_.GetHarfBuzzFace();
     const OpenTypeVerticalData& vertical_data = hb_face->VerticalData();
     ideographic_inline_size_ = vertical_data.AdvanceHeight(cjk_water_glyph);
   });
@@ -461,9 +467,8 @@ const HanKerning::FontData& SimpleFontDa
 }
 
 gfx::RectF SimpleFontData::PlatformBoundsForGlyph(Glyph glyph) const {
-  if (!platform_data_->size()) {
+  if (!platform_data_.size())
     return gfx::RectF();
-  }
 
   static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
 
@@ -476,18 +481,16 @@ void SimpleFontData::BoundsForGlyphs(con
                                      Vector<SkRect, 256>* bounds) const {
   DCHECK_EQ(glyphs.size(), bounds->size());
 
-  if (!platform_data_->size()) {
+  if (!platform_data_.size())
     return;
-  }
 
   DCHECK_EQ(bounds->size(), glyphs.size());
   SkFontGetBoundsForGlyphs(font_, glyphs, bounds->data());
 }
 
 float SimpleFontData::WidthForGlyph(Glyph glyph) const {
-  if (!platform_data_->size()) {
+  if (!platform_data_.size())
     return 0;
-  }
 
   static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
 
--- a/third_party/blink/renderer/platform/fonts/simple_font_data.h
+++ b/third_party/blink/renderer/platform/fonts/simple_font_data.h
@@ -40,7 +40,6 @@
 #include "third_party/blink/renderer/platform/fonts/glyph.h"
 #include "third_party/blink/renderer/platform/fonts/shaping/han_kerning.h"
 #include "third_party/blink/renderer/platform/fonts/typesetting_features.h"
-#include "third_party/blink/renderer/platform/heap/member.h"
 #include "third_party/blink/renderer/platform/platform_export.h"
 #include "third_party/blink/renderer/platform/wtf/casting.h"
 #include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
@@ -75,18 +74,12 @@ class FontDescription;
 class PLATFORM_EXPORT SimpleFontData final : public FontData {
  public:
   // Used to create platform fonts.
-  SimpleFontData(
-      const FontPlatformData*,
-      const CustomFontData* custom_data = nullptr,
-      bool subpixel_ascent_descent = false,
-      const FontMetricsOverride& metrics_override = FontMetricsOverride());
-
-  void Trace(Visitor* visitor) const override {
-    visitor->Trace(platform_data_);
-    visitor->Trace(small_caps_);
-    visitor->Trace(emphasis_mark_);
-    visitor->Trace(custom_font_data_);
-    FontData::Trace(visitor);
+  static scoped_refptr<SimpleFontData> Create(
+      const FontPlatformData& platform_data,
+      scoped_refptr<CustomFontData> custom_data = nullptr,
+      bool subpixel_ascent_descent = false) {
+    return base::AdoptRef(new SimpleFontData(
+        platform_data, std::move(custom_data), subpixel_ascent_descent));
   }
 
   SimpleFontData(const SimpleFontData&) = delete;
@@ -95,11 +88,13 @@ class PLATFORM_EXPORT SimpleFontData fin
   SimpleFontData& operator=(const SimpleFontData&) = delete;
   SimpleFontData& operator=(const SimpleFontData&&) = delete;
 
-  const FontPlatformData& PlatformData() const { return *platform_data_; }
+  const FontPlatformData& PlatformData() const { return platform_data_; }
 
-  SimpleFontData* SmallCapsFontData(const FontDescription&) const;
-  SimpleFontData* EmphasisMarkFontData(const FontDescription&) const;
-  SimpleFontData* MetricsOverriddenFontData(const FontMetricsOverride&) const;
+  scoped_refptr<SimpleFontData> SmallCapsFontData(const FontDescription&) const;
+  scoped_refptr<SimpleFontData> EmphasisMarkFontData(
+      const FontDescription&) const;
+  scoped_refptr<SimpleFontData> MetricsOverriddenFontData(
+      const FontMetricsOverride&) const;
 
   FontMetrics& GetFontMetrics() { return font_metrics_; }
   const FontMetrics& GetFontMetrics() const { return font_metrics_; }
@@ -154,7 +149,7 @@ class PLATFORM_EXPORT SimpleFontData fin
 
   Glyph GlyphForCharacter(UChar32) const;
 
-  bool IsCustomFont() const override { return custom_font_data_; }
+  bool IsCustomFont() const override { return custom_font_data_.get(); }
   bool IsLoading() const override {
     return custom_font_data_ ? custom_font_data_->IsLoading() : false;
   }
@@ -169,16 +164,20 @@ class PLATFORM_EXPORT SimpleFontData fin
     return custom_font_data_ && custom_font_data_->ShouldSkipDrawing();
   }
 
-  const CustomFontData* GetCustomFontData() const {
-    return custom_font_data_.Get();
-  }
+  CustomFontData* GetCustomFontData() const { return custom_font_data_.get(); }
 
  private:
+  SimpleFontData(
+      const FontPlatformData&,
+      scoped_refptr<CustomFontData> custom_data,
+      bool subpixel_ascent_descent = false,
+      const FontMetricsOverride& metrics_override = FontMetricsOverride());
+
   void PlatformInit(bool subpixel_ascent_descent, const FontMetricsOverride&);
   void PlatformGlyphInit();
 
-  SimpleFontData* CreateScaledFontData(const FontDescription&,
-                                       float scale_factor) const;
+  scoped_refptr<SimpleFontData> CreateScaledFontData(const FontDescription&,
+                                              float scale_factor) const;
 
   void ComputeNormalizedTypoAscentAndDescent() const;
   bool TrySetNormalizedTypoAscentAndDescent(float ascent, float descent) const;
@@ -187,17 +186,30 @@ class PLATFORM_EXPORT SimpleFontData fin
   float max_char_width_ = -1;
   float avg_char_width_ = -1;
 
-  Member<const FontPlatformData> platform_data_;
+  const FontPlatformData platform_data_;
   const SkFont font_;
 
   Glyph space_glyph_ = 0;
   float space_width_ = 0;
   Glyph zero_glyph_ = 0;
 
-  mutable Member<SimpleFontData> small_caps_;
-  mutable Member<SimpleFontData> emphasis_mark_;
+  struct DerivedFontData final {
+    USING_FAST_MALLOC(DerivedFontData);
+
+   public:
+    DerivedFontData() = default;
+    DerivedFontData(const DerivedFontData&) = delete;
+    DerivedFontData(DerivedFontData&&) = delete;
+    DerivedFontData& operator=(const DerivedFontData&) = delete;
+    DerivedFontData& operator=(DerivedFontData&&) = delete;
+
+    scoped_refptr<SimpleFontData> small_caps;
+    scoped_refptr<SimpleFontData> emphasis_mark;
+  };
+
+  mutable std::unique_ptr<DerivedFontData> derived_font_data_;
 
-  Member<const CustomFontData> custom_font_data_;
+  const scoped_refptr<CustomFontData> custom_font_data_;
 
   mutable std::once_flag ideographic_inline_size_once_;
   mutable std::once_flag ideographic_advance_width_once_;
--- a/third_party/blink/renderer/platform/fonts/skia/font_cache_skia.cc
+++ b/third_party/blink/renderer/platform/fonts/skia/font_cache_skia.cc
@@ -94,7 +94,7 @@ AtomicString FontCache::GetFamilyNameFor
 
 void FontCache::PlatformInit() {}
 
-const SimpleFontData* FontCache::FallbackOnStandardFontStyle(
+scoped_refptr<SimpleFontData> FontCache::FallbackOnStandardFontStyle(
     const FontDescription& font_description,
     UChar32 character) {
   FontDescription substitute_description(font_description);
@@ -103,26 +103,27 @@ const SimpleFontData* FontCache::Fallbac
 
   FontFaceCreationParams creation_params(
       substitute_description.Family().FamilyName());
-  const FontPlatformData* substitute_platform_data =
+  FontPlatformData* substitute_platform_data =
       GetFontPlatformData(substitute_description, creation_params);
   if (substitute_platform_data &&
       substitute_platform_data->FontContainsCharacter(character)) {
-    FontPlatformData* platform_data =
-        MakeGarbageCollected<FontPlatformData>(*substitute_platform_data);
-    platform_data->SetSyntheticBold(font_description.Weight() >=
-                                        kBoldThreshold &&
-                                    font_description.SyntheticBoldAllowed());
-    platform_data->SetSyntheticItalic(
-        font_description.Style() == kItalicSlopeValue &&
-        font_description.SyntheticItalicAllowed());
-    return FontDataFromFontPlatformData(platform_data);
+    FontPlatformData platform_data =
+        FontPlatformData(*substitute_platform_data);
+    platform_data.SetSyntheticBold(font_description.Weight() >=
+                                       kBoldThreshold &&
+                                   font_description.SyntheticBoldAllowed());
+    platform_data.SetSyntheticItalic(font_description.Style() ==
+                                         kItalicSlopeValue &&
+                                     font_description.SyntheticItalicAllowed());
+    return FontDataFromFontPlatformData(&platform_data, kDoNotRetain);
   }
 
   return nullptr;
 }
 
-const SimpleFontData* FontCache::GetLastResortFallbackFont(
-    const FontDescription& description) {
+scoped_refptr<SimpleFontData> FontCache::GetLastResortFallbackFont(
+    const FontDescription& description,
+    ShouldRetain should_retain) {
   const FontFaceCreationParams fallback_creation_params(
       GetFallbackFontFamily(description));
   const FontPlatformData* font_platform_data = GetFontPlatformData(
@@ -195,7 +196,7 @@ const SimpleFontData* FontCache::GetLast
 #endif
 
   DCHECK(font_platform_data);
-  return FontDataFromFontPlatformData(font_platform_data);
+  return FontDataFromFontPlatformData(font_platform_data, should_retain);
 }
 
 sk_sp<SkTypeface> FontCache::CreateTypeface(
@@ -238,7 +239,7 @@ sk_sp<SkTypeface> FontCache::CreateTypef
 }
 
 #if !BUILDFLAG(IS_WIN)
-const FontPlatformData* FontCache::CreateFontPlatformData(
+std::unique_ptr<FontPlatformData> FontCache::CreateFontPlatformData(
     const FontDescription& font_description,
     const FontFaceCreationParams& creation_params,
     float font_size,
@@ -293,10 +294,11 @@ const FontPlatformData* FontCache::Creat
                 ->GetResolvedFontFeatures()
           : ResolvedFontFeatures();
 
-  FontPlatformData* font_platform_data = MakeGarbageCollected<FontPlatformData>(
-      typeface, name, font_size, synthetic_bold, synthetic_italic,
-      font_description.TextRendering(), resolved_font_features,
-      font_description.Orientation());
+  std::unique_ptr<FontPlatformData> font_platform_data =
+      std::make_unique<FontPlatformData>(
+          typeface, name, font_size, synthetic_bold, synthetic_italic,
+          font_description.TextRendering(), resolved_font_features,
+          font_description.Orientation());
 
   font_platform_data->SetAvoidEmbeddedBitmaps(
       BitmapGlyphsBlockList::ShouldAvoidEmbeddedBitmapsForTypeface(*typeface));
--- a/third_party/blink/renderer/platform/testing/font_test_helpers.cc
+++ b/third_party/blink/renderer/platform/testing/font_test_helpers.cc
@@ -43,26 +43,23 @@ class TestFontSelector : public FontSele
   }
   ~TestFontSelector() override = default;
 
-  FontData* GetFontData(const FontDescription& font_description,
-                        const FontFamily&) override {
+  scoped_refptr<FontData> GetFontData(const FontDescription& font_description,
+                                      const FontFamily&) override {
     FontSelectionCapabilities normal_capabilities(
         {kNormalWidthValue, kNormalWidthValue},
         {kNormalSlopeValue, kNormalSlopeValue},
         {kNormalWeightValue, kNormalWeightValue});
-    const FontPlatformData* platform_data =
-        custom_platform_data_->GetFontPlatformData(
-            font_description.EffectiveFontSize(),
-            font_description.AdjustedSpecifiedSize(),
-            font_description.IsSyntheticBold() &&
-                font_description.SyntheticBoldAllowed(),
-            font_description.IsSyntheticItalic() &&
-                font_description.SyntheticItalicAllowed(),
-            font_description.GetFontSelectionRequest(), normal_capabilities,
-            font_description.FontOpticalSizing(),
-            font_description.TextRendering(), {},
-            font_description.Orientation());
-    return MakeGarbageCollected<SimpleFontData>(
-        platform_data, MakeGarbageCollected<CustomFontData>());
+    FontPlatformData platform_data = custom_platform_data_->GetFontPlatformData(
+        font_description.EffectiveFontSize(),
+        font_description.AdjustedSpecifiedSize(),
+        font_description.IsSyntheticBold() &&
+            font_description.SyntheticBoldAllowed(),
+        font_description.IsSyntheticItalic() &&
+            font_description.SyntheticItalicAllowed(),
+        font_description.GetFontSelectionRequest(), normal_capabilities,
+        font_description.FontOpticalSizing(), font_description.TextRendering(),
+        {}, font_description.Orientation());
+    return SimpleFontData::Create(platform_data, CustomFontData::Create());
   }
 
   void WillUseFontData(const FontDescription&,
@@ -83,20 +80,20 @@ class TestFontSelector : public FontSele
   void ReportFontLookupByUniqueOrFamilyName(
       const AtomicString& name,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) override {}
+      scoped_refptr<SimpleFontData> resulting_font_data) override {}
   void ReportFontLookupByUniqueNameOnly(
       const AtomicString& name,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data,
+      scoped_refptr<SimpleFontData> resulting_font_data,
       bool is_loading_fallback = false) override {}
   void ReportFontLookupByFallbackCharacter(
       UChar32 hint,
       FontFallbackPriority fallback_priority,
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) override {}
+      scoped_refptr<SimpleFontData> resulting_font_data) override {}
   void ReportLastResortFallbackFontLookup(
       const FontDescription& font_description,
-      const SimpleFontData* resulting_font_data) override {}
+      scoped_refptr<SimpleFontData> resulting_font_data) override {}
   void ReportNotDefGlyph() const override {}
   void ReportEmojiSegmentGlyphCoverage(unsigned, unsigned) override {}
   ExecutionContext* GetExecutionContext() const override { return nullptr; }
--- a/tools/privacy_budget/font_indexer/font_indexer.cc
+++ b/tools/privacy_budget/font_indexer/font_indexer.cc
@@ -116,7 +116,7 @@ void FontIndexer::FontListHasLoaded(base
 bool FontIndexer::DoesFontHaveDigest(WTF::AtomicString name,
                                      blink::FontDescription font_description,
                                      int64_t digest) {
-  const blink::SimpleFontData* font_data =
+  scoped_refptr<blink::SimpleFontData> font_data =
       font_cache_->GetFontData(font_description, name);
   DCHECK(font_data);
   return blink::FontGlobalContext::Get()
@@ -170,7 +170,7 @@ void FontIndexer::PrintAllFontsWithName(
   // exists and for later comparison.
   int64_t default_font_digest;
   {
-    const blink::SimpleFontData* font_data =
+    scoped_refptr<blink::SimpleFontData> font_data =
         font_cache_->GetFontData(blink::FontDescription(), name);
     default_font_digest =
         font_data ? blink::FontGlobalContext::Get()
@@ -231,7 +231,7 @@ void FontIndexer::PrintAllFontsWithName(
       for (auto slope_pair : slopes) {
         font_description.SetStyle(slope_pair.first);
 
-        if (const blink::SimpleFontData* font_data =
+        if (scoped_refptr<blink::SimpleFontData> font_data =
                 font_cache_->GetFontData(font_description, name)) {
           uint64_t typeface_digest =
               blink::FontGlobalContext::Get()