stevenpetryk / mafs

React components for interactive math
https://mafs.dev
MIT License
3.24k stars 90 forks source link

Text shadow makes other text colors appears fuzzy #85

Closed xkisu closed 1 year ago

xkisu commented 1 year ago

When specifying a color other than the default for the Text component, the edges of the text become fuzzy and appears bold

For example, here's what the default text color looks like:

<Text
    x={yTip[0]}
    y={yTip[1]}
    attach="e"
    attachDistance={25}
>
    Y
</Text>

image

And here's how it appears with a different color specified:

<Text
    x={yTip[0]}
    y={yTip[1]}
    attach="e"
    attachDistance={25}
    color={Theme.green}
>
    Y
</Text>

image

This happens because when a custom color is set, the Text component uses that color as its stroke instead of using the background color (line https://github.com/stevenpetryk/mafs/blob/7d86d79c916606c6ea8e48dad7fce69b1e5377b4/src/display/Text.tsx#LL66). However this causes the size of the text to inflate and become fuzzy because of the simulated shadow effect from the mafs-shadow class not playing nice with colours other than white.

Here's how the above example looks like with the stroke set back to mafs-bg: image

Proposed solution: Update Text to still use the mafs-bg color as the text stroke, even when a custom color is specified.

stevenpetryk commented 1 year ago

Ah, good catch. Will cut a release to fix this right now.

stevenpetryk commented 1 year ago
Thanks, @xkisu! This is fixed in v0.10.1.
xkisu commented 1 year ago
Thanks, @xkisu! This is fixed in v0.10.1.

Cheers!