简体   繁体   English

jetpack compose中的自定义字体粗细

[英]Custom Font weight in jetpack compose

my designer give me我的设计师给我

Font(R.font.source_sans_variable_350)

which is 350. I am working on fonts through this doc .这是 350。我正在通过这个文档研究 fonts。 To provide FontWeight in FontFamily .FontFamily中提供FontWeight I checked FontWeight.Light and FontWeight.Normal which is 300 and 400 respectively.我检查了FontWeight.LightFontWeight.Normal分别是300400 So is there any solution for 350 ?那么350有什么解决方案吗?

Thanks谢谢

Its a class with parameterized constructor.它是一个带有参数化构造函数的 class。 You can just use it like this.你可以像这样使用它。

Font(resId = R.font.montserrat_light, weight = FontWeight(350))

I am not sure but check this(may be related to this).我不确定,但检查一下(可能与此有关)。 to your style file到您的样式文件

<family name="sans-serif">
     <font weight="300" style="normal">sans_light.Light.ttf</font>
     <font weight="350" style="normal">sans_medium.ttf</font>
     <font weight="400" style="normal">sans_normal.ttf</font>
</family>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM