fonts: testing font sizes
enumerating fonts is slow, and just saying "hey you have these system fonts" is boring. So lets collect sizes. Now, it's bit pointless (and SLOW) testing fonts that the user is expected to have and there is a size collision
for example: TB on linux bundles 140 font files (for 134 fonts) and all fonts are restricted to those. But something like 53 of those fonts are all the exact same size, so we could drop 52 of those .. and there are some other buckets of sizes with multiple fonts in them. Since they are all expected, we only need to measure one of each size
for example: on windows
// ignore: expected + dupe sizes
// "SimSun-ExtB", // = MS Gothic
// "MS UI Gothic", // = MS PGothic
// "Segoe UI Symbol", // = Segoe UI
// "Cambria", // = cambria math
// "Helvetica","Small Fonts" // = Arial (which we catch if not in fonts, in bases)
// "Courier", // = courier new
// "MS Serif","Roman","Times", // = TNR
// "MS Sans Serif", // = Microsoft Sans Serif
and there's likely more: such as "Cordia New" and "CordiaUPC" always seem to be bundled together (I just need to check) and they are the same size. Same with "Browallia New", "BrowalliaUPC" | "Angsana New", "AngsanaUPC" ...
what I'm lacking is some data sets to make decisions: for example, of the 232 legit windows font names being tested, I do not have 102 of them on my windows 7
Am after TB on linux, FF on windows 8/8.1/10/11, FF mac. For Firefox, disable RFP so I can get size collisions for all the fonts you may have
STR
- if Firefox, flip RFP off
- https://arkenfox.github.io/TZP/tzp.html
- open console
- type
listfontsizes()and hit enter - paste the results here
- flip RFP back on if required
example
here is my windows 7
2571.4 x 358.5 : Cordia New, CordiaUPC
2590.2 x 332.5 : Browallia New, BrowalliaUPC
2618.56 x 346 : Angsana New, AngsanaUPC
3072 x 294 : FangSong, SimHei, SimSun
3072 x 298.5 : KaiTi, NSimSun, 宋体
3072 x 299.5 : BatangChe, DotumChe, GungsuhChe, 굴림체
3072 x 307.2 : MS Gothic, MS Mincho
3072 x 310 : DFKai-SB, MingLiU_HKSCS-ExtB, 細明體
3072 x 316.5 : MingLiU, MingLiU-ExtB, MingLiU_HKSCS
3728.26 x 316.5 : PMingLiU, PMingLiU-ExtB
3967.7 x 294 : Mongolian Baiti, Times New Roman
3976.26 x 296.5 : MS Shell Dlg, Microsoft Sans Serif
3990.4 x 340 : Lao UI, Segoe UI
Arch Linux GNOME 42.4
3452.86 x 308 : URW Chancery L, Z003 3644.86 x 307 : Standard Symbols L, Standard Symbols PS 3686.4 x 327 : Courier sans-serif, Nimbus Mono L sans-serif, Nimbus Mono PS sans-serif 3686.4 x 359 : Source Code Pro, Source Code Pro Black, Source Code Pro ExtraLight, Source Code Pro Light, Source Code Pro Medium, Source Code Pro Semibold 3687.2 x 321 : Courier New, Liberation Mono 3912.14 x 338 : FreeSans, FreeSerif 3967.26 x 339 : Arial, Liberation Sans 3975.44 x 319 : Nimbus Sans, Nimbus Sans L 3981.06 x 307 : Nimbus Roman, Nimbus Roman No9 L 4215.56 x 322 : URW Gothic, URW Gothic L 4363.8 x 318 : P052, URW Palladio L 4415.16 x 321 : C059, Century Schoolbook L 4458.96 x 316 : URW Bookman, URW Bookman L 4730.86 x 378 : D050000L, Dingbats
Ubuntu 22.04
3072 x 371 : Noto Sans Mono CJK HK, Noto Sans Mono CJK JP, Noto Sans Mono CJK KR, Noto Sans Mono CJK SC, Noto Sans Mono CJK TC 3660.02 x 340 : Rasa Light, Yrsa Light 3686.4 x 335 : Tlwg Typist, Tlwg Typo 3687.2 x 319 : Courier New, Liberation Mono 3699.2 x 321 : KacstArt, KacstBook, KacstDigital, KacstFarsi, KacstLetter, KacstNaskh, KacstOffice, KacstPen, KacstPoster, KacstScreen, KacstTitle 3699.2 x 335 : Droid Sans Fallback, Standard Symbols L 3699.2 x 341 : Lohit Assamese, Lohit Bengali 3699.2 x 362 : RaghuMalayalamSans, Samyak Malayalam 3699.2 x 396 : KacstQurn, KacstTitleL 3699.2 x 426 : Gubbi, Navilu 3699.2 x 458 : Pothana2000, Vemana2000 3699.2 x 480 : ori1Uni, utkal 3699.2 x 512 : Samyak Devanagari, Samyak Tamil 3699.2 x 517 : Lohit Tamil, Lohit Tamil Classical 3700.24 x 340 : Rasa, Yrsa 3741.46 x 340 : Rasa Medium, Yrsa Medium 3779.26 x 340 : Rasa SemiBold, Yrsa SemiBold 3912.14 x 307 : FreeSans, FreeSerif 3926.26 x 513 : Gargi, गार्गी 3930.8 x 430 : Kalimati, नालिमाटी 3967.26 x 307 : Arial, Liberation Sans 3967.26 x 407 : Loma, Phetsarath OT 3967.7 x 431 : Nakula, Sahadeva 4259.26 x 363 : padmaa, padmmaa 4270 x 371 : Noto Sans CJK HK, Noto Sans CJK JP, Noto Sans CJK KR, Noto Sans CJK SC, Noto Sans CJK TC 4649.82 x 369 : Noto Serif CJK JP, Noto Serif CJK KR, Noto Serif CJK SC, Noto Serif CJK TC
This research is for arkenfox or for TZP?
W10 22H2
3750.14 x 313 : Calibri, Calibri Light
3871.16 x 313 : Candara, Candara Light
3889.26 x 313 : Corbel, Corbel Light
3933.06 x 342.1 : HoloLens MDL2 Assets, Segoe MDL2 Assets
3967.26 x 297 : Arial, Arial Black
3976.26 x 296.5 : MS Shell Dlg, Microsoft Sans Serif
3990.4 x 340 : Gadugi, Leelawadee UI, Leelawadee UI Semilight, Nirmala UI, Nirmala UI Semilight, Segoe UI, Segoe UI Black, Segoe UI Emoji, Segoe UI Historic, Yu Gothic UI, Yu Gothic UI Light
4071.8 x 341 : Malgun Gothic, Malgun Gothic Semilight
4155.2 x 410 : Yu Gothic, Yu Gothic Light
4286.8 x 325 : Microsoft JhengHei UI, Microsoft JhengHei UI Light
4286.8 x 340 : Microsoft JhengHei, Microsoft JhengHei Light
4349.8 x 325 : Microsoft YaHei UI, Microsoft YaHei UI Light
4349.8 x 338 : Microsoft YaHei, Microsoft YaHei Light
macOS Monterey 12.6:
3586.56 x 329.6 : Bodoni 72, Bodoni 72 Oldstyle
3813.6 x 362 : Al Tarikh, Baghdad
3813.6 x 384.5 : Al Bayan, Al Nile
3813.6 x 384.6 : ITF Devanagari, ITF Devanagari Marathi
3813.6 x 387 : STIXIntegralsSm, STIXIntegralsUp, STIXIntegralsUpSm
3813.6 x 417 : Mishafi, Mishafi Gold
3813.6 x 640.5 : Noto Nastaliq Urdu, Noto Serif Myanmar
3813.6 x 674.5 : STIXIntegralsD, STIXIntegralsUpD
3813.6 x 798 : STIXSizeFourSym, STIXSizeThreeSym
3861.56 x 361.1 : Songti SC, Songti TC
3867.2 x 334 : Bangla Sangam MN, Malayalam Sangam MN
4091.1 x 384.6 : Kohinoor Bangla, Kohinoor Devanagari, Kohinoor Telugu
4092.76 x 361.1 : PingFang HK, PingFang SC, PingFang TC
4198.7 x 313.934 : Heiti SC, Heiti TC
4284.9 x 323.534 : Kannada MN, Oriya MN, Tamil MN, Telugu MN
4332.3 x 384.5 : Hiragino Kaku Gothic ProN, Hiragino Sans GB
Windows 11 21H2
3072 x 296.5 : NSimSun, SimSun, 宋体
3676.98 x 331 : Sitka Banner, Sitka Display, Sitka Heading, Sitka Small, Sitka Subheading, Sitka Text
3767.36 x 340 : Segoe UI Light, Yu Gothic UI Light
3878.4 x 340 : Leelawadee UI Semilight, Nirmala UI Semilight, Segoe UI Semilight, Yu Gothic UI Semilight
3933.06 x 340.1 : HoloLens MDL2 Assets, Segoe MDL2 Assets
3976.26 x 295 : MS Shell Dlg, Microsoft Sans Serif
3990.4 x 340 : Gadugi, Leelawadee UI, Nirmala UI, Segoe UI, Segoe UI Emoji, Segoe UI Historic, Yu Gothic UI
4140.1 x 340 : Segoe UI Semibold, Yu Gothic UI Semibold
This research is for arkenfox or for TZP?
TZP
click me for details if you are bored
The issue with TZP perf is that lets say I run the test and it takes 450ms - 300ms of that was in fonts: namely 200ms enumerating fonts, and 100ms measuring glyphs. And that's with a windows list of 250 fonts. Mac is 440 fonts, linux is 470 fonts (or something)
The ONLY way to speed this up is to do less measurements. It is the actual act of querying the dimensions that causes the slow down: e.g. I can set 100 fonts and it takes no time, but measuring each one in between, the dom has to populate all the properties even if the font used doesn't actually change (it's a bit more confusing than that because I am also setting a generic base font-family style)
So one thing I have done is to speed up the measuring logic in two ways. Normally you measure against monospace, then serif, then sans-serif. I drop subsequent checks if the font has already been detected
so as an example:
- collect the three generic font-families (monospace, serif, sans-serif) base measurements
- old method: loop 100 fonts, each font loop three generic font-families
- so that's 300 measurements: e.g.
- FontA monospace, compare to monospace base measurement: if it differs, the font is detected
- FontA serif, compare to serif base measurement: if it differs, the font is detected
- FontA sans-serif, compare to sans-serif base measurement: if it differs, the font is detected
- FontB ... etc
- new method: skips subsequent tests if the font is already detected
- the number of measurements saved depends on what fonts you have: e.g.
- lets say I test 100 fonts
- against monospace I test all 100 and I detect 60
- against serif I only need to test 40 (I already found 60) and I detect another 3
- against sans-serif I only need to test 37 (I already found 63) and I detect another 4
- so instead of 300 measurements, I only need to do, in this example, 177
The reason you test against three generic font-families, is that if you don't you won't pick up all fonts. Something has to be the default font for each and there can be size collisions. For example if we only checked against monospace in windows, we wouldn't pick up Consolas, because that is the actual default font for monospace = the same as comparing monospace to monospace, or comparing consolas to consolas.
anyway, long story short, this saved about 1/3rd of the time in enumerating fonts (it depends on what you fonts you have, but these lists are OS targeted and we get a reasonable number detected on the first i.e monospace).
But still, fonts is a large chunk of the testing time taken. So that led me to another method which is to not use monospace, serif, sans-serif AT ALL in comparing, and to only measure against a single baseline
- so 100 fonts = 100 measurements - that's it, absolute minimum, end of story
I won't get into the nuts and bolts of it all, suffice to say that this protects against font config fubars (such as Tor Browser, true story, not whitelisting Menlo on mac and thus never rendering monospace at all, ever = fucks up all the tests), because the font base line is an expected font that the system must have, and this base line size doesn't have collisions except with other expected system fonts (usually one)
I only use this, so far, for windows and mac
So we've gone from 100 fonts taking 300 measurements, down to 100 measurements: 2/3rds time saved, which on 200ms is a LOT.
Which then brings me to how else to speed up the font enumeration tests. Again, the only way is to reduce the measurements, and we're now down to what fonts we test
So any font I can skip testing, because it adds nothing to entropy, then I save one measurement - i.e it is expected to exist so would be found on the first pass, so only one measurement saved.
e.g. windows OSes must have Times, Roman and Times New Roman. Probably because of their root origins, these three are always the same size. Same with Courier and Courier New. And some font names are aliases e.g. MS ゴシック = MS Gothic. So I only need to test for one of each
So by getting some data on size buckets, I can determine what other font names I can drop.
Now this is not the end of it (reducing font lists to be checked), because the sizes themselves are likely equivalency. So it's a balance between reducing size collisions but not compromising always getting as much entropy as possible on detected fonts.
edit: also the name of the game is NOT to detect all fonts, it is to maximize entropy
Debian 12 bookworm - FF105
3072 x 371.584 : Noto Sans Mono CJK HK, Noto Sans Mono CJK JP, Noto Sans Mono CJK KR, Noto Sans Mono CJK SC, Noto Sans Mono CJK TC 3440.6 x 319.666 : URW Chancery L, Z003 3644.86 x 334.25 : Standard Symbols L, Standard Symbols PS 3686.4 x 324.034 : Courier, Nimbus Mono L, Nimbus Mono PS 3687.2 x 319.366 : Courier New, Liberation Mono 3699.2 x 317.034 : Noto Serif Hebrew, OpenSymbol 3699.2 x 334.25 : Noto Sans Sinhala, Noto Serif Sinhala 3699.2 x 340.95 : Noto Sans Malayalam, Noto Serif Malayalam 3699.2 x 347.366 : Noto Sans Bengali, Noto Sans Devanagari, Noto Sans Gujarati, Noto Sans Gurmukhi 3699.2 x 348.834 : Noto Sans Armenian, Noto Sans Georgian, Noto Sans Hebrew, Noto Serif Armenian, Noto Serif Georgian 3699.2 x 349.416 : Noto Sans Buginese, Noto Sans Canadian Aboriginal, Noto Sans Cherokee, Noto Sans Ethiopic, Noto Sans Khmer, Noto Sans Oriya, Noto Sans Yi, Noto Serif Ethiopic, Noto Serif Khmer 3699.2 x 366.034 : Noto Sans Telugu, Noto Serif Telugu 3966.76 x 352.334 : Nimbus Sans, Nimbus Sans L 3967.26 x 307.416 : Arial, Liberation Sans 3968.26 x 342.416 : Nimbus Roman, Nimbus Roman No9 L 4038.1 x 371.584 : Noto Sans CJK HK Thin, Noto Sans CJK JP Thin, Noto Sans CJK KR Thin, Noto Sans CJK SC Thin, Noto Sans CJK TC Thin 4132.6 x 371.584 : Noto Sans CJK HK Light, Noto Sans CJK JP Light, Noto Sans CJK KR Light, Noto Sans CJK SC Light, Noto Sans CJK TC Light 4198.7 x 328.416 : URW Gothic, URW Gothic L 4230.86 x 371.584 : Noto Sans CJK HK DemiLight, Noto Sans CJK JP DemiLight, Noto Sans CJK KR DemiLight, Noto Sans CJK SC DemiLight, Noto Sans CJK TC DemiLight 4270 x 371.584 : Noto Sans CJK HK, Noto Sans CJK JP, Noto Sans CJK KR, Noto Sans CJK SC, Noto Sans CJK TC 4363.8 x 338.334 : P052, URW Palladio L 4374.46 x 371.584 : Noto Sans CJK HK Medium, Noto Sans CJK JP Medium, Noto Sans CJK KR Medium, Noto Sans CJK SC Medium, Noto Sans CJK TC Medium 4415.16 x 335.416 : C059, Century Schoolbook L 4423.64 x 339.5 : URW Bookman, URW Bookman L 4486.7 x 307.416 : DejaVu Sans, DejaVu Sans Light 4581.4 x 368.666 : Noto Serif CJK JP ExtraLight, Noto Serif CJK KR ExtraLight, Noto Serif CJK SC ExtraLight, Noto Serif CJK TC ExtraLight 4613.12 x 368.666 : Noto Serif CJK JP Light, Noto Serif CJK KR Light, Noto Serif CJK SC Light, Noto Serif CJK TC Light 4637.3 x 371.584 : Noto Sans CJK HK Black, Noto Sans CJK JP Black, Noto Sans CJK KR Black, Noto Sans CJK SC Black, Noto Sans CJK TC Black 4649.82 x 368.666 : Noto Serif CJK JP, Noto Serif CJK KR, Noto Serif CJK SC, Noto Serif CJK TC 4701.62 x 368.666 : Noto Serif CJK JP Medium, Noto Serif CJK KR Medium, Noto Serif CJK SC Medium, Noto Serif CJK TC Medium 4730.86 x 338.05 : D050000L, Dingbats 4753.44 x 368.666 : Noto Serif CJK JP SemiBold, Noto Serif CJK KR SemiBold, Noto Serif CJK SC SemiBold, Noto Serif CJK TC SemiBold 4922.12 x 368.666 : Noto Serif CJK JP Black, Noto Serif CJK KR Black, Noto Serif CJK SC Black, Noto Serif CJK TC Black fonts.js:33:11
@1Naim (or anyone with windows 11) .. @abrahamjuliot
Could do you do me a favor. I want to add some windows 11 only fonts, and would like you to test them for me.
To do so
- load https://arkenfox.github.io/TZP/tzp.html
- open console and type
injectwin11()- this will add a bunch of win11 only fonts and faces to the font list that is being tested
- then scroll down to the font section and click
rerun - then in the console type
checkwin11()- this will list what fonts and faces were found and not found
- then in the console type
listfontsizes()- so I can see all the size collisions
paste me the console bits: what was/wasn't found, and the size collisions
TIA ❤️ 💋 🍰 🍻
FONTS FOUND - none
FONTS NOT FOUND - all
FACES FOUND - none
FACES NOT FOUND - all
3072 x 298.5 : NSimSun, 宋体
3878.4 x 340 : Segoe UI Semilight, Yu Gothic UI Semilight
3976.26 x 296.5 : MS Shell Dlg, Microsoft Sans Serif
3990.4 x 340 : Segoe UI, Yu Gothic UI
4140.1 x 340 : Segoe UI Semibold, Yu Gothic UI Semibold
umm, did you rerun the font section, because you're not even showing Cascadia Code or Cascadia Mono which you should - https://github.com/arkenfox/TZP/issues/197#issuecomment-1263064802
yeah,

weird... you can always test font names one by one in https://arkenfox.github.io/TZP/tests/fontdebug.html, at least get something detected ... this is so weird, I might have to set up my new laptop (win10, brand new, sitting in a box for the last 9 months) ... hopefully I can upgrade to 11 without having to give MS an email account
Hmmm, after the rerun, click on the font names details on the tzp page (maybe I've screwed up what data I'm looking at?) - edit, nvm
@Thorin-Oakenpants
FONTS FOUND - none
FONTS NOT FOUND - all
FACES FOUND - none
FACES NOT FOUND - all
3072 x 296.5 : NSimSun, SimSun
3976.26 x 295 : MS Shell Dlg, Microsoft Sans Serif
Feel free to ask me to do more, I'm always happy to help.
3072 x 296.5 : NSimSun, SimSun
that's interesting ... I wouldn't have expected those to be the same size
me win7
3072 x 294": "FangSong", "SimHei", "SimSun"
3072 x 298.5": "KaiTi", "NSimSun", "宋体"
abraham win11 (IDK if he has SimSun as it wasn't listed in a size collision)
3072 x 298.5 : NSimSun, 宋体 // win11 doesn't ship with KaiTi
going back to the first result
1Naim : 3976.26 x 295 : MS Shell Dlg, Microsoft Sans Serif
Me : 3976.26 x 296.5: MS Shell Dlg, Microsoft Sans Serif
abraham : 3976.26 x 296.5: MS Shell Dlg, Microsoft Sans Serif
So something else affects the width: at least abraham + I seem to be the same. I do plan on building a test page to test all OS fonts and return same sizes etc
zoom affects sizes, but does that universally, so fonts still match other fonts. Same with changing layout.css.devPixelsPerPx e.g. to 1.1 (110%). I suspect system scaling would behave the same
Firefox 105, OS X 10.14.6
2752.44 x 307.2 : SignPainter, SignPainter-HouseScript 3586.56 x 329.6 : Bodoni 72, Bodoni 72 Oldstyle 3812.1 x 362 : Al Tarikh, Baghdad 3812.1 x 384.5 : Al Bayan, Al Nile 3812.1 x 384.6 : ITF Devanagari, ITF Devanagari Marathi 3812.1 x 387 : STIXIntegralsSm, STIXIntegralsUp, STIXIntegralsUpSm 3812.1 x 417 : Mishafi, Mishafi Gold 3812.1 x 640 : Noto Nastaliq Urdu, STIXSizeTwoSym 3812.1 x 674.5 : STIXIntegralsD, STIXIntegralsUpD 3812.1 x 798 : STIXSizeFourSym, STIXSizeThreeSym 3861.56 x 361.1 : Songti SC, Songti TC 3867.2 x 334 : Bangla Sangam MN, Malayalam Sangam MN 4091.1 x 384.6 : Kohinoor Bangla, Kohinoor Devanagari, Kohinoor Telugu 4092.76 x 361.1 : PingFang HK, PingFang SC, PingFang TC 4198.7 x 313.934 : Heiti SC, Heiti TC 4224 x 350 : Avenir Black, Avenir Black Oblique 4276.3 x 384.5 : Hiragino Maru Gothic Pro W4, Hiragino Maru Gothic ProN, Hiragino Maru Gothic ProN W4 4284.9 x 323.534 : Kannada MN, Oriya MN, Tamil MN, Telugu MN 4332.3 x 384.5 : Hiragino Kaku Gothic Pro W3, Hiragino Kaku Gothic ProN, Hiragino Kaku Gothic ProN W3, Hiragino Sans GB, Hiragino Sans GB W3, Hiragino Sans W3 4356.1 x 384.5 : Hiragino Mincho Pro W3, Hiragino Mincho ProN, Hiragino Mincho ProN W3 4511.14 x 384.5 : Hiragino Sans, Hiragino Sans W4 4668.76 x 384.5 : Hiragino Mincho Pro W6, Hiragino Mincho ProN W6 4702.54 x 384.5 : Hiragino Kaku Gothic Pro W6, Hiragino Kaku Gothic ProN W6, Hiragino Sans GB W6, Hiragino Sans W6 5102.54 x 384.5 : Hiragino Kaku Gothic Std W8, Hiragino Kaku Gothic StdN W8, Hiragino Sans W8
thanks for the mac info - definitely some saving to be made there (but I also need to expand the list with changes in the last two releases and additional option downloadable system fonts). I've been working on Tor Browser linux/windows fonts and FF windows fonts. I don't have a mac but will be working on those next - see https://github.com/arkenfox/TZP/issues/197 - @fxbrit will be getting some home assignments
windows
all 205 (was 251)
rfp 69 (was 115) (kBaseFonts - size collisions of expected)
tb 81 (was 159) (whitelist - size collisions of expected)
linux
tb 60 (was 134)
mac is currently
all 438 (this is too large)
rfp 213 (kBaseFonts)
tb 26 (whitelist - bundled (expected)) [note: still to add 123 bundled - size collisions]
so zooming can affect the font groupings, but I only found two fonts (CJK ones) on my windows 7 that changed: instead of being in their own group, they merged with three other CJK ones as I zoomed up in size. This is not a concern
what is a concern is that we have some different font groups on different windows results: for example, for 1Naim https://github.com/arkenfox/user.js/issues/1555#issuecomment-1262133460 has all sitka's the same, on my windows 10 VM they are not - they are each unique sizes. There's also some conflicting groupings with various UI fonts and Segoe - but they do always match something (that is always in the font testing list)
I copied over some win10 only fonts into a firefox/font profile and also got some groupings that can mimic what I have seen above, but not in windows 10 itself. So I am beginning to wonder if this is a case of windows 7 users, who had these fonts by default, upgraded to win10, where these fonts are now supplemental. And thus the differences in size groupings? Still doesn't explain, e.g Sitka.
Anyway, I have scaled back some of the reductions, currently at 219 windows fonts tested - until I can confirm from multiple resources. My windows 10 VM is not activated and doesn't allow me to download additonal/supplemental windows fonts. Time I set up my new latop, methinks.
Anyway, closing. Thanks for the help. It's been enlightening. ❤️
I will get mac results from the fish, and I have enough sources for windows. When needed I will open a new issue for Android and Linux.