Skip to content

content: Fix **bold code** rendering with regular weight #501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 2, 2024

Conversation

chrisbobbe
Copy link
Collaborator

Also format **bold text** using weightVariableTextStyle, fixing #499, and update a comment to point to #500.

Before After
image image

Fixes: #498
Fixes: #499

@chrisbobbe
Copy link
Collaborator Author

If #439 is merged first, I should update the commit message for

content: Fix bold code rendering with regular weight

because at that point the needed weightVariableTextStyle won't come from paragraph-content styles, but rather from a custom Typography value.

@chrisbobbe

This comment was marked as resolved.

@chrisbobbe chrisbobbe force-pushed the pr-small-bold-content-fixes branch from 30cbd05 to 26fa0f8 Compare February 2, 2024 01:06
@chrisbobbe

This comment was marked as resolved.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! One small comment below; otherwise LGTM.

@@ -464,15 +464,20 @@ class _InlineContentBuilder {

final InlineContent widget;

InlineSpan build() {
InlineSpan build(BuildContext context) {
_context = context;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_context = context;
assert(_context == null);
_context = context;

@gnprice
Copy link
Member

gnprice commented Feb 2, 2024

(Plus this, I guess:)

If #439 is merged first, I should update the commit message […]

Our experience with variable-weight fonts is that, whenever we use
such a font, we need to specify a "wght" value, even if we want the
text to appear in the boring, regular weight. If we don't specify a
"wght", the text will appear in an extremely light weight.

We use a variable-weight font (Source Code Pro) for rendering inline
code spans, so that's why we were using weightVariableTextStyle
here. As an unfortunate result, when a code span appears inside a
bold ("strong") span, the outer span's bold-weight style has been
getting clobbered, and the code span appears in regular weight.

Fortunately, removing the `weightVariableTextStyle` from the inline
code style doesn't actually cause any inline spans to appear at
minimum weight. This is a relief, and it follows from the presence
of a `weightVariableTextStyle` applied widely across the app; see
zulipTypography and 6784ef9. We apply it widely across the app
because we apply Source Sans 3 widely across the app, and that is
also a variable-weight font. Moreover, Source Code Pro and Source
Sans 3 seem closely related (and were designed by the same person),
so it's likely that their "wght" axes are identical.

Fixes: zulip#498
@chrisbobbe chrisbobbe force-pushed the pr-small-bold-content-fixes branch from 26fa0f8 to 4c0c6cd Compare February 2, 2024 01:46
@chrisbobbe
Copy link
Collaborator Author

Thanks for the review! Revision pushed.

@gnprice
Copy link
Member

gnprice commented Feb 2, 2024

Thanks! Looks good; merging.

@gnprice gnprice merged commit 4c0c6cd into zulip:main Feb 2, 2024
@chrisbobbe chrisbobbe deleted the pr-small-bold-content-fixes branch February 2, 2024 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants