Closed Gax24 closed 2 years ago
I take it you want to replace the font with something that looks better for roman text?
There are actually two problems here:
To replace the font, you have two options:
a.) Find and replace the font name using x32dbg or a similar tool. b.) Hook CreateFontA and use a different font.
Again, two options:
a.) Define a mapping from Shift-JIS characters to ANSI characters and create a font accordingly. b.) Define a mapping from Shift-JIS characters to ANSI characters and hook GetGlyphOutlineA to replace characters at runtime.
Using some kind of hooking is arguably the cleaner / easier solution, but it'll take some digging either way. Someone actually had a similar problem in the past (seems the issue disappeared, though) and back then I threw together this example here:
Which makes something like this possible:
This is only a demonstration, though.
thank you very much, what is the name of the font you are using in that image? Also, another question, is there any way to change the size of it?
@EusthEnoptEron Do you have any example for shift-jis mapping?
@Cosetto
Here's the code I used to achieve the example above: HookExample.zip
In this example you need to drag & drop the game exe on HookExample.exe
if I'm not mistaken.
Of course, if you want to go the hooking route, I would recommend doing it in a lower level language (C++ or maybe Rust) and using some form of DLL bootstrapping / proxying, so that you don't have to execute a separate exe.
The principle is simple:
Now that I think of it, you could probably write a DLL proxy for gdi32.dll
and intercept the relevant calls directly.
Also: there may be more elegant ways out there. This is just a quick & dirty way to achieve the desired effect.
@Cosetto
Here's the code I used to achieve the example above: HookExample.zip
In this example you need to drag & drop the game exe on
HookExample.exe
if I'm not mistaken.Of course, if you want to go the hooking route, I would recommend doing it in a lower level language (C++ or maybe Rust) and using some form of DLL bootstrapping / proxying, so that you don't have to execute a separate exe.
The principle is simple:
- You replace one of the DLLs the game loads with your own.
- The game starts and loads its DLLs.
- Your DLL proxy gets loaded, injects your hooks, and loads the original DLL.
- Your hooks get executed.
Now that I think of it, you could probably write a DLL proxy for
gdi32.dll
and intercept the relevant calls directly.Also: there may be more elegant ways out there. This is just a quick & dirty way to achieve the desired effect.
Thank you. Also, I think I have an idea for non-sjis characters by using a crazy method: _ First, using SjisTunnelEncoding from vntextpatch, this will handle non-sjis characters and output sjisext.bin Next, using proxy and sjis_ext.bin to display the characters in the game.
This only work on shift-jis scripts though, and I'm using the utf8 .txt dump by your tool, switching between shift-jis and utf8 doesn't retain the tunnel characters (like in the picture). So, which part of the code of this tool should I change to dump/insert shift-jis only?
Ah, nice. That's pretty much the approach I described, just with everything integrated.
So let me get this straight:
If that's the case, you might have to explicitly set the encoding to Shift-JIS in TransFile.cs like so, which would allow for translation files in Shift-JIS:
using (var reader = new StreamReader(stream, Encoding.GetEncoding("shift_jis")))
That, or you integrate the tunnel encoding stuff into ReplaceUmlauts. (That's a remnant of my own initial attempts at translating something to German.)
Or you integrate this library into VNTranslationTools. :P
Ah, nice. That's pretty much the approach I described, just with everything integrated.
So let me get this straight:
- The output of step 1 is a binary file with the mappings and a .txt file in Shift-JIS with the Unicode chars replaced by tunnel chars?
- When packing the translations with my library, the tunnel chars get garbled?
If that's the case, you might have to explicitly set the encoding to Shift-JIS in TransFile.cs like so, which would allow for translation files in Shift-JIS:
using (var reader = new StreamReader(stream, Encoding.GetEncoding("shift_jis")))
That, or you integrate the tunnel encoding stuff into ReplaceUmlauts. (That's a remnant of my own initial attempts at translating something to German.)
Or you integrate this library into VNTranslationTools. :P
Just like what you said, converting between utf8 and shift-jis will mess up the tunnel characters. I have already requested vntranslationtool's owner to add support for Liar soft but it seems like he won't do it any times soon. Anyway, thanks for the tip.
@EusthEnoptEron I know this is late to ask, but where can I config word-wrap count?
@EusthEnoptEron I know this is late to ask, but where can I config word-wrap count?
Hello! I want to translate this game: https://vndb.org/v601 into french language, but in this case, this Liar soft game doesn't have a font selector, could you give me a hand to resolve that?