Bug 6530 - Fixed-pitch font detection doesn't work for many fonts
Summary: Fixed-pitch font detection doesn't work for many fonts
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
Depends on: 6218 6529
Blocks: 6400
  Show dependency treegraph
Reported: 2006-01-14 04:37 PST by Alexey Proskuryakov
Modified: 2010-06-10 14:21 PDT (History)
1 user (show)

See Also:

test app listing what AppKit thinks about fixed-pitch fonts (5.94 KB, application/zip)
2006-01-14 04:47 PST, Alexey Proskuryakov
no flags Details
test case (504 bytes, text/html)
2006-01-14 04:50 PST, Alexey Proskuryakov
no flags Details
proposed patch (3.18 KB, patch)
2006-01-14 04:52 PST, Alexey Proskuryakov
darin: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2006-01-14 04:37:30 PST
WebKit uses several hacks to work around problems with NSFixedPitchFontMask, as reported by AppKit 
(see <rdar://problem/3999467>, <rdar://problem/4032938>). Some of them are no longer needed, but 
some other fonts are still mishandled (see below).
Comment 1 Alexey Proskuryakov 2006-01-14 04:47:41 PST
Created attachment 5662 [details]
test app listing what AppKit thinks about fixed-pitch fonts

Results on my machine (running 10.4.3):

isFixedPitch: Monaco (Monaco)
isFixedPitch: MS-Gothic (MS Gothic)
isFixedPitch: SimSun (SimSun)
Traits: CourierNewPS-ItalicMT (Courier New)
isFixedPitch: CourierNewPS-ItalicMT (Courier New)
isFixedPitch: Webdings (Webdings)
isFixedPitch: Courier (Courier)
Traits: Osaka-Mono (Osaka)
isFixedPitch: Osaka-Mono (Osaka)
Traits: LucidaSans-TypewriterOblique (Lucida Sans Typewriter)
isFixedPitch: LucidaSans-TypewriterOblique (Lucida Sans Typewriter)
isFixedPitch: MS-PGothic (MS PGothic)
Traits: LucidaSans-TypewriterBold (Lucida Sans Typewriter)
isFixedPitch: LucidaSans-TypewriterBold (Lucida Sans Typewriter)
Traits: CourierNewPS-BoldMT (Courier New)
isFixedPitch: CourierNewPS-BoldMT (Courier New)
isFixedPitch: MS-PMincho (MS PMincho)
isFixedPitch: Courier-Bold (Courier)
isFixedPitch: JCsmPC (#PCMyungjo)
isFixedPitch: MS-Mincho (MS Mincho)
Traits: GB18030Bitmap (GB18030 Bitmap)
Traits: CourierNewPS-BoldItalicMT (Courier New)
isFixedPitch: CourierNewPS-BoldItalicMT (Courier New)
Traits: AndaleMono (Andale Mono)
isFixedPitch: AndaleMono (Andale Mono)
Traits: CourierNewPSMT (Courier New)
isFixedPitch: CourierNewPSMT (Courier New)
Traits: LucidaSans-TypewriterBoldOblique (Lucida Sans Typewriter)
isFixedPitch: LucidaSans-TypewriterBoldOblique (Lucida Sans Typewriter)
Traits: LucidaSans-Typewriter (Lucida Sans Typewriter)
isFixedPitch: LucidaSans-Typewriter (Lucida Sans Typewriter)
isFixedPitch: PMingLiU (PMingLiU)
Traits: Ahem (Ahem)
isFixedPitch: Ahem (Ahem)

It can be seen that workarounds for Osaka-Mono are no longer needed, as 
-[NSFont isFixedPitch] and -[NSFontManager traitsOfFont:] are now in
Monaco and Courier are problematic because -[NSFontManager traitsOfFont:] 
doesn't report them as fixed pitch. OTOH, MS-PGothic is one of several Asian
that are reported as fixed-pitch, while they shouldn't be (MS-Gothic,
MS-Mincho, MS-PMincho, #PCMyungjo, PMingLiU, SimSun aren't handled in WebKit).
Comment 2 Alexey Proskuryakov 2006-01-14 04:50:00 PST
Created attachment 5663 [details]
test case
Comment 3 Alexey Proskuryakov 2006-01-14 04:52:15 PST
Created attachment 5664 [details]
proposed patch
Comment 4 Alexey Proskuryakov 2006-01-14 04:55:15 PST
The patch itself doesn't depend on bug 6529, but the test case does.
Comment 5 Darin Adler 2006-01-21 10:57:06 PST
Comment on attachment 5664 [details]
proposed patch

Adding more special cases for fonts that are incorrectly reported as fixed pitch is fine. But I do want each of the fonts that behave wrong in this respect reported to the AppKit team in a bugreport.apple.com bug report (not necessarily a separate one for each font family). I don't think it's good to remove the list of bug numbers and fonts that were mentioned in those bugs from the code. We could convert it to a more-terse format, but I want to keep a connecton between special case family names and the bug reports mentioning the need for them.

I'm not sure that the NSFixedPitchFontMask in the traits should be identical to the results of isFontFixedPitch: -- since the former is used for selecting fonts, and the latter is used to ensure that glyph widths all match it's not clear to me that they need to be in sync. But perhaps there's concrete reason why it's important to have both contain the exception list. Can you explain why?