software-mansion / software-mansion/react-native-svg
Pixelated SVG on Android when using SvgXml and applying style scale transform.
Open
@jakex7 is already working on this.
Since Jun 13, 2024.
bug
- Dominant language
- TypeScript
- Stars
- 8k
- Forks
- 1.2k
- Avg merge
- 10d 9h
- Merged PRs (30d)
- 2
Description
Bug
SVGs displayed using SvgXML are pixelated on Android when scaled using style transforms.
Conditions to reproduce:
- Use
SvgXML - Apply a style transformation on scale different to 1 (does not matter if less or more)
- Run on Android.
The following component:
import * as React from 'react';
import { SvgXml } from 'react-native-svg';
export const LogoSVG: React.FC = () => {
const svgXML = `<svg width="20" height="20" viewBox="0 0 40 40" fill="none">
<circle cx="20" cy="20" r="10" fill="#FF0000"/>
</svg>`;
return <SvgXml xml={svgXML} style={{ transform: [{ scale: 2.5 }] }} />;
};
Renders like this:
In contrast, when no scale transformation is applied (scale = 1);
import * as React from 'react';
import { SvgXml } from 'react-native-svg';
export const LogoSVG: React.FC = () => {
const svgXML = `<svg width="60" height="60" viewBox="0 0 40 40" fill="none">
<circle cx="20" cy="20" r="10" fill="#FF0000"/>
</svg>`;
return <SvgXml xml={svgXML} style={{ transform: [{ scale: 1 }] }} />;
};
It renders a sharp, geometrically precise figure:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.