Norbyte / bg3se

Baldur's Gate 3 Script Extender
Other
1.15k stars 67 forks source link

path for IMGUI Japanese font incorrect #422

Open hawchangJA opened 4 months ago

hawchangJA commented 4 months ago

I have attempted solutions to common problems

Yes

I have checked that my game version is supported

Yes

OS

Windows 11

Platform

Steam

Description

The font path on line 1472 of bg3se/BG3Extender/Extender/Client/IMGUI/IMGUI.cpp seems to be incorrect.

1471:        } else if (language == "Japanese") {
1472:            path = "Public/Game/GUI/Assets/Fonts/NotoSerifKR-Regular.otf";
1473:            glyphRanges = ImGui::GetIO().Fonts->GetGlyphRangesJapanese();

Isn't the correct name "Public/Game/GUI/Assets/Fonts/NotoSerifJP-Regular.otf"?

I have also confirmed that Korean fonts cannot be displayed using Google Fonts. Google Fonts Google Fonts: Noto Serif JP Google Fonts: Noto Serif KR

The character "変" is displayed as "?" There are many other characters that are displayed as "?" UTF8: E5 A4 89 "変"

Indications

I checked with multiple mods that use BG3SE and confirmed that the path was incorrect in the source.

Diagnostic Files

No response

Steps to Reproduce

No response

Expected Behavior

No response

Actual Behavior

No response

hawchangJA commented 4 months ago

I downloaded Noto Serif Japanese (.ttf) from Google Fonts, renamed the file to NotoSerifKR-Regular.otf and saved it in Public/Game/GUI/Assets/Fonts, and then characters were displayed instead of "?".

Norbyte commented 4 months ago

The difficulty is that the NotoSerifJP-Regular.otf included in the game is not, in fact, the Noto Serif JP from Google Fonts, but rather something else.

Also, the game does not use the NotoSerifJP-Regular.otf file at all, this is the font resolve path:

<node id="Font">
    <attribute id="FontPath" type="LSString" value="Assets/Fonts/QuadraatOffcPro/#Quadraat Offc Pro"/>
</node>
<node id="Font">
    <attribute id="FontPath" type="LSString" value="Assets/Fonts/#Noto Serif SC"/>
</node>
<node id="Font">
    <attribute id="FontPath" type="LSString" value="Assets/Fonts/#Noto Serif KR"/>
</node>

I tested with the ingame JP font, and it did not render the JP characters properly.

After some testing, Noto Serif SC seems to include all the required glyphs though: image

hawchangJA commented 4 months ago

Thank you immediately answer. The following is information on the Japanese environment. If you need testing in a Japanese environment, I can help.

I have the Japanese version installed, and when I extracted JapanData.pak I found the following files:

And in .xaml it was defined as follows:

    <FontFamily x:Key="DefaultFont">pack://application:,,,/GustavNoesisGUI;component/Assets/Fonts/#Noto Serif JP</FontFamily>
    <FontFamily x:Key="SpecialFont">pack://application:,,,/GustavNoesisGUI;component/Assets/Fonts/#Noto Serif JP</FontFamily>
Norbyte commented 4 months ago

I did some tweaks in this build, can you check if all texts are legible now?

GameLatestOffline.zip

hawchangJA commented 4 months ago

I checked it quickly and attached the messages of the console. Since I have installed "Trial of Tav" and its translation mod, I have deleted the translation-related messages. Some were displayed correctly, but the next characters remained as "?".

烙 贖 噛 朦 朧

BGSE-Console-20240717.txt

hawchangJA commented 4 months ago

I looked into how to display a wide range of Japanese characters in IMGUI. ImGui::GetIO().Fonts->GetGlyphRangesJapanese() seems to have a narrow character range. It is possible that the glyph is not included in the font file, but if the range is small, it seems that the glyph cannot be displayed even if it is included. According to the following two articles (in Japanese), it seems that the range can be expanded by passing an array as an argument without using GetGlyphRangesJapanese.

Reference article 1 Reference article 2

This fix only improves Japanese display, so if it is difficult to implement, I think it is fine to leave it as it is. The explanation of IMGUI also mentions the side effects of having a large number of glyphs. Also, if the standard fonf file does not contain a glyph, each user can replace it with a loose file, so it is fine as long as the file name referenced by Script Extender is clear.

hawchangJA commented 4 months ago

I validated three additional points, but there was no change in the "?" displayed.

  1. Extract NotoSerifJP-Regular.otf from JapanData.pak, Place Public\Game\GUI\Assets\Fonts and rename to NotoSerifSC-Regular.otf
  2. Extract NotoSerifJP-Regular.ttf from Noto Serif Japanese of Google Fonts , Place Public\Game\GUI\Assets\Fonts and rename to NotoSerifSC-Regular.otf
  3. Extract another Japanese Font (Different typeface) from Google Fonts, Place Public\Game\GUI\Assets\Fonts and rename to NotoSerifSC-Regular.otf