ysc3839 / FontMod

Simple hook tool to change Win32 program font.
MIT License
1.29k stars 62 forks source link
arm arm64 dll-hijack dll-hijacking gdi gdiplus hook hooks windows

FontMod

English 简体中文 繁体中文

Simple hook tool to change Win32 program font. Works with some GDI/GDI+ or Qt based program.

Proven workable on Telegram Desktop, Kleopatra (Gpg4Win) and Mendeley Desktop.

Usage

Download FontMod{32,64,ARM,ARM64}.dll and rename to one of following:
dinput8.dll, dinput.dll, dsound.dll, d3d9.dll, d3d11.dll, ddraw.dll, winmm.dll, version.dll, d3d8.dll (d3d8.dll is 32bit only).
Then put in the folder of program exe.
User font: Put fonts in fonts folder to use them directly, don't need to install to system.

Config file

Will create FontMod.yaml on first run. Config file uses UTF-8 encoding. Support UTF-8 BOM.

style: &style
# Remove '#' to override font style
#  size: 0
#  width: 0
#  weight: 0
#  italic: false
#  underLine: false
#  strikeOut: false
#  charSet: 0
#  outPrecision: 0
#  clipPrecision: 0
#  quality: 0
#  pitchAndFamily: 0

fonts:
  SimSun: &zh-cn-font # Chinese (Simplified) fallback font
    replace: Microsoft YaHei
    <<: *style
  PMingLiU: # Chinese (Traditional) fallback font
    replace: Microsoft JhengHei UI
    <<: *style
  MS UI Gothic: # Japanese fallback font
    replace: Yu Gothic UI
    <<: *style
  Gulim: # Korean fallback font
    replace: 맑은 고딕
    <<: *style

#fixGSOFont: true # true is to use system UI font
#fixGSOFont: *zh-cn-font # Or replace with user defined font

#gdiplus:
#  SimSun:
#    replace: Microsoft YaHei
#  Microsoft YaHei:
#    size: 72.0
#    style: regular
##    style: 0
#    unit: point
##    unit: 3

#gdipGFFSansSerif: Calibri
#gdipGFFSerif: Times New Roman
#gdipGFFMonospace: Consolas

debug: false

YAML supports anchors(&) and references (*) (Please refer to Wikipedia), this tool also supports not mandatory Merge Key function in YAML spec. You can reuse data like config file above, and don't need to copy multiple times like JSON.

If you want replace only CJK fonts and keep English font, you need to set key to CJK fallback font. This font may be different in different language environments. (For example in Chinese simplified environment is SimSun), you can use debug mode to find corresponding font.