Skip to content
二哥的秘密小站

时间漂流船

二哥的秘密小站

时间漂流船

修复win11中word字体与旧字体名称不同导致的显示异常(Powershell脚本)

Posted on 2025年1月25日

打开管理员终端,运行以下脚本:

# 必须用管理员权限运行
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}

# 设置执行策略(仅首次运行需要)
Set-ExecutionPolicy RemoteSigned -Scope Process -Force

# 定义全量旧→新字体映射表(覆盖GB2312、GBK、XP时代旧名称)
$fontMappings = @{
# 中文旧字体
"楷体_GB2312" = "KaiTi" # 旧楷体 → 新楷体
"仿宋_GB2312" = "FangSong" # 旧仿宋 → 新仿宋
"宋体" = "SimSun" # 旧宋体 → 新宋体
"黑体_GB2312" = "SimHei" # 旧黑体 → 新黑体
"方正小标宋_GBK" = "FZXiaoBiaoSong-B05" # 特殊公文字体
"华文楷体" = "KaiTi" # 第三方字体兼容

# 英文旧字体映射
"Arial Narrow" = "Arial"
"Times New Roman Baltic" = "Times New Roman"

# 系统遗留字体
"MS UI Gothic" = "Yu Gothic UI" # 日语字体更新
"MS Mincho" = "Yu Mincho"

# 扩展修复(来自用户常见问题)
"幼圆" = "YouYuan" # 旧版幼圆字体
"隶书" = "LiSu"
"华文新魏" = "STXinwei"
}

# 注册表路径
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes"

# 批量修复(带进度显示)
Write-Host "正在扫描并修复旧字体映射..." -ForegroundColor Cyan
$total = $fontMappings.Count
$current = 0

foreach ($key in $fontMappings.Keys) {
$current++
$percent = [math]::Round(($current/$total)*100)
$value = $fontMappings[$key]

# 写入注册表
try {
Set-ItemProperty -Path $regPath -Name $key -Value $value -ErrorAction Stop -Force
Write-Host "[$percent%] 已修复: $key → $value" -ForegroundColor Green
}
catch {
Write-Host "[!] 修复失败: $key (可能权限不足或键值被锁定)" -ForegroundColor Red
}
}

# 完成提示
Write-Host "`n已完成所有旧字体映射修复!" -ForegroundColor Yellow
Write-Host "强烈建议重启电脑使更改生效(未重启前Word可能仍使用缓存)`n" -ForegroundColor Magenta

# 可选:一键打开注册表路径供验证
$choice = Read-Host "是否要立即打开注册表验证修改?(Y/N)"
if ($choice -eq "Y") {
regedit.exe /m /v "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes"
}

Read-Host "按回车键退出"

未分类

文章导航

Previous post
Next post

Search

Archives

  • 2025 年 7 月
  • 2025 年 6 月
  • 2025 年 1 月
  • 2024 年 12 月
  • 2024 年 3 月
  • 2024 年 2 月
  • 2023 年 12 月
  • 2023 年 9 月
  • 2023 年 8 月
  • 2023 年 7 月
  • 2023 年 6 月
  • 2023 年 5 月
  • 2023 年 4 月
  • 2023 年 2 月
  • 2022 年 12 月
  • 2022 年 10 月
  • 2022 年 8 月
  • 2022 年 7 月
  • 2022 年 6 月
  • 2022 年 2 月

其他操作

  • 注册
  • 登录
  • 条目 feed
  • 评论 feed
  • WordPress.org
©2025 二哥的秘密小站 | WordPress Theme by SuperbThemes