Chrome 97以上可允许用户在不同的站点使用不同的缩放级别,但用户无法自定义缩放倍率
(如图)
试着测试了几个网站的自定义,并通过
chrome://version
(Edge浏览器为 edge://version )查询到配置文件目录
C:\Users\$username$\AppData\Local\Google\Chrome\User Data\Default
,得知此信息存储于文件 Preferences 中(如图)
发现zoom_level为神秘小数。通过更改不同的数据得到如下的拟合曲线
获得
的近似公式。
查阅chromium的相关源码,在文件 components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/PageZoomUtils.java 中有所描述:
*
* The zoom of a page is calculated internally with a base an exponent. The base is set to
* |kTextSizeMultiplierRatio| = 1.2. See: third_party/blink/common/page/page_zoom.cc.
* E.g. To get a zoom level of 25%, internally the number -7.6 is used, because: 1.2^-7.6 = 0.25.
*
* To help with confusion, we will consistently stick to the following verbiage:
*
* "zoom factor" = the internal number used by HostZoomMap, acts as the exponent. (double)
* "zoom level" = the percentage for the zoom that is presented externally to the user. (double)
* "zoom string" = the string that is actually presented to the user for zoom percentage. (String)
* "zoom seek value" = an arbitrary int to map the factor to an integer value for a SeekBar. (int)
*
* For example, some common zoom values are:
*
* string factor level seek value
* 25% | -7.6 | 0.25 | 0 |
* 50% | -3.8 | 0.50 | 5 |
* 100% | 0.0 | 1.00 | 16 |
* 250% | 5.03 | 2.50 | 47 |
* 500% | 8.83 | 5.00 | 100 |
*
*/
数学运算可得:x %对应的zl(zoom level)则为
为便于计算,换底得
计算得到zoom_level之后修改/添加配置文件 Preferences 中的相关参数即可。
(关于全局自定义缩放比例的相关教程站内已有描述,此处不再赘述)