r192 baseline calculation off by 1 pixel
By thecloudexpa... on September 29, 2010 23:37 (imported from Google Code)
In r192, the new calculation of the baseline offset has a subtle bug. This results in certain fonts (namely, Inconsolata, although there may be others affected) being drawn 1 pixel too high.
Below are some screenshots that illustrate the problem, with a comparison against Terminal.app. Note that in Terminal.app, and in my previous patch to r188, the bracket characters and the $ in the prompt are vertically centered in the selected line. In r192, they are drawn 1 pixel too high.
Here is a diff that seems to fix the issue. It just consists of adding parentheses around the addition operation, so the descender height is calculated before the subtraction operation. (One would expect this to be a no-op, given operator precedence, but evidently this is not the case.)
Index: PTYTextView.m
--- PTYTextView.m (revision 192)
+++ PTYTextView.m (working copy)
@@ -3689,7 +3689,7 @@
fontInfo->font = font;
[fontInfo->font retain];
- fontInfo->baselineOffset = -floorf([font leading] - [font descender] + 0.5);
- fontInfo->baselineOffset = -floorf([font leading] - ([font descender] + 0.5));
fontInfo->descender = floorf([font descender]);
fontInfo->boldVersion = NULL;
}