视觉小说更换字体

最近开坑《With Ribbon》但发现并没有更换字体的选项,默认字体缺少简体中文字符,看得很难受

由于笔者不会win32,就偷了两个开源项目改字体

注意:笔者仅测试了一个游戏(引擎KIRIKIRI 2.32.1.426)可以成功更改字体,不保证对所有程序可用

更改字体使用以下工具:ysc3839/FontMod: Simple hook tool to change Win32 program font. (github.com)

加载dll使用以下工具:hasherezade/dll_injector: A simple commandline injector using classic DLL injection (github.com)

以《With Ribbon》为例

首先需要使游戏主程序加载更改字体用的dll,将FontMod.dll放入和游戏主程序相同目录下,使用dll_injector启动(需要对应32/64位)

.\dll_injector32.exe /dll .\FontMod.dll /target .\WithRibbon.exe

也可以按照dll仓库README操作,更改为提到的几个dll名称(笔者改成d3d9.dll不行,ddraw.dll可以,大概和游戏使用图形API有关)

第一次运行后会在同目录生成FontMod.yaml,在fonts选项下面更改成需要的字体,若游戏使用gdi之类的东西,修改配置会稍有区别,具体参见FontMod的git仓库

若不知道是什么字体,将配置文件的debug选项设为true,查看log后再进行尝试

log示例:

这个乱码的“俵俽 俹僑僔僢僋”实际上是Shift-JIS编码的日文“MS Pゴシック”强制使用GBK编码表示的结果。但在写配置文件时,这部分还是需要保持乱码,不然替换将不能生效。若操作系统语言不是简体中文,或者开启了系统实验性UTF-8支持,可能这里的字体名字也会有相应的变化。

笔者最终配置(部分):

fonts:
  # MS Pゴシック:
  俵俽 俹僑僔僢僋:
    replace: 思源黑体 CN Medium
    <<: *style

效果:

修改前
修改后

最后再贴一个PowerShell脚本(来源)获取OpenType字体信息(不过好像没什么用):

$folder = "C:\Windows\fonts\"

$objShell = New-Object -ComObject Shell.Application 


$fileList = @() 
$attrList = @{} 
$details = ( "Title",
              "Font style",
              "Show/hide", 
              "Designed for",
              "Category",
              "Designer/foundry" ,
               "Font Embeddability",
               "Font type",
               "Family",
               "Date created",
               "Date modified",
               "Collection",
               "Font file names",
               "Font version"
                 ) 

 #figure out what the possible metadata is
$objFolder = $objShell.namespace($folder) 
for ($attr = 0 ; $attr  -le 500; $attr++) 
{ 
    $attrName = $objFolder.getDetailsOf($objFolder.items, $attr) 
    if ( $attrName -and ( -not $attrList.Contains($attrName) )) 
    {  
        $attrList.add( $attrName, $attr )  
    } 
} 

 #$attrList

 #loop through all the fonts, and process
     $objFolder = $objShell.namespace($folder) 
    foreach($file in $objFolder.items()) 
    { 
        foreach( $attr in $details) 
        { 

            $attrValue = $objFolder.getDetailsOf($file, $attrList[$attr]) 
            if ( $attrValue )  
            {  
                Add-Member -InputObject $file -MemberType NoteProperty -Name $attr -value $attrValue 
            }  
        } 
        $fileList += $file 
        write-verbose "Prcessing file number $($fileList.Count)"
    } 


$fileList | select $details |  out-gridview

Visits: 49

发布者:Tabing010102

???

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据