News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[patch] Glitch of non-standard font

Started by knightly, February 10, 2010, 10:48:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

knightly

Some Chinese players prefer to use wenquanyi_9pt.bdf instead of the standard font as some characters can't be properly displayed.

However, the font height of wenquanyi_9pt is actually 14px, resulting in some garbage pixels underneath the characters as in the attached image. Those garbage pixels are caused by the text-displaying routine trying to read beyond the boundary of image data.

The attached patch fixes this problem.



prissi

The reading of the BDF character seems strange: Why ignoring characters with negative offset completely? The should not happen; but moving those characters one pixel down or ignoring top rows would achieve still a readab le charecter (mostly).

knightly

#2
I think you are referring to this block of code :
Quote
// read for height times
for (y = top; y < h; y++) {
   fgets(str, sizeof(str), fin);
   if(  y>=0  ) {
      dsp_decode_bdf_data_row(data + char_nr*CHARACTER_LEN, y, xoff, g_width, str);
   }
}

If y is negative, calling dsp_decode_bdf_data_row() with such value will cause the previous character's data be overwritten partially. This should not be allowed.

Edit :

Forgot to say, that this problem does happen in wenquanyi_9pt.bdf. An example will be character with encoding 594 (height=12, desc=2).

Edit :

Just want to make it clear : my fix above ignores the top (negative) rows only, but not ignoring the character completely as you think.


prissi

The display routines are fixed anyway. I will try this for the reader.