Windows 11 字體渲染折騰個底掉

更新了 Windows 11 ,在 Intel 12 大小核的調度下,系統運行極其穩定、平滑。

唯 x 讓人不滿意的有幾點:

  1. 字體渲染,喪心病狂的比 Win 10 還拉跨。極端銳化,看得我老眼昏花,看着屏幕完全無法對焦。
  2. 任務欄無法選擇不合並,必須借用第三方工具,如:StartAllBack
  3. 右鍵菜單,設計簡化其實挺好的,原有的菜單功能(如 7zip 解壓),必須二層菜單,非常麻煩,可以參考:Windows11恢復Windows10右鍵菜單樣式

2-3 都有解決方案(2 要掏錢,所以就勉強忍耐了,畢竟用了那麼久 OSX),唯獨 1 這字體,真的看着巨難受,實在無法忍。

本文針對 1 字體渲染的問題,有以下的折騰優化方案,操作有兩步:

  1. 安裝 mactype
  2. Chrome/Edge 安裝 Tampermonkey 或 Violentmonkey,添加如下腳本:

以下腳本源自:https://n2o.io/go?page=userstyles

原安裝腳本:https://greasyfork.org/zh-CN/scripts/419362-%E5%85%A8%E5%B1%80%E6%80%9D%E6%BA%90%E9%BB%91%E4%BD%93

// ==UserScript==
// @name 全局思源黑體
// @namespace franciszhao
// @version 2.2.9-alpha
// @description 一款使用 Adobe 品牌字體替換網頁原有字體的用戶樣式表,爲你呈現更統一美觀的頁面風格。
// @author Francis Zhao <[email protected]>
// @homepageURL https://n2o.io/go?page=userstyles
// @supportURL https://n2o.io/go?page=userstyles
// @license MIT
// @grant GM_addStyle
// @run-at document-end
// @include *
// ==/UserScript==
(
  () => {
    (
      function () {
        'use strict';
        var u = `html {
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
  text-rendering: optimizeLegibility !important;
}

body, p {
  font-family: \${rootFont} !important;
  font-weight: 400 !important;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Roboto Condensed", \${rootFont} !important;
  font-weight: 500 !important;
}

strong, b, th {
  font-family: "Roboto Condensed", \${rootFont} !important;
  font-weight: 500 !important;
}

button,
input,
keygen,
optgroup,
select,
textarea {
  font-family: \${rootFont} !important;
}

code,
kbd,
pre,
samp {
  font-family: \${monoFont} !important;
}
`, o;
        (
          function (t) {
            t[t.default = 0] = 'default', t[t.monospace = 1] = 'monospace';
          }
        )(o || (
          o = {}
        ));
        const m = '"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", emoji',
              r = (t = 0) => {
                switch (t) {
                  case 1:
                    return `monospace, ${m}`;
                }
                return `system-ui, -apple-system, sans-serif, ${m}`;
              },
              f = (t, n = 0) => t == null ? r(n) : Array.isArray(t) ? [
                ...t.filter(Boolean).map(e => `"${e}"`),
                r(n),
              ].filter(Boolean).join(',') : typeof t != 'string' || t.trim() === '' ? r(n) : [t, r(n)].join(','),
              i = {},
              h = t => t === 'monoFont' ? o.monospace : o.default,
              d = (t, n) => (
                i[t] == null && (
                  /font/i.test(t) ? i[t] = f(n, h(t)) : i[t] = n + ''
                ), i[t]
              ),
              g = (t, n, e) => t.replace(/\${([^{}]+)}/gm, (c, a) => d(a, n[a] || null)) + `
` + e;
        (
          (t, n, e, c, a) => {
            if (t == null || t.getElementById(e)) return;
            const p = () => {
              try {
                const s = g(u, c, a), l = t.createElement('style');
                l.setAttribute('id', e), l.appendChild(t.createTextNode(s)), (
                  t.head || t.querySelector('head') || t.documentElement
                ).appendChild(l);
              } catch (s) {
                console.warn(`inject reset styles error: ${s.message}`);
              }
            };
            n ? t.addEventListener('DOMContentLoaded', function () {
              p();
            }) : p();
          }
        )(
          document,
          // 是否使用 dom ready 注入樣式
          false,
          // 注入樣式 id
          `__reset_style_${new Date().valueOf()}_${Math.floor(Math.random() * 1e5)}`,
          // 字體配置
          {
            rootFont: [
              'Roboto',
              'PingFang SC',
            ],
            monoFont: [
              'JetBrains Mono',
              'PingFang SC',
            ],
          },
          // 額外注入的樣式
          '',
        );
      }
    )();
  }
)();

以上腳本爲本地開發後經 vite 轉譯,之後會將這個構建代碼開源出來。

是否啓用 dom ready ,有些網站存在延遲加載樣式的情況,使得注入的樣式被後續覆蓋,使用 dom ready 能較好的解決此問題,但就會存在頁面加載時一閃的情況(先按照網站原來的字體樣式渲染,而後 dom ready 才注入 reset 樣式)。

至此,Win 11 內的字體渲染,基本接近 OSX 的水平,上截圖:

開源中國首頁截圖

WebStorm界面

百度截圖

輸入法問題

這又是一個老問題,話說 OSX 更新到 12 以後,輸入法切換徹底進入 Win 8-10 的恐怖年代。新版本增加了一個地球儀鍵來切換輸入法,又擯棄了 Caps lock 鍵,這就和搜狗輸入法的配置又存在衝突了。

而且以前可以刪除掉默認的英文,只保留一種輸入法。12 又不允許了。

而且輸入法/英文,各個窗口不停的在重置,簡直把人逼瘋了。

直接倒退回到 2014 年的水平,X你個輸入法

這次換回 Win 11,輸入法問題有了新的解決辦法。

  1. 不安裝任何輸入法,就使用系統自帶的微軟輸入法。

  2. 修改輸入法按鍵設置,我去掉了 <kbd>Shift</kbd> ,改爲 <kbd>Ctrl + Space</kbd> ,因爲很容易誤觸(比如輸入大寫,可能存在 <kbd>shift</kbd> 先按或後離開導致誤觸):

    修改輸入法按鍵設置

  3. 安裝 PowerToys,微軟團隊官方出品:

    下載 PowerToys

  4. 打開 PowerToys 的鍵盤管理器,添加 <kbd>Caps Lock</kbd> to <kbd>Ctrl + Space</kbd>。

    添加鍵映射

到此,即可輕鬆實現 OSX 10-11 時期 Caps Lock 切換輸入法,非常簡單有效。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章