OpenTTD

Tasklist

FS#6527 - Company name with foreign (e.g. Czech) characters overflows

Attached to Project: OpenTTD
Opened by SirkoZ (SirkoZ) - Wednesday, 07 December 2016, 13:10 GMT
Last edited by frosch (frosch) - Sunday, 25 December 2016, 17:58 GMT
Type Bug
Category Interface
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version 1.6.1
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Company name in the company bar at the bottom middle of the screen overflows if it contains
too high characters, e.g. "Š" and others - the upper part of the character - usually
hyphenation will overflow onto map terrain when scrolling through the map - mostly downward (due south).
Again - a great example CZ/SK/EN Gamepark.cz Server - when one uses default company name with all kinds of hyphenated characters - things begin to happen. :-)
This task depends upon

Closed by  frosch (frosch)
Sunday, 25 December 2016, 17:58 GMT
Reason for closing:  Fixed
Additional comments about closing:  in r27713 by adf88
Comment by Grzegorz Duczyński (adf88) - Friday, 23 December 2016, 14:00 GMT
Could you give a screenshot?
Comment by SirkoZ (SirkoZ) - Friday, 23 December 2016, 22:49 GMT
There is also server text overflow visible, however pay attention to the two "ˇ" characters and their overflow while navigating terrain...
Comment by Grzegorz Duczyński (adf88) - Saturday, 24 December 2016, 06:45 GMT
As a temporary workaround you can experiment with other fonts:

https://wiki.openttd.org/Unicode
Comment by Grzegorz Duczyński (adf88) - Saturday, 24 December 2016, 12:02 GMT
OK, I figured it out.

Long time before letters were never taller then FONT_HEIGHT_XXX thus there was always enough space to draw labels on widgets. No clipping was needed.

Since Unicode support, it's natural that some characters may be oversized (like Czech diacritics). However, before the GUI zoom feature, it was a minor problem - except of the area reserved for drawing a text, widgets also reserve some pixels for a frame. This additional space was almost always enough for the oversized characters.

Now we have GUI zoom feature. The oversize of characters is N times bigger in GUI zoom xN. Extra space reserved for a frame is no longer enough, letters may extend over the widget. And this is most problematic when they extend over whole window.

When drawing windows (DrawOverlappedWindow), the clipping rectangle is not limited to the area occupied by the window( http://hg.openttd.org/trunk.hg/file/101381b218b0/src/window.cpp#l912 ). A window may paint stuff outside of it and this won't be clipped out automatically. This causes artifacts to appear around some windows if characters are too big.


I can think of few solutions to the problem. We can add clipping and/or reserve more space for drawing labels. Reserving extra space is problematic - how much to reserve? If a font has a single, very tall character, should all widgets be as tall as it's needed to handle this extra tall character? Or maybe we should just reserve a bit more hoping that it will be enough? Poor. I prefer the first one - setup some additional clipping.

But what kind of clipping to perform? Three possibilities. 1 - clip whole windows. 2 - clip whole widgets. 3 - clip only text areas. The 3rd solution would prevent from painting labels over frames and we don't want it probably. Actually it's a nice feature that frames get overpainted by labels - the text is more readable and whole thing doesn't look awkward, it doesn't cause artifacts. Looks like solution 1 or 2 would be preferred. Both would be easy to implement and computationally cheap. Solution 2, in contrast to solution 1 would prevent occasional glitches inside windows.
Comment by SirkoZ (SirkoZ) - Saturday, 24 December 2016, 23:11 GMT
I neglected to mention, that yes, I do use 2x interface (zoom) feature and 1680x1050 resolution or sometimes 1280x1024 (with 2x int.).
From what I've seen only the hyphenated characters are problematic (c, r, s....with ' ˇ ^ `). Also I saw $ being too large some time back.
If OpenTTD is truly supporting unicode/all languages, the new-fangled widget system will automatically adjust itself for added font height/to any font.
From my experience only additional 2 or 3 (1 spare) pixels of height would be necessary.
Comment by Grzegorz Duczyński (adf88) - Sunday, 25 December 2016, 08:54 GMT
Widget system automatically adjust itself for font height, yes, but the problem is that some character may be oversized - some may be taller than the height of a given font. And they cause glitches because there is no clipping mechanism. We could of course make widgets as high as the highest character but this would be a waste of screen space.

Also adding arbitrary number of pixels is a poor solution. There is so many fonts, so many languages, so many characters out there ... because of this uncertainty you will never know when things will brake again.

Clipping solves all problems. I even attempted to implement it:
Comment by Grzegorz Duczyński (adf88) - Sunday, 25 December 2016, 09:02 GMT
Something went wrong during upload. Ignore previous patches.
Additional comment to FONT_HEIGHT_XXX may be useful.

Loading...