Skip to content

Conversation

@bsmth
Copy link
Member

@bsmth bsmth commented Oct 29, 2025

Description

Adding a few relevant characters to the math example.

Motivation

There wasn't really anything that shows much of the benefit of this. This is something minimal to at least show a few characters that look better with this style.

Feedback welcome on other ideas, but I think the original isn't too helpful by itself.

Related issues and pull requests

@bsmth bsmth requested a review from a team as a code owner October 29, 2025 10:00
@bsmth bsmth requested review from chrisdavidmills and removed request for a team October 29, 2025 10:00
@github-actions github-actions bot added the Content:CSS Cascading Style Sheets docs label Oct 29, 2025
@github-actions github-actions bot added the size/xs [PR only] 0-5 LoC changed label Oct 29, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 29, 2025

Preview URLs

Flaws (4)

URL: /en-US/docs/Web/CSS/Reference/Properties/font-family
Title: font-family
Flaw count: 4

  • macros:
    • Macro produces link /en-US/docs/Web/CSS/font which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/font-style which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/font-weight which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/font-variant-emoji which is a redirect

(comment last updated: 2025-10-31 11:26:17)

@bsmth
Copy link
Member Author

bsmth commented Oct 29, 2025

@fred-wang do you have any thoughts for something nice here for demos?

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

Looks good to me, @bsmth. I've got a couple of small comments, but nothing blocking:

  1. I wonder if you want to give the start of the new sentence the same form as the others, i.e., "This is an example of...". I'm not sure it matters really.
  2. Do you also want to give each <div> some bottom margin, so the sentences are less squashed together?

@fred-wang
Copy link
Contributor

@bsmth:

I'm not sure there is a nice example to demo.

Basically, if you use math characters they would either be displayed as tofu or picked from a font installed on your system. font-family: math only says to try to use math fonts from the font.name-list.serif.x-math preference list so they would be all picked from the same font, but if none of them is installed on your system you won't see a difference anyway.

It is particularly important to use math fonts for MathML formulas, if you don't the rendering would be very bad for things like

<math display="block">
  <msqrt>
    <mrow>
      <munderover>
        <mo></mo>
        <mrow>
          <mi>n</mi>
          <mo>=</mo>
          <mn>1</mn>
        </mrow>
        <mrow>
          <mo>+</mo>
          <mn></mn>
        </mrow>
      </munderover>
      <mfrac>
        <mn>10</mn>
        <msup>
          <mi>n</mi>
          <mn>4</mn>
        </msup>
      </mfrac>
    </mrow>
  </msqrt>
</math>

In the past, Firefox had some internal hacks to make sure the font.name-list.serif.x-math preference list is used on a <math> element. Now, the UA stylesheet sets math { font-family: math } on the <math> element which should provide something equivalent. And even if you specify a different font-family, I believe it will still try to fallback to font.name-list.serif.x-math for backward-compat reason. So you won't really see a difference either.

cc @eerii

@bsmth
Copy link
Member Author

bsmth commented Oct 29, 2025

Thanks @chrisdavidmills:

  1. I wonder if you want to give the start of the new sentence the same form as the others, i.e., "This is an example of...". I'm not sure it matters really.

I thought about this, but I think it's a little redundant for the math case.

  1. Do you also want to give each <div> some bottom margin, so the sentences are less squashed together?

Yessir!

@eerii
Copy link

eerii commented Oct 29, 2025

As Fred mentioned, it allows using math { font-family: math } for specifying that some content should use the font.name-list.serif.x-math preference list. We tried getting rid of x-math but it is not feasible at the moment because of how the preference system works. So the hack is still there, only now it matches a bit better with the specification.

As for an example, I can't think of a better one either. It is going to be very dependent on what system and fonts the user has. Here is a comparison between Linux and Android. On Linux you can install fonts that match the font list, so it uses those for math. On Android there isn't any math font, so it is as if the preference doesn't exist. This is what it would look if we didn't set font-family: math (or have the previous hacks) on other platforms.

@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Oct 30, 2025
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@bsmth bsmth closed this Oct 31, 2025
@bsmth bsmth force-pushed the 41506-font-family-example branch from 72e837a to d960038 Compare October 31, 2025 10:52
@bsmth bsmth reopened this Oct 31, 2025
@github-actions github-actions bot removed the merge conflicts 🚧 [PR only] label Oct 31, 2025
@bsmth
Copy link
Member Author

bsmth commented Oct 31, 2025

Thank you @eerii and @fred-wang, I'll leave the updates to be quite minimal then for the moment (limited to 25ac0a2), the context we have from your replies is already quite helpful.

@github-actions github-actions bot added size/s [PR only] 6-50 LoC changed and removed size/xs [PR only] 0-5 LoC changed labels Oct 31, 2025
@bsmth
Copy link
Member Author

bsmth commented Oct 31, 2025

Thanks all, I'm going to merge in the current state for now.

@bsmth bsmth merged commit 5a8de32 into mdn:main Oct 31, 2025
8 checks passed
@bsmth bsmth deleted the 41506-font-family-example branch October 31, 2025 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants