There is a problem on my system that occurs when text is rotated 90 degrees as it is in frame labels. This only happens when ClearType is turned on, and only around 90 degrees of rotation.
I am running Mathematica 7 on Windows 7.
Input:
Style["αβημπρτ", 20, FontFamily -> "Arial"]
Rotate[%, # °] & /@ {90, 90.1, -90, 85, 95, 45, 0}
Exhibit A: ClearType OFF
Ehibit B: ClearType ON
Notice the strongly inferior rendering of the text rotated 90° and 90.1°, but acceptable rendering of text at the other rotations including -90°.
A close inspection of the images above will reveal that sub-pixel-rendering is disabled on rotated text except for the cases of 90°, 90.1°, and 0°. In the last case it works as as intended but it should apparently have been disabled (the default AA is used instead) for 90° and 90.1° as well. I do not want to turn off ClearType as it makes text more readable throughout my system except for this bug.
I tried to be clever by nesting rotations but that does not work. Interestingly there is a difference in rendering between 360° and -360° but not in the anti-aliasing.
text = Style["αβημπρτ", 20, FontFamily -> "Arial"];
Fold[Rotate, text, # °] & /@ {{90, 360}, {90, -360}, {45, 45}} // Row
What systems are affected by this bug? Is it fixed in newer versions?
Is there a work-around that can be applied to the output of
Graphics
?
I would rather not Rasterize
the text.
Answer
Setting a FontOpacity
less than 1 appears to prevent sub-pixel rendering and therefore provides output similar (perhaps identical) to that obtained with ClearType switched off.
text = Style["αβημπρτ", 20, FontFamily -> "Arial", FontOpacity -> 0.999];
Rotate[text, # °] & /@ {90, 90.1, -90, 85, 95, 45, 0}
One possibility to automate this, and to preserve sub-pixel rendering for unrotated text is to hijack RotationBox
:
Unprotect[RotationBox];
RotationBox[boxes_, opts___?OptionQ] := Block[{$rotboxblock = True},
RotationBox[StyleBox[boxes,
If[(BoxRotation /. {opts}) != 0, FontOpacity -> 0.999, {}, {}]],
opts]
] /; ! TrueQ[$rotboxblock];
By targetting RotationBox
rather than Rotate
, the effect is seen even with expressions that don't explicitly involve Rotate
:
text = Style["αβημπρτ", 20, FontFamily -> "Arial"];
Panel[text, text, Left, RotateLabel -> True]
Comments
Post a Comment