Open Bug 1565153 Opened 6 years ago Updated 3 years ago

Firefox download custom web font even when there is no text in page

Categories

(Core :: Layout: Text and Fonts, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: dehghani.m.c, Unassigned)

Details

Hi,

Firefox download custom font for following situation:

@font-face { font-family: 'whatever'; }
<div style="font-family: whatever"></div>
Which is wrong and for empty pages there is no need to downloading fonts.

Component: General → Layout: Text and Fonts
Product: Firefox → Core

The first font in the font-family list is needed in order to resolve the values of CSS units like 'ch' and 'ex', even if no text is present.

So my feeling is that this should be closed as invalid. Mehdi, do you have a specific reason you think this should behave differently?

Flags: needinfo?(dehghani.m.c)

Should we do that even if no ex / ch units are specified?

I haven't tracked this down fully, but I suspect we need the first font in order to get metrics that are used to compute the normal line height, which is needed to set up the block reflow input for any block frames - even if they're empty.

@Jonathan, I think font should be downloaded only when it actually used. I run some test using Chrome and seems like web kit based browsers doesn't download font unless the tag/html have some content.

When there is no text/content to use downloaded font, would you tell me what is point of downloading that font?

Flags: needinfo?(dehghani.m.c) → needinfo?(jfkthame)

As mentioned above, the font's metrics are used to compute the normal line-height value, which may be needed even if there's no content.

Obviously, there may be cases where it really isn't needed, but it's not as simple as "there's no text in the element".

Flags: needinfo?(jfkthame)
Priority: -- → P5

That's right, maybe there are other cases that Firefox do unnecessary works, this is one of them.

Severity: normal → S3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.