Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: [0.9]Chinese Translation character problem  (Read 2457 times)

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
[0.9]Chinese Translation character problem
« on: November 22, 2018, 10:19:28 PM »

About Chinese character word wrap: It seems can not calculate the characters' width correctly.
Spoiler
[close]
The character is cut off and half becomes "??"
And, the composing seems wired too.
Spoiler
[close]
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.9]Chinese Translation character problem
« Reply #1 on: November 23, 2018, 10:11:55 AM »

Hmm - the game is treating these as characters from any other font. I suspect that if there's an issue calculating width, it's *probably* due to incorrect data in the .fnt file.

The character is cut off and half becomes "??"

The game displays ? for a character that's not in the .fnt file, so you're saying that a single character becomes multiple ?'s when displayed? This sounds like it could be a character encoding issue; make sure the mission text file is saved in UTF-8.

And, the composing seems wired too.

Could you clarify what you mean? Is this about the comma being on the new line, or something else?
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: [0.9]Chinese Translation character problem
« Reply #2 on: November 23, 2018, 06:25:15 PM »

The game displays ? for a character that's not in the .fnt file, so you're saying that a single character becomes multiple ?'s when displayed? This sounds like it could be a character encoding issue; make sure the mission text file is saved in UTF-8.
well that's not the encoding problem I think. Because we do use UTF-8 without bom.
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.9]Chinese Translation character problem
« Reply #3 on: November 23, 2018, 06:34:16 PM »

Can you try removing a few preceding characters to see if the ??? still shows up? That'd tell us if it's related to the line break or not.
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: [0.9]Chinese Translation character problem
« Reply #4 on: November 23, 2018, 07:00:58 PM »

Can you try removing a few preceding characters to see if the ??? still shows up? That'd tell us if it's related to the line break or not.
I think it's related to the link break. Look, wrapping lines work fine in the content below.(though they couldn't wrap line correctly, they couldn't fill up the whole line)(sorry I couldn't give you the screen shoot right now, cuz some incidents)
« Last Edit: November 23, 2018, 07:02:52 PM by Originem »
Logged
My mods


jn_xyp

  • Ensign
  • *
  • Posts: 28
  • Ordinary Player, Fossic.org customer support
    • View Profile
    • Jn_xyp's Blog (In Chinese)
Re: [0.9]Chinese Translation character problem
« Reply #5 on: November 23, 2018, 07:06:19 PM »

I think this issue is not really related to the line break since there's no line breaker in that paragraph.

The real situation is, the "???" randomly shows up at different places on different characters, and their position changes after reboot the game.

In the UTF-8 encoding, the English characters can be represented by 1 byte, but for the Chinese characters, it takes 2~4 bytes to encode them.

Therefore, based on these circumstances, we speculate that the problem might be caused by the way of loading or decoding the encoded texts. For example, if the first 1 or 2 byte of a Chinese character is loaded and decoded first, it won't be displayed correctly, and the second half of its encoding may be interpreted as "???".

Hope this helps!

Update: The position of missing characters actually WON'T change after restart the game. :P
« Last Edit: November 23, 2018, 10:42:58 PM by jn_xyp »
Logged
Ordinary Player, maintainer and customer support of fossic.org.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.9]Chinese Translation character problem
« Reply #6 on: November 23, 2018, 07:23:14 PM »

Hmm - the game is loading this text in UTF-8, so multi-byte characters should be fine. It's not doing anything custom or special, just loading UTF-8 text from byte data using built-in Java functionality.

The real situation is, the "???" randomly shows up at different places on different characters, and their position changes after reboot the game.

That's very odd! Hard to imagine how this could change after a game restart, nothing in the code there should be inconsistent or variable.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.9]Chinese Translation character problem
« Reply #7 on: November 23, 2018, 09:22:35 PM »

If you could send me 1) a mission_text file to reproduce it, and 2) the .fnt/png files for the font, I could take a look and see what I see.
Logged

jn_xyp

  • Ensign
  • *
  • Posts: 28
  • Ordinary Player, Fossic.org customer support
    • View Profile
    • Jn_xyp's Blog (In Chinese)
Re: [0.9]Chinese Translation character problem
« Reply #8 on: November 23, 2018, 10:50:09 PM »

Hmm - the game is loading this text in UTF-8, so multi-byte characters should be fine. It's not doing anything custom or special, just loading UTF-8 text from byte data using built-in Java functionality.

The real situation is, the "???" randomly shows up at different places on different characters, and their position changes after reboot the game.

That's very odd! Hard to imagine how this could change after a game restart, nothing in the code there should be inconsistent or variable.

Just checked again... the positions of missing characters WON'T actually change after restart, my fault.  :-[

And there's also an expert mentioned that this problem is very likely to be caused by the following UTF-8 decoder bug inside JDK:
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8039751
Logged
Ordinary Player, maintainer and customer support of fossic.org.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.9]Chinese Translation character problem
« Reply #9 on: November 24, 2018, 12:44:39 PM »

Ahh, I think I found a bug that could cause this - if the file being loaded is over 1024 bytes in length, the game would treat each segment of 1024 bytes as a separate UTF-8 string. For multi-byte characters this could mean they'd be broken apart. Fixed this up; hopefully this is the issue.
Logged