GithubHelp home page GithubHelp logo

How to set font size ? about belly HOT 4 CLOSED

jkb0o avatar jkb0o commented on July 22, 2024
How to set font size ?

from belly.

Comments (4)

jkb0o avatar jkb0o commented on July 22, 2024

Property names follows kebab-case naming convention, like in css. Use font-size to specify font size within eml:

/// eml:
commands.add(eml!(<span s:font-size="42px">Hello</span>))

or ess:

/* style.ess */

/* set font size to exact element */
span {
  font-size: 42px
}

/* 
  text elements often resides as children of other nodes,
  so it may be useful to set font props using `*` selector
*/

/* set default font size */
* {
  font-size: 24px
}
/* set font size for specific block
.specific-block * {
  font-size: 36px
}

There also orher font related properties:

* {
  /* load custom font from assets folder */
  font: "fonts/MyFont.ttf"
  
  /* use predefined font style */
  font: bold /* regular|bold|italic|bold-italic */
  
  /* specify font color */
  color: red
}

I'd like to keep this issue open, until #31 got resolved.

from belly.

kaosat-dev avatar kaosat-dev commented on July 22, 2024

Thanks a lot for your quick reply !
My bad also, I was so focused on Bevy's text attributes that I forgot to try it css style :)
That is valuable information about using a specific font as well , thanks !

It is not really an issue at this stage but would there be any way of reusing a font specified in an asset file in bevy_asset_loader ?

#31 is a very good idea !

Btw I have a list of other questions , possible bugs (still need to some testing outside of my main project to isolate things) , and (small) feature requests: is that too much at the current time or are you ok with that ?

Either way, thanks a lot for creating Belly , very useful and promising!

from belly.

jkb0o avatar jkb0o commented on July 22, 2024

Thank you for such a words! I appreciate it!

It is not really an issue at this stage but would there be any way of reusing a font specified in an asset file in bevy_asset_loader ?

I'm not sure if I understand you question right. Lets look on this ess:

* {
  font: "my-font.ttf"
}

The Text components generated by belly will hold Handle<Font> to my-font.ttf asset. If you define same font in bevy_asset_loader asset, your asset collections will hold the same Handle<Font> to the same my-font.ttf, so it will be the only instance of my-font.ttf asset.

You may want to pass font by asset key:

* {
  font: "collection.assets#my.font"
}

Unfortunately for now it is not possible, but may be possible in future.

Btw I have a list of other questions , possible bugs (still need to some testing outside of my main project to isolate things) , and (small) feature requests: is that too much at the current time or are you ok with that ?

Fill free to contact me in discord @jkbo#2629, or/and add issues. There are should be a lot of small bugs which is pretty easy to fix. Feature requests are welcome as well!

from belly.

jkb0o avatar jkb0o commented on July 22, 2024

closing in favor of #31

from belly.

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.