eglaysher / rlvm

RealLive clone for Linux and OSX
http://rlvm.net
GNU General Public License v3.0
150 stars 25 forks source link

Text layout with any font other than msgothic.ttc is wrong. #70

Closed eglaysher closed 8 years ago

eglaysher commented 8 years ago

The kerning here is so bad that we draw the next letter over the last letter.

eglaysher commented 8 years ago

OK, so here's my current theory on what's going on:

If you look in s/s/b/text_window.cc, you'll see that line breaking is all pixel based. However, in the Gameexe.ini files, text windows are sized in full-width characters.

The current font advancement code in text_window.cc actually is putting the exact same number of Roman characters on the same line as the official RealLive.exe. However, the problem comes from all the Japanese fonts I've tested on Linux not having monospace Roman character information. (!)

Possible work around I'll have to think about for a bit: change the line breaking algorithm from being pixel based to character based. Right now, we ignore the width of the non-evenly monospaced Roman characters and lay them out so that they fit 2 * [number of full-width characters] in a line. Instead break by character count; the line can be laid out however the characters fall, but when dealing with Roman characters, we only allow 2n characters on a line. Possible downsides: this could theoretically break Japanese editions of these games, since the whole line breaking thing is very subtle.

eglaysher commented 8 years ago

So coming back to this, here's the status:

So there are really two bugs here: