ZQF-ReVN / RxYuris

Yu-Ris Engine Tools. | .ypf .ybn
45 stars 3 forks source link

Hook to redirect the game to use window font #2

Open Berthog opened 1 year ago

Berthog commented 1 year ago

Hi Dir-A, thank you very much for your Yuris Tools and also other projects, all of them are very useful for us! Regarding Yuris, most of recent english releases or games using this engine comes with bitmap fonts or fonts in images, in this way is kinda complicated edit the fonts. Do you think it would be possible implement a hook to make the engine redirect to use window fonts? I know you're bussy with other projects, but it would be wonderful if you can take a look on this too please. Here some examples of games using this: (English releases) https://vndb.org/v28634 https://vndb.org/v30235

Dir-A commented 1 year ago

I saw such a game a few months ago, and for now, the most effective way is still to modify the font image. There are some people who have dealt with it https://github.com/yangg1g/my_blog/issues/11

Modifying this may require decompiling the yuris script, So far I have not seen a more complete tool. Anyway, I'll give it a try when I have time

Cosetto commented 1 year ago

Yuris engine also has an annoying spacing issue which is caused by monospace, so it will treat characters such as á, é, í, ó, ú, and also Russian characters, etc as full-width characters. Exam: Thí s is a té sting sé ntence.

Dir-A commented 1 year ago

Have you tried Hook CrateFont to change the iPitchAndFamily parameter to FIXED_PITCH?

Cosetto commented 1 year ago

No, I haven't yet. I don't even know how and where does that locate in the exe, but can you test it out? Like you can try to put half-width letters interleave with full-width, for exmaple: aあbえcいdおeうf

Dir-A commented 1 year ago

QQ截图20230319215524 QQ截图20230319215545 QQ截图20230319215506

Like the first picture? And then you want to show it like the second or third picture?

Cosetto commented 1 year ago

QQ截图20230319215524 QQ截图20230319215545 QQ截图20230319215506

Like the first picture? And then you want to show it like the second or third picture?

Like the second pic. Is is related to the FIXED_PITCH you said because some engines have issue like that and I really want to fix that.

Dir-A commented 1 year ago

I think it's because the game determines whether a character is a single byte or a double byte and thus changes the width of the output character

Like a b c d e f g These are all single-byte characters Both Chinese and Japanese are double-byte

á, é, í, ó, ú Those characters are double-byte encoded under and GBK, so yuris should judge them as similar to the output of Chinese and Japanese。 So they show up like this Thí s is a té sting sé ntence. They are twice as wide as normal single-byte characters.

If you go directly to modify may be more complicated

For normal yuris engine output text is via TextOut function You can map with single-byte characters. like i -> 0x69, í -> 0xA8AA(GBK)

If I want to display "Thís" Write "i" in the script. like "This"

Replace back when the game calls the TextOut function i -> í Then on the screen you can see the normal output Thís not Thí s

I don't know if you want to display both i and í, in which case you can look for other characters to replace them. The characters in the ASCII table are all single-byte and can be replaced. But some characters cannot be displayed like \n \t, and the replacement will not be output through TextOut.

I know that most western languages are represented by a finite number of letters. Like the twenty-six letters of the English alphabet. Replacing the English letters in ASCII with the letters of the language you need is probably the best option.

Cosetto commented 1 year ago

Is that Sjis mapping? I've heard about it many times but I don't about the specific detail, and since my language has 134 characters to replace so I don't think ASCII will be enough

Dir-A commented 1 year ago

In fact, it is also possible, because ASCII only uses half of a byte, that is, 0x00-0x7F, the remaining half can still be used, but this involves some problems with DBCS, the implementation is a little more troublesome

Anyway, there is a simple way to take all single-byte characters and make them double-byte, like a(halfwidth)->a(fullwidth).

But in this case, there may be a requirement for fonts, and unlike Chinese characters, which require few characters, this situation may cause the text to be particularly long.

zMews commented 1 year ago

I don't know if this has anything to do with it but... in "euphoria", I'm trying to add more characters like: á,é,í,ó,ú,ç,ã.

however, the game is pulling the pre-rendered font from the esfont folder (in jp version) or cgsys/font (in EN version). Because of using pre-rendered font, I'm still trying to fix it, but I couldn't.

Any ideas?

Dir-A commented 1 year ago

@zMews I took a look at this version last week.I think the first thing to do is decompile ybn script, otherwise it's hard direct call system API to render font.

and debugged the game and found that it has two ways of rendering fonts, like text dialog, which uses image-font, but the settings screen uses the system API (TextOutA).

like this

switch(render_mode)
{
case Sys_Font:
    {
        ....
    }
    break;
case Image_Font:
    {
        .....
    }
    break;
case ...
}

I found that switch and the normal yuris engine will go to Sys_Font, but the version that uses image-fonts will skip this code.

If you modify the jump directly into Sys_Font, there will be parameter mismatch and thus accessing the wrong address, and game will crash.

So I think there is a part in compiled script to switch rendering mode, but it's hard to find and edit it now.

zMews commented 1 year ago

Are you planning to make decompiler or disassembler? since you are working with yuris

I was thinking of making a port to another game engine manually or doing the disassembler... I just want to find a way to get the translation working ;-;

Dir-A commented 1 year ago

That is not easy, for decompiling scripts. Of course if I have a lot of time, I think I can try it.

For translation, I think it's easier to modify font-images for now

Like this blog says:https://github.com/yangg1g/my_blog/issues/11

zMews commented 1 year ago

That is not easy, for decompiling scripts.

Of course if I have a lot of time, I think I can try it.

For translation, I think it's easier to modify font-images for now

Like this blog says:https://github.com/yangg1g/my_blog/issues/11

Some games, like euphoria is using a font with separated image files for each glyph, and inside the game script it maps each image for the correct character, in our case we can't translate without add new characters to that mapping at least.

mmafic commented 1 year ago

I am having the same thought as @zMews for a game I'm trying to translate, I'm looking for a way to get information like which sprite appears for which lines and when certain music / voice lines play. Is there really no way to do this yet?