[webkit-help] How does mobile webkit's auto text resizing algorithm work?

Toby Ho airportyh at gmail.com
Wed Aug 15 19:28:33 PDT 2012

Hello all,

I am currently investigating how the auto text resizing on mobile
webkit works, more specifically iOS. My end goal is to reverse
engineer the algorithm using Javascript, so that I can on a desktop
webkit browser mimic what it should look like on the device.

My current approach is black box testing, but this has not been very
fruitful as of yet: it seems I keep uncovering more layers of
complexity. Here are some things I have found so far:

1. there's a correlation between the final font-size and the container's width
2. there's also a correlation with the length of text, for example, in
one test, when the length of the paragraph cross the threshold ~165
characters, the font size increases by 1 or 2 pxs
3. it also depends on the number of elements on the page that has
text. For example, there's only one element on the entire page with
text in it, then the auto resizing doesn't seem to kick in at all
4. when you have multiple elements on the page with text, the final
font size seems to be determined by a combination of the widths and
the lengths of the texts within all the elements

If someone could give me more detail or guidance on how this algorithm
works, or at least where to dig deeper, I'd greatly appreciate it.


More information about the webkit-help mailing list