Open Bug 589779 Opened 14 years ago Updated 2 years ago

Extract generic id even from font-family values that have things other than a generic

Categories

(Core :: CSS Parsing and Computation, defect)

x86
Linux
defect

Tracking

()

People

(Reporter: drice, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/8.04 (hardy) Firefox/3.6.8
Build Identifier: 3.6.8

In Firefox 3.6.8 on Ubuntu from package Firefox 3.6.8+build1+nobinonly-0ubuntu0.8.04.1 (hardy-updates)

If all font-family entries given are not found, the final generic-family is not used, at least for monospace.



Reproducible: Always

Steps to Reproduce:
1. System without Lucida Console, with Courier.
2. View https://developer.mozilla.org/samples/cssref/font-family.html
3. Fixed width is rendered properly in Courier.
4. Edit style/dom (or save locally, edit, and view locally) by removing "Courier, " so that the font-family style reads:

.examplemonospace {
	font-family: "Lucida Console",monospace;
}

5. See fixed width example NOT in fixed width.
Actual Results:  
.examplemonospace is rendered in serif.

Expected Results:  
.examplemonospace should be rendered as if it was given font-family:monospace, 

I'd put this as a low priority / minor bug, but I think that it's important to a lot of web apps that want to render fixed width fonts that they can trust font-family: ...., monospace; will always render in fixed width.
This does not happen on my Window's 3.6.8
Derrick, what does your OS report when you run:

 fc-match "Lucida Console",monospace

?
$ fc-match "Lucida Console",monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

Same when quoted

$ fc-match '"Lucida Console",monospace'
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
didn't mean to hit save change so quickly..

$ fc-match '"Lucida Console",Courier,monospace'
n022003l.pfb: "Nimbus Mono L" "Regular"

$ fc-match 'monospace'                         
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"


Note that 'monospace' gives the same result as '"Lucida Console",monospace' but renders differently in Firefox.
Hmm.  That's really odd..  Karl, any idea what's going on here?

Derrick, what's your font preference set to for the monospace font?
In Gnome's System > Preferences > Appearance, I have Fixed width font set to "Monospace" size 10.

in about:config for all font.name.monospace.* I have "monospace".

I have one user-set font.name.* value:

font.name.serif.x-western: "Times New Roman"

*** Resetting that to default clears this bug ***

bizarre.
That's.... really odd, yes.  Does setting it back via about:config cause the bug to reappear?  What about via the prefs dialog?
    Confirmed with openSUSE 11.2's 3.6.8 using
    http://fm.no-ip.com/Auth/Tmp/font-family589779b.html

    fc-match reports andalemo.ttf: "Andale Mono" "Normal"

    FF 4b2 behaves as expected on same system.
Clearing in about:config font.name.serif.x-western: "Sans Serif" to blank fixes it here too.
Yes, changing the font.name.serif.x-western value causes the bug to reappear in real-time.

When property is reset (no bug):

Firefox Preferences > Content
Default font: serif 16
(advanced...)
Fonts for Western:
Porportional: Serif 16
Serif: serif
Sans-serif: sans-serif
Monospace: monospace 12
Minimum font size: None
(checked) Allow pages to choose their own fonts, instead of my selections above 
Default Character Encoding: Western (ISO-8859-1)

With property set to Times New Roman (bug appears)

Firefox Preferences > Content
Default font: Times New Roman 16
(advanced...)
Fonts for Western:
Porportional: Serif 16
Serif: Times New Roman
Sans-serif: sans-serif
Monospace: monospace 12
Minimum font size: None
(checked) Allow pages to choose their own fonts, instead of my selections above 
Default Character Encoding: Western (ISO-8859-1)
Oops. s/font.name.serif.x-western:/font.default.x-western/
Felix, Derrick, do you see the bug with a mozilla.org 3.6.8 as well?  It not happening with 4.0b2 for Felix is interesting.
(In reply to comment #1)
> This does not happen on my Window's 3.6.8

Even with new information, I cannot reproduce this on Windows 3.6.8.  I tried changing the property from the default TImes New Roman to Arial and using a test style of "garbledigook", monospace and it properly rendered in monospace.
Reproduced off a fresh download:

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
(In reply to comment #14)
> Reproduced off a fresh download:
> 
> Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100722
> Firefox/3.6.8

Also reproduced in 3.5.11

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100701 Firefox/3.5.11
With Mozilla.org's 3.6.6 and the same profile as 11.2's 3.6.8 the bad behavior is restored by going into preferences and selecting sans serif for proportional.
Ok.  So sounds like this is just something that got fixed between 3.6 and current trunk?  And the question is whether to backport the fix?

Felix, are you willing to figure out when this got fixed on trunk?
Status: UNCONFIRMED → NEW
Ever confirmed: true
I was mistaken in comment 8. This brokenness was made from Mozilla.org's Firefox 4.0b2 on openSUSE 11.2/KDE3.
What's happening here is that nsStyleContext::GetStyleFont()->mFont is returning a font with two generic families in the name:
  "Lucida Console",monospace,serif

gfxPangoFontGroup is broken when there are two generic families.
That's a bug that's not simple to fix.

The computed style one has a single generic:
font-family: "Lucida Console",monospace;

Where did "serif" come from?
(In reply to comment #19)
> gfxPangoFontGroup is broken when there are two generic families.
> That's a bug that's not simple to fix.

Actually, I can probably fix that by just ignoring any specified families after the first generic.

But I'm still curious as to why there are two generics?
Looks like the two generics might be from this code (though I haven't debugged):

http://hg.mozilla.org/mozilla-central/annotate/f0af50ab4215/layout/style/nsRuleNode.cpp#l3361
http://hg.mozilla.org/mozilla-central/annotate/f0af50ab4215/layout/style/nsRuleNode.cpp#l3001

Seems a bit strange to have two generics, but I need to fix gfxPangoFontGroup for bug 546315 when there are non-generics after the generic family anyway.

This bug can either be marked a dupe of bug 546315, or used to investigate whether two generics in family list is reasonable (and possibly whether generics in author family should affect mGenericID).
There is probably a performance cost to adding extra generic families, on Linux at least, so, if the style system will continue to have two generics, then perhaps gfxPangoFontGroup should remove the second.

There may be some value in having a second generic though: for languages which are not supported by any monospace fonts, a second generic will give the preferred choice between sans-serif and serif (if that means anything for that language).
Depends on: 546315
Now that font families is actually a list, not a flat string, we should be able to look for individual generics in it, no?  So fix that XXX comment in ComputeFontData.  Seems like a good idea to track that in this bug.
Summary: font-family doesn't use generic-family if family-name fonts not found → Extract generic id even from font-family values that have things other than a generic
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: