xaml-math icon indicating copy to clipboard operation
xaml-math copied to clipboard

Improve blurred output

Open torfranz opened this issue 7 years ago • 5 comments

Hi, Currently formulas are rendered pretty blurred.

Toying with the v0.3 version now it seems I'm unable to influence the rendering of the formula with any of the usual options, RenderOptions, TextOptions, UseLayoutRounding. I tried basically all combinations but to no avail. Can you give any hint on how to reduce the blur?

Btw, thx for the lightning speed in releasing v0.3 👍

torfranz avatar Feb 24 '17 15:02 torfranz

Alright, it wasn't completely fixed. See comment from @torfranz:

image

Please note the blurred horizontal lines on the equal sign.

ForNeVeR avatar Mar 13 '17 15:03 ForNeVeR

See this one. To the left are the computer modern fonts and to the right are the Asana Math fonts render_compare

B3zaleel avatar Sep 05 '18 09:09 B3zaleel

That's not a font issue, it's more of WPF aliasing / layout rendering / pixel pinning issue. You can't just "fix" it by changing a font.

Also, for the record, the right one looks more blurry to me (check the radical sign: its' top part definitely has more pixels in height than it should; the top pixel line is shadowed).

ForNeVeR avatar Sep 05 '18 09:09 ForNeVeR

Have you tried overriding the OnRender method of the formula control and changing the VisualTextRenderingMode of the base to TextRenderingMode.Cleartype or GrayScale. It gets sharper but sometimes (when scaled), it adds excess pixels.

B3zaleel avatar Sep 05 '18 11:09 B3zaleel

You could make the following changes in the "WpfMath/Rendering/WpfElementRenderer.cs" file.

public void RenderGlyphRun(Func<double, GlyphRun> scaledGlyphFactory, double x, double y, Brush foreground)
        {
            var glyphRun = scaledGlyphFactory(_scale);
            Pen glyphPen = new Pen(foreground, 1);
            _drawingContext.DrawGeometry(foreground, glyphPen, glyphRun.BuildGeometry());

            //_drawingContext.DrawGlyphRun(foreground, glyphRun);
        }

It has the tendency of being too bold so you'll have to make a lot of small changes to it(the Pen).

B3zaleel avatar Sep 20 '18 15:09 B3zaleel