Giter VIP home page Giter VIP logo

Comments (4)

KurtGokhan avatar KurtGokhan commented on July 4, 2024 1

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.

from core.

KurtGokhan avatar KurtGokhan commented on July 4, 2024 1

Changed default font size to 16px in v0.14.0

from core.

Muchaszewski avatar Muchaszewski commented on July 4, 2024

Additional information:

  • em Unit: The em unit allows setting the font size of an element relative to the font size of its parent. When the size of the parent element changes, the size of the child changes automatically.
  • rem Unit: The rem is based upon the font-size value of the root element, which is the element. And if the element doesnโ€™t have a specified font-size, the browser default value of 16px is used. So here only the value of the root is considered, and there is no relation with a parent element.

as for the reactUnity example, no CSS style or root of HTML has been changed

from core.

Muchaszewski avatar Muchaszewski commented on July 4, 2024

Relative em scaling seems to work properly (except for the oversized starting size)

HTML

<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>

image

ReactUnity

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 />);

image

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.