Skip to content

Repository files navigation

Font_Merger

Font Merger GUI / Font Merger 图形界面 / Font Merger 圖形介面

图形界面 / Graphical interface / 圖形介面

将 🀄️:🦜(= 2:1 的等宽)双字体并集(纯英字体所有字符,覆盖中文字体中的对应部分),生成中 + 英双语单字体。

Merge a 🀄️:🦜 dual-font pair (= 2:1 monospace), with every character from the Latin font overriding its counterpart in the Chinese font, into one bilingual font.

將 🀄️:🦜(= 2:1 等寬)的雙字型取聯集(純英文字型的所有字元覆蓋中文字型中的對應部分),生成中英雙語單一字型。

VS Code

VS Code font merging effect

Sublime Text

Sublime Text font merging effect

SilverBullet

SilverBullet font merging effect

目录 / Contents / 目錄


简体中文

项目简介

Font_Merger 是一个字体合并工具,用于生成中英文(等宽)混排字体家族。

作为示例,它将 Inconsolata 的 1 等宽西文字符与 LXGW Bright 的 2 等宽中文字符,拼合成一个统一的英:中 = 1:2 等宽字体,并支持多字重和样式(Regular、Medium、Bold、Italic 等)。

  • 合并一款西文字体和一款中文字体时,会自动让西文字体覆盖重复字符;输入顺序不影响结果。
  • 支持 TTF、OTF、TTC 和 OTC,也可以依次合并多个字体。
  • 支持微软雅黑等 .ttc 字体,无须预先拆分。
  • 自动修改字体内部名称,避免与原字体冲突。
  • 提供 Windows、Linux、macOS 单文件程序,无须安装 Python。
  • 默认根据输入字体自动选择可实现的输出字重;静态字体会约束可变字体,全部输入均为可变字体时才可能一次生成多个字重。

功能亮点

  1. 中英文混排优化:作为示例,英文使用 Inconsolata,中文使用 LXGW Bright,保持视觉一致的 2:1 等宽比例。
  2. 多字重支持:可生成 Regular、Medium、Bold、Italic 等不同字重和样式的字体。
  3. 字体集合支持:可以直接选择 TTC/OTC 中的字体,例如微软雅黑。
  4. 开箱即用:下载程序即可合并,生成的字体可直接安装使用。

使用方法

下载

在 Releases 下载适合你系统的文件:

  • Windows:font-merger-windows-x64.exe
  • Windows 图形界面:font-merger-gui-windows-x64.zip
  • Linux:font-merger-linux-x64
  • macOS(Apple Silicon / arm64):font-merger-macos-arm64
  • macOS(Intel / x64):font-merger-macos-x64

发布页同时提供 SHA256SUMS.txt,可用于校验下载文件的 SHA-256。

GUI(Windows 推荐)

下载图形界面压缩包,解压后双击 font-merger-gui-windows-x64.exe。添加字体、选择输出位置,再点击“开始合并”即可。界面支持简体中文、繁體中文和 English。若 Windows 文件选择器不显示 C:\Windows\Fonts,可点击与“添加字体”并列的“系统字体…”,按家族名、样式或文件名搜索系统级和当前用户安装的字体,并用 Ctrl / Shift 多选;TTC / OTC 会直接列出其中的各个字体。

默认设置适合大多数用户:当且仅当两个输入能被可靠识别为一款西文字体和一款 CJK 字体时,程序让西文字体覆盖英文等重复字符、由 CJK 字体补充其余字符,并以 CJK 字体的 UPM 和 Hinting 作为显示基准;此时两款字体的添加顺序不影响结果。其他组合(包括三个以上输入)默认按字体列表顺序决定字符优先级和显示基准。

字重默认使用 auto + nearest:只要存在静态字体,优先级最高的静态字体就作为字重基准,可变字体在可能时实例化到相同字重。例如静态西文字体为 350、CJK 可变字体支持 wght=100..900 时,会生成双方均为 350 的静态输出。全部输入都是可变字体时,程序以可用字重锚点较丰富的字体为基准,优先生成所有输入都能精确实现的字重。最近字重匹配默认不限制最大差值;需要严格匹配时可在高级设置中选择“必须精确匹配”或填写最大字重差。

家族名留空时,程序会用 + 连接去重后的源字体家族名;默认输出文件为当前目录的 merged.ttf,仅当实际生成多个字重时才在文件名后追加样式名。手动填写 wght=350 或固定实例会明确指定单一字重,GUI 因而自动恢复 weights=auto、清空并停用冲突的多字重设置。

命令行

把程序和字体放在同一文件夹,在该文件夹打开终端后运行:

./font-merger-windows-x64.exe "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" --family "Inconsolata-LXGWMono" --style Medium -o "Inconsolata-LXGWMono-Medium.ttf"

Linux 首次下载后先赋予执行权限,再使用 Linux 可执行文件:

chmod +x font-merger-linux-x64
./font-merger-linux-x64 "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" --family "Inconsolata-LXGWMono" --style Medium -o "Inconsolata-LXGWMono-Medium.ttf"

命令行使用与 GUI 相同的默认策略:--priority auto、--hinting-source auto、--weights auto、--weight-match nearest,最大字重差不设上限。未写 --family 时,输出家族名由去重后的源家族名以 + 连接;未写 -o 时输出文件名基准为 merged.ttf。合并无法识别为西文 + CJK 双字体的组合或三个以上字体时,字符优先级按输入顺序。

合并微软雅黑

TTC / OTC 是字体集合。先查看其中的字体:

./font-merger-windows-x64.exe --list "C:\Windows\Fonts\msyh.ttc"

再选择要使用的序号,例如 #0:

./font-merger-windows-x64.exe "Inconsolata-Medium.ttf" "C:\Windows\Fonts\msyh.ttc#0" --family "Inconsolata-YaHei" --style Medium -o "Inconsolata-YaHei-Medium.ttf"

路径中有 #0 时,请保留两边的英文双引号。

Hinting

一份字体只能安全使用一套 TrueType Hinting。中西文双字体默认以中文 / CJK 字体的 UPM 和 Hinting 为显示基准;这不会改变字形来源,英文和数字仍优先取自西文字体。源字体含可用 Hinting 时会优先保留。如果更在意西文 Hinting,可以加上:

--hinting-source latin

也可以选择 cjk、none 或输入字体序号,例如 --hinting-source 2。

多字重

默认自动规则:

  • 至少一个输入为静态字体:按字符优先级选取第一款静态字体作为字重基准;通常只生成它的实际字重,并让可变字体匹配该 wght,如静态 350 自动匹配可变 350。
  • 全部输入均为可变字体:以可用字重锚点最多的输入为基准,优先生成所有输入都能精确实现的命名字重;若没有共同锚点,则按默认的 nearest 规则使用各字体最接近的字重。
  • nearest 默认不限制最大字重差。可用 --weight-match exact 要求每个输入精确实现目标字重,或用 --max-weight-gap N 限制允许的差值。
  • Regular、Bold 分别合并时保持相同的家族名,安装后即可自动切换真正的粗体。
  • DemiLight、Medium 等扩展字重也使用相同的家族名,同时在样式名和 usWeightClass 中保留实际字重,便于现代 Windows、CSS 等按字重选择。
  • 这是面向现代字重选择的命名方式;只识别传统 Regular/Bold/Italic/Bold Italic 四成员家族的旧程序,可能无法完整列出扩展字重。
  • 若希望 Markdown/CSS 的 font-weight: bold 使用真实粗体,建议同时生成并安装 700/Bold;如果只安装 350/500,最终选择 500 还是合成粗体取决于应用自身的字体匹配规则。

可用 --list 查看字体包含的实例:

./font-merger-windows-x64.exe --list "C:\Windows\Fonts\NotoSansSC-VF.ttf"

face #0 只是 TTC / OTC 的字体序号,并非字重。需要手动覆盖时可写 --axis wght=350;默认情况下通常不必填写。--style、--instance 或 --axis wght=... 都表示只生成一个字重,不能再同时指定非 auto 的 --weights。

若需要兼容只按 Regular / Bold 名称匹配字体的旧软件,可以把视觉字重与输出样式元数据分开指定。例如 --axis wght=500 --style Bold 会按 500 的轮廓字重生成字体并保留 usWeightClass=500,同时把输出样式名称及 legacy Bold 标志写成 Bold。GUI 的高级设置中可使用“输出样式(元数据)”完成同样操作。这是一种兼容性覆盖,并不会把实际轮廓变成 700 字重。

如果同时指定命名实例和轴坐标(例如 --instance Bold --axis wght=500),显式轴坐标仍覆盖该实例的同名轴,但输出样式保留显式实例名 Bold;需要只覆盖命名而不依赖源字体存在 Bold 实例时,优先使用 --style Bold。

只需一个字重时明确指定实例:

./font-merger-windows-x64.exe "consolab.ttf" "NotoSansSC-VF.ttf" --instance Bold --family "Consolas Noto Sans SC" -o "Consolas-Noto-Bold.ttf"

需要更多控制时,可用 --weights latin、cjk、union、intersection 或 300,400,700。多个输出会基于 -o 指定的文件名自动追加 Thin、Regular、Bold 等样式名。

安装与使用

  • Windows:双击 TTF 文件 → 点击“安装”
  • macOS:双击 TTF 文件 → 安装到字体册
  • Linux:拷贝到 ~/.local/share/fonts/ → 运行 fc-cache -fv

Sublime Text 的 Preferences.sublime-settings:

{
    "font_face": "Inconsolata-LXGWMono",
    "font_size": 14
}

VS Code:管理 → 设置 → 搜索 Font Family:

'Inconsolata-LXGWMono', 'Source Han Mono SC', Consolas, 'Courier New', monospace

开发者

普通用户不需要安装 Python。源码运行方式:

python -m pip install -e .
font-merger "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" -o "merged.ttf"

GUI 使用 Python 标准库 Tkinter / ttk,字体处理使用 fontTools,并由 PyInstaller 打包为单文件程序。合并任务在后台线程运行;耗时主要取决于字体大小、字符数量和输出字重数量。

Windows 本地构建与测试:

python -m pip install -e ".[build]"
.\build-windows.ps1
.\run-gui-debug.ps1
.\run-gui-release.ps1

Release 单文件输出到 dist/local-release;带控制台与 PyInstaller 调试信息的 onedir GUI 输出到 dist/local-debug。启动脚本可加 -Build 强制重新构建。

字体合并不会改变源字体许可证。分享合并后的字体前,请确认所有源字体都允许这样使用。

同类工具调研与技术说明见 docs/research.md。

许可证

GPL-3.0

返回目录


English

Overview

Font_Merger merges fonts into a family designed for mixed Chinese and Latin monospace text.

For example, it combines the single-width Latin glyphs of Inconsolata with the double-width Chinese glyphs of LXGW Bright to create a consistent 1:2 Latin-to-Chinese monospace font. Multiple weights and styles such as Regular, Medium, Bold, and Italic are supported.

  • When merging one Latin font with one CJK font, Latin glyphs automatically override duplicate characters; input order does not matter.
  • Supports TTF, OTF, TTC, and OTC files, plus sequential merging of multiple fonts.
  • Uses .ttc fonts such as Microsoft YaHei directly, without extracting them first.
  • Renames the merged font internally to avoid conflicts with its source fonts.
  • Provides standalone Windows, Linux, and macOS programs; Python is not required.
  • Selects realizable output weights automatically: static inputs constrain variable fonts, while an all-variable set may produce multiple weights in one run.

Highlights

  1. Optimized mixed text: for example, Inconsolata for Latin and LXGW Bright for Chinese preserve a visually consistent 2:1 monospace ratio.
  2. Multiple weights: generate Regular, Medium, Bold, Italic, and other weights or styles.
  3. Font collections: select a font directly from a TTC/OTC collection such as Microsoft YaHei.
  4. Ready to use: download, merge, and install the generated font.

Usage

Download

Get the file for your system from Releases:

  • Windows: font-merger-windows-x64.exe
  • Windows GUI: font-merger-gui-windows-x64.zip
  • Linux: font-merger-linux-x64
  • macOS (Apple Silicon / arm64): font-merger-macos-arm64
  • macOS (Intel / x64): font-merger-macos-x64

Releases also include SHA256SUMS.txt for verifying downloaded files with SHA-256.

GUI (recommended on Windows)

Download and extract the GUI archive, then double-click font-merger-gui-windows-x64.exe. Add fonts, choose an output path, and click “Merge fonts.” The interface supports Simplified Chinese, Traditional Chinese, and English. If the Windows file picker does not show C:\Windows\Fonts, use “System fonts…” beside “Add fonts” to search system-wide and per-user fonts by family, style, or file name and select multiple entries with Ctrl / Shift. Each face in a TTC / OTC collection is listed directly.

The defaults suit most users. If and only if two inputs can be identified reliably as one Latin and one CJK font, the Latin font supplies overlapping characters, the CJK font supplies the rest, and the CJK font provides the UPM and hinting baseline. Input order does not matter for that detected pair. Other combinations, including three or more inputs, use font-list order for glyph priority and the display baseline.

The default weight policy is auto + nearest. If any input is static, the highest-priority static font becomes the weight reference and variable fonts are instantiated at the same weight when possible. For example, a static Latin face at 350 and a CJK variable font supporting wght=100..900 produce a static 350 output. When every input is variable, the font with the richest set of useful weight anchors becomes the reference, with weights that every input can realize exactly preferred. Nearest matching has no maximum gap by default; choose “Require an exact match” or enter a maximum weight gap in Advanced settings when stricter matching is required.

If Family is blank, unique source family names are joined with +. The default output is merged.ttf in the current directory, and a style suffix is added only when the run actually generates multiple weights. Entering wght=350 or a named instance explicitly requests one weight, so the GUI resets weights to auto, clears, and disables the conflicting multi-weight controls.

Command line

Put the program and fonts in one folder, open a terminal there, and run:

./font-merger-windows-x64.exe "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" --family "Inconsolata-LXGWMono" --style Medium -o "Inconsolata-LXGWMono-Medium.ttf"

On Linux, make the downloaded binary executable once, then run the Linux build:

chmod +x font-merger-linux-x64
./font-merger-linux-x64 "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" --family "Inconsolata-LXGWMono" --style Medium -o "Inconsolata-LXGWMono-Medium.ttf"

The CLI uses the same defaults as the GUI: --priority auto, --hinting-source auto, --weights auto, and --weight-match nearest, with no maximum weight gap. Without --family, unique source family names are joined with +; without -o, the output base name is merged.ttf. Combinations that are not detected as a Latin/CJK pair, and runs with three or more fonts, use input order for glyph priority.

Merge Microsoft YaHei

TTC and OTC files are font collections. First list the fonts inside:

./font-merger-windows-x64.exe --list "C:\Windows\Fonts\msyh.ttc"

Then select an index such as #0:

./font-merger-windows-x64.exe "Inconsolata-Medium.ttf" "C:\Windows\Fonts\msyh.ttc#0" --family "Inconsolata-YaHei" --style Medium -o "Inconsolata-YaHei-Medium.ttf"

Keep the double quotes around a path that contains #0.

Hinting

A font can safely use only one set of TrueType hinting. For a Latin/CJK pair, the default uses the CJK font's UPM and hinting as the display baseline. This does not change glyph ownership: Latin letters and digits still come from the Latin font. Usable source hinting is preserved when possible. To prioritize Latin hinting instead, add:

--hinting-source latin

You can also choose cjk, none, or an input font number such as --hinting-source 2.

Multiple weights

Default automatic rules:

  • At least one static input: the first static font in glyph-priority order becomes the weight reference. Normally its actual weight is the sole target, and variable fonts match that wght, such as static 350 selecting variable 350.
  • All inputs variable: the input exposing the most useful weight anchors becomes the reference. Anchors that every input can realize exactly are preferred; if there are no shared anchors, each font uses its nearest weight under the default nearest rule.
  • nearest has no maximum gap by default. Use --weight-match exact to require every input to realize a target exactly, or --max-weight-gap N to limit the allowed difference.
  • When Regular and Bold are merged separately, keep the same family name so applications can select the real Bold automatically.
  • Extended weights such as DemiLight and Medium also use the same family name while retaining their actual style name and usWeightClass, allowing modern Windows and CSS clients to select by weight.
  • This naming favors modern weight selection. Legacy applications limited to four-member Regular/Bold/Italic/Bold Italic families may not enumerate every extended weight correctly.
  • To make Markdown/CSS font-weight: bold use a real bold face, generate and install 700/Bold as well. If only 350/500 are installed, whether 500 is selected or bold is synthesized depends on the application's font-matching rules.

List the instances in a font with --list:

./font-merger-windows-x64.exe --list "C:\Windows\Fonts\NotoSansSC-VF.ttf"

face #0 is only the font index in a TTC/OTC collection, not a weight. Use --axis wght=350 to override automatic matching; it is normally unnecessary. --style, --instance, and --axis wght=... each request a single output weight and therefore cannot be combined with a non-auto --weights value.

For legacy applications that match fonts by Regular / Bold naming rather than numeric weight, the visual weight and output style metadata can be specified independently. For example, --axis wght=500 --style Bold keeps the outlines and usWeightClass=500 while writing the output style names and legacy Bold flags as Bold. The GUI exposes the same behavior as “Output style (metadata)” in Advanced settings. This is a compatibility override; it does not turn the outlines into a true 700-weight face.

When both a named instance and axis coordinates are given (for example, --instance Bold --axis wght=500), explicit axis values still override the matching coordinates from the instance, while the output style keeps the explicitly requested instance name Bold. If you only need to override naming and do not want to require a Bold named instance in every variable input, prefer --style Bold.

To generate only one weight, select its instance explicitly:

./font-merger-windows-x64.exe "consolab.ttf" "NotoSansSC-VF.ttf" --instance Bold --family "Consolas Noto Sans SC" -o "Consolas-Noto-Bold.ttf"

For more control, use --weights latin, cjk, union, intersection, or a list such as 300,400,700. Multiple outputs automatically receive Thin, Regular, Bold, and similar style suffixes based on the file name supplied with -o.

Install and use

  • Windows: double-click the TTF file → click “Install”
  • macOS: double-click the TTF file → install it in Font Book
  • Linux: copy it to ~/.local/share/fonts/ → run fc-cache -fv

In Sublime Text's Preferences.sublime-settings:

{
    "font_face": "Inconsolata-LXGWMono",
    "font_size": 14
}

In VS Code, open Manage → Settings and search for Font Family:

'Inconsolata-LXGWMono', 'Source Han Mono SC', Consolas, 'Courier New', monospace

Developers

Regular users do not need Python. To run from source:

python -m pip install -e .
font-merger "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" -o "merged.ttf"

The GUI uses Python's standard Tkinter/ttk library, font processing uses fontTools, and PyInstaller produces standalone executables. Merging runs in a background thread; performance mainly depends on font size, glyph count, and the number of output weights.

For local Windows builds and testing:

python -m pip install -e ".[build]"
.\build-windows.ps1
.\run-gui-debug.ps1
.\run-gui-release.ps1

Release one-file executables are written to dist/local-release. The onedir GUI with a console and PyInstaller diagnostics is written to dist/local-debug. Add -Build to either launcher to force a rebuild.

Merging does not change the licenses of the source fonts. Before sharing a merged font, confirm that every source font permits that use.

See docs/research.md for related-tool research and technical notes.

License

GPL-3.0

Back to contents


繁體中文

專案簡介

Font_Merger 是一款字型合併工具,用於產生適合中英文等寬混排的字型家族。

例如,它會將 Inconsolata 的單倍寬西文字元與 LXGW Bright 的雙倍寬中文字元,合成統一的英:中 = 1:2 等寬字型,並支援多種字重與樣式(Regular、Medium、Bold、Italic 等)。

  • 合併一款西文字型與一款中文字型時,會自動讓西文字型覆蓋重複字元;輸入順序不影響結果。
  • 支援 TTF、OTF、TTC 與 OTC,也能依序合併多個字型。
  • 可直接使用微軟雅黑等 .ttc 字型,無須預先拆分。
  • 自動修改字型內部名稱,避免與來源字型衝突。
  • 提供 Windows、Linux、macOS 單一執行檔,無須安裝 Python。
  • 預設依輸入字型自動選擇可實現的輸出字重;靜態字型會約束可變字型,所有輸入皆為可變字型時才可能一次產生多個字重。

功能亮點

  1. 中英文混排最佳化:例如英文使用 Inconsolata、中文使用 LXGW Bright,維持視覺一致的 2:1 等寬比例。
  2. 多字重支援:可產生 Regular、Medium、Bold、Italic 等不同字重與樣式。
  3. 字型集合支援:可直接選擇 TTC/OTC 中的字型,例如微軟雅黑。
  4. 開箱即用:下載程式即可合併,產生的字型可直接安裝使用。

使用方式

下載

前往 Releases 下載適合你系統的檔案:

  • Windows:font-merger-windows-x64.exe
  • Windows 圖形介面:font-merger-gui-windows-x64.zip
  • Linux:font-merger-linux-x64
  • macOS(Apple Silicon / arm64):font-merger-macos-arm64
  • macOS(Intel / x64):font-merger-macos-x64

Release 頁面也會提供 SHA256SUMS.txt,可用來驗證下載檔案的 SHA-256。

GUI(Windows 推薦)

下載圖形介面壓縮檔,解壓縮後按兩下 font-merger-gui-windows-x64.exe。加入字型、選擇輸出位置,再按一下「開始合併字型」即可。介面支援簡體中文、繁體中文與 English。若 Windows 檔案選擇器未顯示 C:\Windows\Fonts,可按一下與「加入字型」並列的「系統字型…」,依家族名稱、樣式或檔名搜尋系統層級和目前使用者安裝的字型,並用 Ctrl / Shift 多選;TTC / OTC 會直接列出其中各個字型。

預設設定適合大多數使用者:僅當兩個輸入能可靠辨識為一款西文字型與一款 CJK 字型時,程式才會讓西文字型提供英文等重複字元、由 CJK 字型補充其餘字元,並以 CJK 字型的 UPM 與 Hinting 作為顯示基準;此時兩款字型的加入順序不影響結果。其他組合(包括三個以上輸入)預設依字型清單順序決定字元優先順序與顯示基準。

字重預設使用 auto + nearest:只要存在靜態字型,優先順序最高的靜態字型就會作為字重基準,可變字型則在可行時實例化為相同字重。例如靜態西文字型為 350、CJK 可變字型支援 wght=100..900 時,會產生雙方均為 350 的靜態輸出。所有輸入皆為可變字型時,程式以可用字重錨點較豐富的字型為基準,優先產生所有輸入都能精確實現的字重。最近字重配對預設不限制最大差值;需要嚴格配對時,可在進階設定中選擇「必須精確配對」或填寫最大字重差。

家族名稱留空時,程式會以 + 連接去重後的來源字型家族名稱;預設輸出檔案是目前目錄的 merged.ttf,只有實際產生多個字重時才會在檔名後加入樣式名稱。手動填寫 wght=350 或固定實例會明確指定單一字重,因此 GUI 會自動恢復 weights=auto、清空並停用衝突的多字重設定。

命令列

將程式與字型放在同一個資料夾,在該資料夾開啟終端機後執行:

./font-merger-windows-x64.exe "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" --family "Inconsolata-LXGWMono" --style Medium -o "Inconsolata-LXGWMono-Medium.ttf"

Linux 第一次下載後先賦予執行權限,再使用 Linux 執行檔:

chmod +x font-merger-linux-x64
./font-merger-linux-x64 "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" --family "Inconsolata-LXGWMono" --style Medium -o "Inconsolata-LXGWMono-Medium.ttf"

命令列使用與 GUI 相同的預設策略:--priority auto、--hinting-source auto、--weights auto、--weight-match nearest,且最大字重差沒有上限。未指定 --family 時,輸出家族名稱由去重後的來源家族名稱以 + 連接;未指定 -o 時,輸出檔名基準為 merged.ttf。無法辨識為西文 + CJK 雙字型的組合或三個以上字型,會依輸入順序決定字元優先順序。

合併微軟雅黑

TTC / OTC 是字型集合。先查看其中的字型:

./font-merger-windows-x64.exe --list "C:\Windows\Fonts\msyh.ttc"

再選擇要使用的編號,例如 #0:

./font-merger-windows-x64.exe "Inconsolata-Medium.ttf" "C:\Windows\Fonts\msyh.ttc#0" --family "Inconsolata-YaHei" --style Medium -o "Inconsolata-YaHei-Medium.ttf"

路徑中含有 #0 時,請保留兩側的英文雙引號。

Hinting

一份字型只能安全使用一套 TrueType Hinting。中西文雙字型預設以中文 / CJK 字型的 UPM 與 Hinting 作為顯示基準;這不會改變字形來源,英文與數字仍優先取自西文字型。來源字型含有可用的 Hinting 時會優先保留。若更重視西文 Hinting,可加入:

--hinting-source latin

也可以選擇 cjk、none 或輸入字型編號,例如 --hinting-source 2。

多字重

預設自動規則:

  • 至少一個輸入為靜態字型:依字元優先順序選取第一款靜態字型作為字重基準;通常只產生其實際字重,並讓可變字型配對該 wght,例如靜態 350 自動配對可變 350。
  • 所有輸入皆為可變字型:以可用字重錨點最多的輸入為基準,優先產生所有輸入都能精確實現的命名字重;若沒有共同錨點,則依預設的 nearest 規則使用各字型最接近的字重。
  • nearest 預設不限制最大字重差。可用 --weight-match exact 要求每個輸入精確實現目標字重,或用 --max-weight-gap N 限制允許的差值。
  • Regular、Bold 分別合併時保持相同家族名稱,安裝後即可自動切換真正的粗體。
  • DemiLight、Medium 等延伸字重也使用相同家族名稱,同時在樣式名稱與 usWeightClass 中保留實際字重,方便現代 Windows、CSS 等依字重選擇。
  • 這是偏向現代字重選擇的命名方式;只支援傳統 Regular/Bold/Italic/Bold Italic 四成員家族的舊程式,可能無法完整列出延伸字重。
  • 若希望 Markdown/CSS 的 font-weight: bold 使用真正的粗體,建議同時產生並安裝 700/Bold;若只安裝 350/500,最終選擇 500 或合成粗體取決於應用程式本身的字型配對規則。

可用 --list 查看字型包含的實例:

./font-merger-windows-x64.exe --list "C:\Windows\Fonts\NotoSansSC-VF.ttf"

face #0 只是 TTC / OTC 的字型編號,並非字重。需要手動覆蓋時可寫 --axis wght=350;預設情況通常不必填寫。--style、--instance 或 --axis wght=... 都表示只產生一個字重,不能再同時指定非 auto 的 --weights。

若要相容只依 Regular / Bold 名稱配對字型的舊軟體,可以分別指定視覺字重與輸出樣式中繼資料。例如 --axis wght=500 --style Bold 會依 500 的輪廓字重產生字型並保留 usWeightClass=500,同時把輸出樣式名稱與 legacy Bold 標誌寫成 Bold。GUI 的進階設定可使用「輸出樣式(中繼資料)」完成相同行為。這是相容性覆蓋,不會把實際輪廓變成 700 字重。

若同時指定命名實例與軸座標(例如 --instance Bold --axis wght=500),明確的軸座標仍會覆蓋實例中的同名軸,但輸出樣式會保留明確指定的 Bold 實例名稱;若只想覆蓋命名而不要求每個來源可變字型都具有 Bold 實例,請優先使用 --style Bold。

只需要一個字重時,請明確指定實例:

./font-merger-windows-x64.exe "consolab.ttf" "NotoSansSC-VF.ttf" --instance Bold --family "Consolas Noto Sans SC" -o "Consolas-Noto-Bold.ttf"

需要更多控制時,可使用 --weights latin、cjk、union、intersection 或 300,400,700。多個輸出會依 -o 指定的檔名自動加入 Thin、Regular、Bold 等樣式名稱。

安裝與使用

  • Windows:按兩下 TTF 檔案 → 按一下「安裝」
  • macOS:按兩下 TTF 檔案 → 安裝至「字體簿」
  • Linux:複製至 ~/.local/share/fonts/ → 執行 fc-cache -fv

Sublime Text 的 Preferences.sublime-settings:

{
    "font_face": "Inconsolata-LXGWMono",
    "font_size": 14
}

VS Code:管理 → 設定 → 搜尋 Font Family:

'Inconsolata-LXGWMono', 'Source Han Mono SC', Consolas, 'Courier New', monospace

開發者

一般使用者不需要安裝 Python。從原始碼執行的方式:

python -m pip install -e .
font-merger "Inconsolata-Medium.ttf" "LXGWBright-Medium.ttf" -o "merged.ttf"

GUI 使用 Python 標準函式庫 Tkinter / ttk,字型處理使用 fontTools,並由 PyInstaller 打包為單一執行檔。合併工作會在背景執行緒中執行;耗時主要取決於字型大小、字元數量與輸出字重數量。

Windows 本機建置與測試:

python -m pip install -e ".[build]"
.\build-windows.ps1
.\run-gui-debug.ps1
.\run-gui-release.ps1

Release 單一執行檔會輸出至 dist/local-release;含主控台與 PyInstaller 偵錯資訊的 onedir GUI 會輸出至 dist/local-debug。啟動腳本可加上 -Build 強制重新建置。

字型合併不會改變來源字型的授權條款。分享合併後的字型前,請確認所有來源字型都允許這種用途。

同類工具研究與技術說明請見 docs/research.md。

授權

GPL-3.0

返回目錄

About

Merge Chinese font + English font by Taking the union of the two sets. (English sets cover that of Chinese)

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages