[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font lists / font perf #197

Open
4 of 10 tasks
Thorin-Oakenpants opened this issue Sep 28, 2022 · 13 comments
Open
4 of 10 tasks

font lists / font perf #197

Thorin-Oakenpants opened this issue Sep 28, 2022 · 13 comments
Labels

Comments

@Thorin-Oakenpants
Copy link
Contributor
Thorin-Oakenpants commented Sep 28, 2022

posting so I have a record somewhere

currently

WINDOWS - isPlatformFont (single pass vs MS Shell Dlg \32 )

   all  219 (was 251)
   rfp   82 (was 115) (kBaseFonts - size collisions of expected)
    tb   83 (was 159) (whitelist - size collisions of expected)

todo:

  • keep trimming size collisions of expected fonts: e.g. "Cordia New", "CordiaUPC"
    • but make sure we keep at least one font from each of 8, 8.1, 10, 11
  • expand tb with bundled unique sizes
  • update with new win11 fonts - see this

MAC - isPlatformFont (single pass vs -apple-system)

   all  438 (this is too large)
   rfp  213 (kBaseFonts)
    tb   26 (whitelist - bundled (expected))

todo:

  • expand tb with bundled unique sizes
  • remove expected fonts with size collisions
  • update with fonts from last two (or is it three?) macOS releases
    • including optional fonts (which makes the list excessively big)
    • did we add san francisco?
    • should we add symbol
  • check if on mac when you add a "font", it adds all of them
    • e.g. if you add "Gill Sans", does it auto add "Gill Sans Light","Gill Sans SemiBold","Gill Sans UltraBold"

LINUX

   all  467
    tb   60 (was all 134 bundled)

currently checks against 3 basefonts (but skips subsequent basefonts if already detected). And super large list sucks. It needs a clean out. I wonder if we could try and detect a known common font from a select list (not noto, we want as unique a size as possible) and use the first found of those so we can do a single pass

todo:

  • tb: just one of each size
  • tb: add isPlatformFont, e.g. Arimo (something unique) since we are restricted to an always expected 134 fonts all fonts listed are expected so will be found on the first basefont anyway = same as a single pass not quite true, most fonts will be found on the first pass, and if I know Noto fonts from android, it takes all three basefonts to get everything
    • this does not work, but it's OK, see 8ac97bf
  • all: this is way too big: do some tests, remove shit old unlikely fonts, remove some size collisions if super common

ANDROID

   all  140

currently checks against 3 basefonts (but skips subsequent basefonts if already detected). It's not so bad at 140 fonts: e.g. my android finds 105 total: 100 or so on the first baseFont. But android is slow so anything here is a large gain

todo

  • all: add more noto fonts
  • all: reduce size collisions? yikes: this is noto, IDK what they results will be
  • if widget font is Roboto, and Roboto is unique, then isPlatformFont it for a single pass
    • or is Android always Roboto and we can ignore when widget font is protected (like in TB)?

reminder

to build a test page to compare three pass detected to single pass detected

use this page to also output the size buckets

@Thorin-Oakenpants
Copy link
Contributor Author
Thorin-Oakenpants commented Sep 30, 2022

win11 new fonts

fonts?
===
Cascadia Code
Cascadia Code ExtraLight
Cascadia Code Light
Cascadia Code SemiLight
Cascadia Code SemiBold
Cascadia Mono
Cascadia Mono ExtraLight
Cascadia Mono Light
Cascadia Mono SemiLight
Cascadia Mono SemiBold
Segoe Fluent Icons
Segoe UI Variable Display
Segoe UI Variable Display Light
Segoe UI Variable Display Semilight
Segoe UI Variable Display Semibold
Segoe UI Variable Small
Segoe UI Variable Small Light
Segoe UI Variable Small Semilight
Segoe UI Variable Small Semibold
Segoe UI Variable Text
Segoe UI Variable Text Light
Segoe UI Variable Text Semilight
Segoe UI Variable Text Semibold
Sitka Banner Semibold
Sitka Display Semibold
Sitka Small Semibold
Sitka Heading Semibold
Sitka Subheading Semibold
Sitka Text Semibold


faces?
===
Cascadia Code ExtraLight Italic
Cascadia Code Light Italic
Cascadia Code SemiLight Italic
Cascadia Code Italic
Cascadia Code SemiBold Italic
Cascadia Code Bold
Cascadia Code Bold Italic
Cascadia Mono ExtraLight Italic
Cascadia Mono Light Italic
Cascadia Mono SemiLight Italic
Cascadia Mono Italic
Cascadia Mono SemiBold Italic
Cascadia Mono Bold
Cascadia Mono Bold Italic
Segoe UI Variable Display Bold
Segoe UI Variable Small Bold
Segoe UI Variable Text Bold
Sitka Banner Semibold Italic
Sitka Display Semibold Italic
Sitka Small Semibold Italic
Sitka Heading Semibold Italic
Sitka Subheading Semibold Italic
Sitka Text Semibold Italic

So which ones are font-families and which ones are faces?

@abrahamjuliot Do you have access to a Win11 machine with these fonts?

@abrahamjuliot
Copy link
Collaborator

I'm seeing these as font families here. Matches my machine too.

Cascadia Code
Cascadia Mono
Segoe UI Variable Display
Segoe UI Variable Small
Segoe UI Variable Text
Segoe Fluent Icons
Sitka Banner
Sitka Display
Sitka Heading
Sitka Small
Sitka Subheading
Sitka Text

macOS Monterey fonts are now published. They are each Google Fonts.

https://support.apple.com/en-us/HT212587

K2D
Fahkwang
Charmonman
Chakra Petch 
Bai Jamjuree
Sarabun
Srisakdi
Kodchasan
KoHo

@Thorin-Oakenpants
Copy link
Contributor Author
Thorin-Oakenpants commented Sep 30, 2022

hmmm, that's weird .. doesn't seem to match other font naming conventions. Regular, you drop the regular part. Bold, Bold Italic and Italic are faces. Anything else is a font

e.g. Do you actually have these in c:\\windows\fonts ? - anyway, pinged you somewhere else with a full test

Cascadia Code ExtraLight
Cascadia Code Light
Cascadia Code SemiLight
Cascadia Code SemiBold

@abrahamjuliot
Copy link
Collaborator

correction: I'm confused.

If I run this in Chrome, I get the above returned as font families

console.log(await queryLocalFonts().then(fonts => [...new Set(fonts.map(font => font.family))].join('\n')))

Powershell also returns Segoe UI Variable Display as a family (no Segoe UI Variable family)

[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
(New-Object System.Drawing.Text.InstalledFontCollection).Families

image

Font folder

image

image

@abrahamjuliot
Copy link
Collaborator
abrahamjuliot commented Sep 30, 2022

FF Nightly

image

RFP

image

Chrome only works with "...Display" added

image

@Thorin-Oakenpants
Copy link
Contributor Author

Powershell also returns Segoe UI Variable Display as a family (no Segoe UI Variable family)
Chrome only works with "...Display" added

right, there is no such font as Segoe UI Variable or Segoe UI Variable Regular. That's the way I see it. In actual fact, to be sure of the font name, you open the font in windows and read the title/name: e.g.

@Thorin-Oakenpants
Copy link
Contributor Author

wow, so nothing was detected from all of these ... yikes, WTF is going on

@abrahamjuliot
Copy link
Collaborator

Yeah, it seems these are not available apart from CSS Font Loading API.

@Thorin-Oakenpants
Copy link
Contributor Author

Not even Segoe Fluent Icons ? The whole lot looks caputsky. I wonder if mozilla hasn't gotten around to adding them somewhere

I was planning on using the CSS Font Loading API to get win versions - I think you said it was super fast

@Thorin-Oakenpants
Copy link
Contributor Author

that's some sweet perf on that mini vid bro. 90ms (with the console open, on nightly which is slower). I'm around 135 nightly and 125 stable - it's approx 50/50 between glyphs/textmetrics + fonts sizes - and that's on a 12yr old machine

@abrahamjuliot
Copy link
Collaborator

sweet perf

Nice, I missed that. It's a custom tower. I think the fastest I can get on TZP is 178ms and 68ms on fonts. Actually, I mostly develop on this $100 Chromebook I got on eBay. It's stuck on Chrome 84, but I can test latest FF Android on it. I just remotely connect to more performant machines when I need to.

Segoe Fluent Icons

Yep, missing. Same in Chrome.

CSS Font Loading API

It's fast, doesn't touch the DOM, and runs asynchronous.

function getLocalFontFamily(font) {
    return new FontFace(font, `local("${font}")`)
        .load()
        .then((font) => font.family)
        .catch(() => null)
}

function loadFonts(fontList) {
    return Promise.all(fontList.map(getLocalFontFamily))
        .then(list => list.filter(font => font !== null))
}

loadFonts(['Segoe Fluent Icons']).then(fonts => console.log(fonts))

@Thorin-Oakenpants
Copy link
Contributor Author

It's fast

Great that it doesn't touch the DOM etc .. but this is not fast. I piped the default windows list of 219 fonts thru it and it took approx 200ms - but sure, on a few select fonts for extra entropy this can come in handy. By comparison, the getDimensions and touching the DOM takes approx 60ms, including an additional 10 base fonts and number crunching everything into pretty objects for FP storage

@abrahamjuliot
Copy link
Collaborator

It should speed up the overall script if run in a Promise.all execution.

 Promise.all([
   doSomeDomWork() // blocks other dom work or non-async operations (200ms)
   getFontFace() // runs in the event loop while doSomeDomWork() is running (200ms)
   getDomFonts() // waits for doSomeNonAsyncTask() to finish (50ms)
 ])
 
 // Overall time to complete ~250ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants