On 11.08.2014 23:14, pulkomandy@xxxxxxxxxxxxx wrote:
diff --git a/src/apps/serialconnect/TermView.cpp b/src/apps/serialconnect/TermView.cpp index 8adbdd3..925494b 100644 --- a/src/apps/serialconnect/TermView.cpp +++ b/src/apps/serialconnect/TermView.cpp @@ -23,7 +23,7 @@ TermView::TermView() font_height height; GetFontHeight(&height); - fFontHeight = height.ascent + height.descent + height.leading; + fFontHeight = height.ascent + height.descent + height.leading + 1;
As I noticed fFontHeight is float in SerialConnect. This doesn't make any sense, unless you do subpixel precise drawing. And you don't want to do that, since the text would look worse and drawing would likely be slower.
The "+ 1" in the above formula isn't plausible. If all font_height members are integer, this just adds an additional (and unnecessary) pixel to the line spacing.
Assuming the type of fFontHeight is changed to integer (like in Terminal), overlaps can still happen. E.g. let ascent and descent both be 5.3 and leading 1. Then fFontHeight would be 11. However, since a glyph can use 5.3 pixels above and 5.3 below the base line, it would actually use 12 pixels (10 fully and 2 partially), so that lines could still overlap.
So, the "+ 1" can result in both necessary and insufficient spacing. I would omit it an look for a solution that works in all cases. The safest one with respect to overlaps is certainly
fontHeight = ceilf(ascent) + ceilf(descent) + ceilf(leading) If leading >= 2, fontHeight = ceilf(ascent + descent + leading)would work well, I guess. However, with this formula, for a smaller leading, lines may visually touch despite leading >= 1. In that case
fontHeight = ceilf(ascent) + ceilf(descent + leading)would ensure that there's at least one pixel spacing between the lines. For leading < 1 that is no longer guaranteed, but at least nothing would overlap.
Maybe the best solution would be to choose one of the three formulas depending on the leading value.
CU, Ingo