Alexander Maryanovsky
12/02/2022, 3:57 PMAlexander Maryanovsky
12/02/2022, 3:58 PMRow {
Text(
text = "Hello",
fontWeight = FontWeight.Black,
modifier = Modifier.background(Color.Gray)
)
Text(
text = "Desktop",
fontWeight = FontWeight.Normal,
modifier = Modifier.background(Color.Gray)
)
}
Alexander Maryanovsky
12/02/2022, 4:01 PMAlexander Maryanovsky
12/02/2022, 4:07 PMseb
12/02/2022, 4:30 PMseb
12/02/2022, 4:30 PMKirill Grouchnikov
12/02/2022, 5:11 PMRow
expected to baseline-align its Text
children?Alexander Maryanovsky
12/02/2022, 5:24 PMAlexander Maryanovsky
12/02/2022, 5:28 PMKirill Grouchnikov
12/02/2022, 5:31 PMAlexander Maryanovsky
12/02/2022, 5:33 PMKirill Grouchnikov
12/02/2022, 5:33 PMAlexander Maryanovsky
12/02/2022, 5:35 PMAlexander Maryanovsky
12/02/2022, 5:35 PMKirill Grouchnikov
12/02/2022, 5:35 PMKirill Grouchnikov
12/02/2022, 5:36 PMAlexander Maryanovsky
12/02/2022, 5:37 PMAlexander Maryanovsky
12/02/2022, 5:37 PMKirill Grouchnikov
12/02/2022, 5:37 PMAlexander Maryanovsky
12/03/2022, 11:54 AMval fonts = FontCollection()
val fontProvider = TypefaceFontProvider()
fonts.setDefaultFontManager(FontMgr.default)
fonts.setAssetFontManager(fontProvider)
fun skTextStyle(weight: Int): SkTextStyle = SkTextStyle().apply {
fontSize = 28.0f
fontFamilies = arrayOf("Helvetica Neue")
fontStyle = fontStyle.withWeight(weight)
}
fun paragraphHeight(weight: Int): Float{
val skParagraph = SkParagraphBuilder(style = SkParagraphStyle(), fc=fonts)
.pushStyle(skTextStyle(weight))
.addText("Skiko")
.build()
skParagraph.layout(200f)
return skParagraph.height
}
println(
IntRange(1, 10)
.map { paragraphHeight(it*100) }
.toSet()
.sorted()
.joinToString()
)
This prints 33.0, 34.0
for “Helvetica Neue”. For any other font I’ve tried, it prints just one number.Alexander Maryanovsky
12/03/2022, 12:22 PMval fontsByName = GraphicsEnvironment.getLocalGraphicsEnvironment().allFonts.associateBy { it.fontName }
val awtFont = fontsByName["HelveticaNeue"]!!.deriveFont(28.0f)
val graphics2D = BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB).createGraphics()
println(awtFont.deriveFont(AwtFont.PLAIN).getLineMetrics("Awt", graphics2D.fontRenderContext).height)
println(awtFont.deriveFont(AwtFont.BOLD).getLineMetrics("Awt", graphics2D.fontRenderContext).height)
prints
33.404
34.188
Alexander Maryanovsky
12/03/2022, 12:39 PMAlexander Maryanovsky
12/03/2022, 12:40 PMAlexander Maryanovsky
12/03/2022, 12:42 PMorangy
Alexander Maryanovsky
12/03/2022, 3:49 PMRow(modifier = Modifier.padding(16.dp)){
Text("Hello", fontWeight = FontWeight.Medium, modifier = Modifier.alignByBaseline())
Text("Desktop", fontWeight = FontWeight.Light, modifier = Modifier.alignByBaseline())
}
Alexander Maryanovsky
12/03/2022, 3:49 PMKirill Grouchnikov
12/03/2022, 3:52 PMAlexander Maryanovsky
12/03/2022, 3:55 PMAlexander Maryanovsky
12/03/2022, 4:00 PMorangy
orangy
Alexander Maryanovsky
12/03/2022, 6:40 PMIgor Demin
12/05/2022, 12:24 PMthere were font issue fixes some tine ago,There were fixes regarding text input and text selection. No big changes regarding fonts. One of the major changes was changing the default font to San Francisco. But it seems it doesn't work on your machine 🤔 (the "a" shape is different). What is the version of macOS?
Alexander Maryanovsky
12/05/2022, 2:01 PMIgor Demin
12/05/2022, 2:02 PMhave San Francisco installedIt is a system font that isn't visible/accessible for external applications explicitly. Applications usually use alias "System Font", which can change in the future versions.
Alexander Maryanovsky
12/05/2022, 2:06 PMDesktopFont.GenericFontFamiliesMapping
specifies it as "San Francisco"
. Maybe that’s the problem?Alexander Maryanovsky
12/05/2022, 2:44 PMAlexander Maryanovsky
12/05/2022, 2:44 PMIgor Demin
12/05/2022, 3:19 PMAlexander Maryanovsky
12/05/2022, 3:23 PMAlexander Maryanovsky
12/05/2022, 3:24 PMIgor Demin
12/05/2022, 3:30 PMbecause SF is smaller/thinner 😅Perhaps, we should add this change only in 1.3. Such changes better to not add as hotfixes. It was meant to be a slightly-breaking change for
1.1 -> 1.2
1.3 stable will be later, but also soon.Alexander Maryanovsky
12/05/2022, 6:29 PMKirill Grouchnikov
12/05/2022, 7:04 PM