Closed Muchaszewski closed 1 year ago
Additional information:
as for the reactUnity example, no CSS style or root of HTML has been changed
Relative em scaling seems to work properly (except for the oversized starting size)
<html>
<body>
<span>Chrome</span><br/>
<span style="display: flex; flex-direction: column; font-size: 2em">
2em text
<span style="display: flex; flex-direction: column; font-size: 2em">4em text
<span style="display: flex; flex-direction: column; font-size: 2em">
6em text
</span>
</span>
</span>
</body>
</html>
import { Renderer } from '@reactunity/renderer';
function App() {
return <div>
<text>ReactUnity</text>
<span style="font-size: 2em">
2em text
<span style="font-size: 2em">4em text
<span style="font-size: 2em">
6em text
</span>
</span>
</span>
</div>;
}
Renderer.render(<App />);
The cause of this is simple, root font size is defined as 24px in ReactUnity instead of browser's 16px. This was done with the thought that games usually require bigger fonts.
The font size is defined in useragent stylesheet. It can be easily overridden with:
:root {
font-size: 16px;
}
When we add a useragent stylesheet for browser rendering compatibility, this should be easy to fix.
Changed default font size to 16px in v0.14.0
The rem scaling is not as in the web browsers. Generally, the text is too big in ReactUnity.
I will discuss the following text with the only variable as font-size.
font-size: medium is computed as 1rem which is equal to 16px.
In ReactUnity while using UGUI it's computed as 24px which is too big compared to Chrome.
When manually changed to proper 16px they look almost identical.