Colton Idle
04/05/2021, 11:12 PMSean McQuillan [G]
04/06/2021, 4:59 PMColton Idle
04/06/2021, 5:08 PMColton Idle
04/06/2021, 7:09 PMColton Idle
04/06/2021, 7:10 PMColton Idle
04/06/2021, 7:11 PMval header = TextStyle(
fontFamily = Rubik,
fontSize = 14.sp,
fontWeight = FontWeight.Normal,
lineHeight = 22.sp,
letterSpacing = (-0.24).sp
)
Colton Idle
04/06/2021, 7:12 PMval article = TextStyle(
fontFamily = Rubik,
fontSize = 18.sp,
fontWeight = FontWeight.Medium,
lineHeight = 24.sp,
letterSpacing = (-0.31).sp
)
Colton Idle
04/06/2021, 7:15 PM@ExperimentalMaterialApi
@Composable
fun ArticleItem(
header: String,
articleTitle: String,
articlePreview: String,
) {
Card(
modifier = Modifier.padding(horizontal = 16.dp),
) {
Column {
Box(
modifier = Modifier
.aspectRatio(16 / 9F)
.background(Color.Gray),
)
Column(Modifier.padding(horizontal = 24.dp)) {
Spacer(Modifier.height(24.dp))
Text(
header,
style = CustomTypeScale.header,
maxLines = 1,
color = Color(0xff212121),
overflow = TextOverflow.Ellipsis
)
Text(
articleTitle,
color = Color(0xff00B4FF),
style = CustomTypeScale.article,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
Spacer(Modifier.height(24.dp))
Text(
articlePreview,
maxLines = 5,
style = CustomTypeScale.header,
color = Color(0xff212121),
overflow = TextOverflow.Ellipsis,
)
Spacer(Modifier.height(24.dp))
}
}
}
}
Colton Idle
04/06/2021, 7:19 PMColton Idle
04/06/2021, 7:20 PMSean McQuillan [G]
04/06/2021, 7:22 PMSean McQuillan [G]
04/06/2021, 7:25 PMColton Idle
04/06/2021, 7:28 PMSean McQuillan [G]
04/06/2021, 7:28 PMColton Idle
04/06/2021, 7:30 PMobject CustomTypeScale {
val header = TextStyle(
fontFamily = Rubik,
fontSize = 14.sp,
fontWeight = FontWeight.Normal,
lineHeight = 22.sp,
letterSpacing = (-0.24).sp
)
val article = TextStyle(
fontFamily = Rubik,
fontSize = 18.sp,
fontWeight = FontWeight.Medium,
lineHeight = 24.sp,
letterSpacing = (-0.31).sp
)
val body = TextStyle(
fontFamily = Rubik,
fontSize = 14.sp,
fontWeight = FontWeight.Normal,
lineHeight = 22.sp,
letterSpacing = (-0.24).sp
)
Siyamed
04/06/2021, 7:32 PMSiyamed
04/06/2021, 7:32 PMSiyamed
04/06/2021, 7:32 PMColton Idle
04/06/2021, 7:34 PMSean McQuillan [G]
04/06/2021, 8:51 PMModifier.paddingFromBaseline(top=, bottom=)
Sean McQuillan [G]
04/06/2021, 8:51 PMSean McQuillan [G]
04/06/2021, 8:51 PMSean McQuillan [G]
04/06/2021, 8:52 PMSean McQuillan [G]
04/06/2021, 8:52 PM@ExperimentalMaterialApi
@Composable
fun ArticleItem(
header: String,
articleTitle: String,
articlePreview: String,
) {
Card(
modifier = Modifier.padding(horizontal = 16.dp),
) {
Column {
Box(
modifier = Modifier
.aspectRatio(16 / 9F)
.background(Color.Gray),
)
Column(Modifier.padding(24.dp)) {
Text(
header,
style = CustomTypeScale.header,
color = Color(0xff212121),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.paddingFromBaseline(top = 26.sp) // after the 24.dp padding
)
Text(
articleTitle,
color = Color(0xff00B4FF),
style = CustomTypeScale.article,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.paddingFromBaseline(top = 24.sp)
)
Spacer(Modifier.height(24.dp))
Text(
articlePreview,
maxLines = 5,
style = CustomTypeScale.body,
color = Color(0xff212121),
overflow = TextOverflow.Ellipsis,
modifier = Modifier.paddingFromBaseline(top = 22.sp)
)
}
}
}
}
Sean McQuillan [G]
04/06/2021, 8:54 PMColton Idle
04/06/2021, 9:06 PMColton Idle
04/06/2021, 9:11 PMColton Idle
04/06/2021, 9:14 PMColton Idle
04/06/2021, 9:16 PMColton Idle
04/06/2021, 9:17 PMSean McQuillan [G]
04/06/2021, 9:43 PMSean McQuillan [G]
04/06/2021, 9:44 PMSean McQuillan [G]
04/06/2021, 9:51 PMColton Idle
04/06/2021, 9:52 PMColton Idle
04/06/2021, 9:53 PMSean McQuillan [G]
04/06/2021, 9:54 PM@Composable
fun LineHeightSizedText(text: String) {
with(LocalDensity.current) {
Text(
text,
style = CustomTypeScale.header,
color = Color(0xff212121),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.defaultMinSize(
minHeight = CustomTypeScale.header.lineHeight.value.toDp()
)
)
}
}
Is what comes to mind πSean McQuillan [G]
04/06/2021, 9:55 PMColton Idle
04/06/2021, 9:58 PMColton Idle
04/06/2021, 9:59 PMColton Idle
04/06/2021, 10:11 PMSean McQuillan [G]
04/06/2021, 10:11 PMSean McQuillan [G]
04/06/2021, 10:11 PMChris Sinco [G]
04/07/2021, 5:13 AMChris Sinco [G]
04/07/2021, 5:14 AMChris Sinco [G]
04/07/2021, 5:19 AMChris Sinco [G]
04/07/2021, 5:24 AMColton Idle
04/07/2021, 9:54 AMColton Idle
04/07/2021, 10:19 AMChris Sinco [G]
04/07/2021, 3:58 PMare you basically saying that thereβs no real unifying way to do this across figma/sketch and ios/web/android?I donβt think itβs impossible, but it would require work and awareness from the design tools companies to address this, especially when they provide inspect and code gen tools for designer -> developer handoff. Like here, you can see the code suggestions from Figma vary quite a bit depending on platform:
Colton Idle
04/07/2021, 3:59 PMColton Idle
04/07/2021, 4:01 PMSean McQuillan [G]
04/07/2021, 4:16 PMSean McQuillan [G]
04/07/2021, 4:18 PMColton Idle
04/07/2021, 4:24 PMSean McQuillan [G]
04/07/2021, 4:24 PMColton Idle
04/07/2021, 4:25 PMColton Idle
04/07/2021, 4:26 PMSketchText
composable which will take the same attributes, but will calculate that top padding the same as sketch does.Colton Idle
06/08/2021, 9:44 PMtad
06/11/2021, 12:08 AMfun Modifier.fillLineHeight(
lineHeight: TextUnit = TextUnit.Unspecified
): Modifier = composed(debugInspectorInfo {
name = "fillLineHeight"
value = lineHeight
}) {
val resolvedLineHeight = lineHeight.takeOrElse { LocalTextStyle.current.lineHeight }
if (resolvedLineHeight.isSpecified) {
val lineHeightPx = with(LocalDensity.current) { resolvedLineHeight.roundToPx() }
Modifier.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
val space = (lineHeightPx - placeable.height % lineHeightPx) % lineHeightPx
layout(placeable.width, placeable.height + space) {
placeable.place(0, space / 2)
}
}
} else {
Modifier
}
}
Sean McQuillan [G]
06/12/2021, 12:10 AMCan
03/29/2022, 9:02 AMColton Idle
03/29/2022, 10:42 AMColton Idle
03/29/2022, 10:44 AMCan
03/29/2022, 1:30 PMCan
03/29/2022, 1:31 PMSiyamed
03/29/2022, 5:39 PMSiyamed
03/29/2022, 5:40 PMtad
03/29/2022, 5:40 PMSiyamed
03/29/2022, 5:41 PMSiyamed
03/29/2022, 5:41 PMtad
03/29/2022, 5:42 PMtad
03/29/2022, 5:42 PMSiyamed
03/29/2022, 5:43 PMSiyamed
03/29/2022, 5:43 PMSiyamed
03/29/2022, 5:44 PMSiyamed
03/29/2022, 5:44 PMSiyamed
03/29/2022, 5:45 PMtad
03/29/2022, 5:45 PMtad
03/29/2022, 5:45 PMtad
03/29/2022, 5:46 PMSiyamed
03/29/2022, 5:50 PMtad
03/29/2022, 6:01 PMtad
03/29/2022, 6:02 PMfun Modifier.fillLineHeight(
lineHeight: TextUnit = TextUnit.Unspecified,
fontSize: TextUnit = TextUnit.Unspecified
): Modifier = composed(
debugInspectorInfo {
name = "fillLineHeight"
value = lineHeight
properties["lineHeight"] = lineHeight
properties["fontSize"] = fontSize
}
) {
val resolvedFontSize = fontSize.takeOrElse { LocalTextStyle.current.fontSize }
val resolvedLineHeight = lineHeight.takeOrElse { LocalTextStyle.current.lineHeight }
if (resolvedLineHeight.isSpecified) {
layout { measurable, constraints ->
val fontSizePx = resolvedFontSize.roundToPx()
val lineHeightPx = resolvedLineHeight.roundToPx()
val placeable = measurable.measure(constraints)
val firstLineBottom = placeable[FirstBaseline]
val firstLineTop = firstLineBottom - fontSizePx
val space = (lineHeightPx - placeable.height % lineHeightPx) % lineHeightPx
layout(placeable.width, placeable.height + space) {
placeable.place(0, (space - firstLineTop) / 2)
}
}
} else {
this
}
}
Siyamed
03/29/2022, 6:21 PMCan
03/29/2022, 6:23 PMLineHeightBehevaiour
is reflecting this quite nicely πColton Idle
03/31/2022, 2:44 AMSiyamed
04/19/2022, 5:36 AMSiyamed
04/19/2022, 5:37 AMSiyamed
04/19/2022, 5:39 AMCan
04/19/2022, 6:32 AMColton Idle
04/19/2022, 1:30 PMCan
04/19/2022, 1:32 PMSiyamed
05/11/2022, 7:20 PMCan
05/11/2022, 7:21 PMSiyamed
05/11/2022, 7:21 PMtad
05/11/2022, 7:23 PMSiyamed
05/11/2022, 7:24 PMColton Idle
05/11/2022, 7:25 PMColton Idle
05/13/2022, 11:21 PMval H1 =
TextStyle(
lineHeightStyle = LineHeightStyle(
alignment = LineHeightStyle.Alignment.Center,
trim = LineHeightStyle.Trim.None
),
platformStyle = PlatformTextStyle(includeFontPadding = false),
fontFamily = MyRoboto,
fontSize = 36.sp,
fontWeight = FontWeight.Bold,
lineHeight = 40.sp,
)
Siyamed
05/14/2022, 6:03 AMSiyamed
05/14/2022, 6:07 AMColton Idle
05/14/2022, 4:52 PMgildor
06/09/2022, 3:49 AMgildor
06/09/2022, 7:13 AMCan
06/09/2022, 7:15 AMgildor
06/09/2022, 7:16 AMgildor
06/09/2022, 7:36 AMText(
text = "BandLab lets you make and share music",
color = Color.Black,
style = TextStyle(
fontSize = 12.sp,
lineHeight = 16.sp,
fontWeight = FontWeight.Medium,
fontFamily = null, // custom font family here
platformStyle = PlatformTextStyle(
paragraphStyle = PlatformParagraphStyle(includeFontPadding = false),
spanStyle = null
),
lineHeightStyle = LineHeightStyle(
alignment = LineHeightStyle.Alignment.Center,
trim = LineHeightStyle.Trim.None
)
),
)
Siyamed
06/09/2022, 7:47 AMgildor
06/09/2022, 7:49 AMHopefully the font is not paidIt is, but I can share it privately, because we are owners of the font
gildor
06/09/2022, 7:53 AMThis tells me possibly the font ascent is not set according to the characters displayedBut what I see is that baseline is actually higher than I expecting (you can compare with default font), so itβs not only caused by general font appearance Cannot comment about ascent/descent values which cause problem. Can I somehow check it?
Can
06/09/2022, 7:54 AMgildor
06/09/2022, 7:56 AMThe top version looks clipped (20 Feb) whereas the bottom is notitβs indeed a problem by itself, with clipping, but it reproducible only because top line there, for example if I add Γ to top line it looks fine, but on date line it looks cropped. But what is really a problem for me is baseline alignment, cropping is not a problem on practice for us because line height is larger than font size (~1.3)
gildor
06/09/2022, 8:04 AMgildor
06/09/2022, 8:15 AMJust a wild guess: Can you try to swap Text for BasicText@Can Nope, no difference
Colton Idle
07/13/2022, 5:13 PMColton Idle
07/13/2022, 5:27 PMSiyamed
07/13/2022, 5:32 PMSiyamed
07/13/2022, 5:32 PMI'm trying to find the blog post that was posted about a month before this one ^ related to text/font padding,I couldnt remember which one you had in mind.
Siyamed
07/13/2022, 5:32 PMSiyamed
07/13/2022, 5:32 PMSiyamed
07/13/2022, 5:33 PMColton Idle
07/13/2022, 5:34 PMColton Idle
07/13/2022, 5:35 PMSiyamed
07/13/2022, 5:38 PMColton Idle
07/13/2022, 5:39 PM