Skip to main content

front end - Poor anti-aliasing in Rotated text with ClearType on


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.



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}

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


Comments

Popular posts from this blog

mathematical optimization - Minimizing using indices, error: Part::pkspec1: The expression cannot be used as a part specification

I want to use Minimize where the variables to minimize are indices pointing into an array. Here a MWE that hopefully shows what my problem is. vars = u@# & /@ Range[3]; cons = Flatten@ { Table[(u[j] != #) & /@ vars[[j + 1 ;; -1]], {j, 1, 3 - 1}], 1 vec1 = {1, 2, 3}; vec2 = {1, 2, 3}; Minimize[{Total@((vec1[[#]] - vec2[[u[#]]])^2 & /@ Range[1, 3]), cons}, vars, Integers] The error I get: Part::pkspec1: The expression u[1] cannot be used as a part specification. >> Answer Ok, it seems that one can get around Mathematica trying to evaluate vec2[[u[1]]] too early by using the function Indexed[vec2,u[1]] . The working MWE would then look like the following: vars = u@# & /@ Range[3]; cons = Flatten@{ Table[(u[j] != #) & /@ vars[[j + 1 ;; -1]], {j, 1, 3 - 1}], 1 vec1 = {1, 2, 3}; vec2 = {1, 2, 3}; NMinimize[ {Total@((vec1[[#]] - Indexed[vec2, u[#]])^2 & /@ R...

functions - Get leading series expansion term?

Given a function f[x] , I would like to have a function leadingSeries that returns just the leading term in the series around x=0 . For example: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x)] x and leadingSeries[(1/x + 2 + (1 - 1/x^3)/4)/(4 + x)] -(1/(16 x^3)) Is there such a function in Mathematica? Or maybe one can implement it efficiently? EDIT I finally went with the following implementation, based on Carl Woll 's answer: lds[ex_,x_]:=( (ex/.x->(x+O[x]^2))/.SeriesData[U_,Z_,L_List,Mi_,Ma_,De_]:>SeriesData[U,Z,{L[[1]]},Mi,Mi+1,De]//Quiet//Normal) The advantage is, that this one also properly works with functions whose leading term is a constant: lds[Exp[x],x] 1 Answer Update 1 Updated to eliminate SeriesData and to not return additional terms Perhaps you could use: leadingSeries[expr_, x_] := Normal[expr /. x->(x+O[x]^2) /. a_List :> Take[a, 1]] Then for your examples: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x), x] leadingSeries[Exp[x], x] leadingSeries[(1/x + 2 + (1 - 1/x...

What is and isn't a valid variable specification for Manipulate?

I have an expression whose terms have arguments (representing subscripts), like this: myExpr = A[0] + V[1,T] I would like to put it inside a Manipulate to see its value as I move around the parameters. (The goal is eventually to plot it wrt one of the variables inside.) However, Mathematica complains when I set V[1,T] as a manipulated variable: Manipulate[Evaluate[myExpr], {A[0], 0, 1}, {V[1, T], 0, 1}] (*Manipulate::vsform: Manipulate argument {V[1,T],0,1} does not have the correct form for a variable specification. >> *) As a workaround, if I get rid of the symbol T inside the argument, it works fine: Manipulate[ Evaluate[myExpr /. T -> 15], {A[0], 0, 1}, {V[1, 15], 0, 1}] Why this behavior? Can anyone point me to the documentation that says what counts as a valid variable? And is there a way to get Manpiulate to accept an expression with a symbolic argument as a variable? Investigations I've done so far: I tried using variableQ from this answer , but it says V[1...