11
$\begingroup$

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

Mathematica graphics

Ehibit B: ClearType ON

Mathematica graphics

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

Mathematica graphics

  1. What systems are affected by this bug? Is it fixed in newer versions?

  2. Is there a work-around that can be applied to the output of Graphics?

I would rather not Rasterize the text.

$\endgroup$
11
  • 1
    $\begingroup$ I get the same problem with Mathematica 8 on Windows 7. $\endgroup$
    – 0xFE
    Feb 4, 2013 at 2:45
  • 1
    $\begingroup$ Problem still exists in 9.0.1. I'm on Windows 2003 here (not sure if the ClearType implementation has changed since). $\endgroup$ Feb 4, 2013 at 3:11
  • 1
    $\begingroup$ I used iRotate to reorient my display with respect to the physical monitor in all four possible directions and in every case the first two rotated text samples looked much worse than the rest (although the others don't look fantastic on a rotated monitor either TBH). This seems to rule out an issue with Windows itself for ClearType and vertical text. $\endgroup$ Feb 4, 2013 at 3:27
  • 1
    $\begingroup$ I've noticed similar before with V8 on mac 10.6.8 with 45 degrees rotation without being annoyed enough to look for solutions. $\endgroup$ Feb 4, 2013 at 4:17
  • 3
    $\begingroup$ I find that adding FontOpacity -> 0.999 to the Style prevents the sub-pixel rendering and makes the quality equally poor at all angles. $\endgroup$ Feb 4, 2013 at 11:18

1 Answer 1

11
$\begingroup$

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}

enter image description here

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]

enter image description here

$\endgroup$
2
  • $\begingroup$ Big +1. This alone will save me a lot of headache. I shall refrain from Accepting this immediately per personal policy, in case someone has something better, but I don't anticipate that. (Great if someone can produce correct sub-pixel rendering for all rotations but apparently even the developers couldn't be bothered to figure that out.) The only things lacking in your answer are a way to preserve sub-pixel AA for the 0° case and a way to do this automatically. Perhaps this tweak could be applied by overloading Rotate? I only mention it because you seem to enjoy a challenge. :-) $\endgroup$
    – Mr.Wizard
    Feb 4, 2013 at 13:01
  • 1
    $\begingroup$ @Mr.Wizard, I've added a possible approach to automate, though you may have better ideas. The elephant in the room is the FrameLabel in plots, which don't get caught by this method... $\endgroup$ Feb 4, 2013 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.