xaml-math
xaml-math copied to clipboard
Improve blurred output
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 👍
Alright, it wasn't completely fixed. See comment from @torfranz:
Please note the blurred horizontal lines on the equal sign.
See this one. To the left are the computer modern fonts and to the right are the Asana Math fonts
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).
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.
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).