Skip to content

Commit f003f58

Browse files
committed
content: Correctly apply font-size to interpret "em" on the same KaTeX span
In CSS, the `em` unit is the font-size of the element, except when defining font-size itself (in which case it's the font-size inherited from the parent). See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/length#em So when the same HTML span has a declared value for font-size, and also a declared value in units of `em` for some other property, the declared font-size needs to be applied in order to correctly interpret the meaning of `em` in the other property's value. It's possible this never comes up in practice -- that KaTeX never ends up giving us a span that gets both a font-size and a height. If it were hard to correctly handle this, we might try to verify that's the case and then rely on it (with an appropriate check to throw an error if that assumption failed). But the fix is easy, so just fix it.
1 parent 86dbcf8 commit f003f58

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/widgets/content.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ class _KatexSpan extends StatelessWidget {
948948

949949
return SizedBox(
950950
height: styles.heightEm != null
951-
? styles.heightEm! * em
951+
? styles.heightEm! * (fontSize ?? em)
952952
: null,
953953
child: widget);
954954
}

0 commit comments

Comments
 (0)