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 stuff #150

Open
Thorin-Oakenpants opened this issue Mar 1, 2022 · 3 comments
Open

font stuff #150

Thorin-Oakenpants opened this issue Mar 1, 2022 · 3 comments
Labels

Comments

@Thorin-Oakenpants
Copy link
Contributor

is it possible to make the font sizes in the the unicode glyphs test, zoom resistant?

This has been on my mind. There is a method I use to harden unicode metrics (emojis & glyphs). Instead of using the text pixel sizes as the metric, I look for the first occurrences of unique dimensions and then the final set is the metric. I also reduce the dimensions in the set to a sum. Then, if we change the screen device pixel ratio or font size, this unique set (but not the sum) should remain the same.

const unicodeSet = new Set()

// loop through the results... and then add new metrics to the set
const metricAsString = "200 x 300"// example
if (!unicodeSet.has(metricAsString)) {
  unicodeSet.add(metricAsString)
}

const uniqueList = [...unicodeSet] // cast set to array
const sum = uniqueList.reduce((acc, x) => acc += x.split(' x ').reduce((acc, x) => acc += Number(x), 0), 0)

Originally posted by @abrahamjuliot in #49 (comment)

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented May 6, 2022

I also reduce the dimensions in the set to a sum

I'm not quite following what is being summed

  • each code point's width+height
  • all the widths as one result and all the heights as another
  • everything

I do not like the sound of this, seems like collisions would happen - e.g. 100 x 200 = 200 x 100 = 20 x 1000 - probably not likely given a small sample size. Tell me more

Unique set: not 100% sure on exactly how system scaling, dpi and devicePixelRatio (subpixels) may affect this, but I think this would lead to less entropy, because the same font users (think platform and limited font visibility such as RFP or Brave) are going to returning the same relative measurements, and same sets of unique measurement won't change (i.e if A, B and C are the same size, that's not going to change for like platforms and fonts)

  • user A : 975 x 1875 (glyphs A etc), 1621 x 1454 (glyphs B etc(
  • user B is 780 x 1500, 1297 x 1163 (decimals rounded)
  • user B is at 80% because system scaling is at 125% (or something)

Maybe I'm missing something but to me you would return glyph sets for both as A, B and lose entropy

@abrahamjuliot
Copy link
Collaborator

abrahamjuliot commented May 8, 2022

summed/collision

I collect each unique set of width x height, then sum them all together. Yeah, collision can happen. A hash of the collection is best.

system scaling/entropy

I'm re-evaluating this, and I don't think it works beyond monospaced fonts. That's true, the unique set of code points' has less entropy than the unique dimension. We could use both, but it may not be worth it.

I recently stopped using the monospace font and the former hardened set now runs wild. I'm instead using a font-family short list. It defaults to a platform or OS release font if available. The entropy is much higher with far less collision between OS releases. The list is not ideal for testing all code points, though.

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented May 10, 2022

I'm going to be adding in code points per size - per script and globally .. to my fontscript page (which doubles as a code point generator and fingerprint data collector for analysis)

  • for example, on win7, I see a lot of the CJK all render the same size (per script)

It's a bit of a hack to sort the width x height buckets .. sigh

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