Closed Bug 437356 Opened 13 years ago Closed 13 years ago
set up shared font entry object
On Mac/Windows we set up a FontEntry object to contain data related to a given font face. For user-downloaded fonts, we need separate objects to track these. First step is to share code between platforms so that this can be shared with user font objects. This will add a small amount of overhead but should reduce the amount of platform-specific code needed for font matching and available weight lookups. Using the QT code set up by Stuart as a starting point to create a shared version for Mac/Windows, then Linux.
Basic idea is to pull font matching code into common code shared across platforms. A font entry represents a single underlying font face, a font family a set of faces. Font matching decisions are made in common code attached to the font group. This will also allow the font matching code on Windows/Mac to be used on Linux. Based on Stuart's gfxQtFonts version, with selected features from Windows/Mac as needed. gfxFontEntry ==> represents underlying font family PRBool TestCharacterMap(PRUint32 aCh); nsresult ReadCMAP(); gfxFontFamily ==> represents underlying font face, set of gfxFontEntry gfxFontEntry *FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBold); gfxFont ==> matched font <font entry, style> gfxTextRange ==> utility struct for recording font matches gfxFontGroup ==> set of matched fonts gfxFont *FindFontForChar(PRUint32 ch, PRUint32 prevCh, PRUint32 nextCh, gfxFont *aFont); PRUint32 ComputeRanges(nsTArray<TextRange>& mRanges, nsString& mString); PRBool HasCharacter(gfxFont *aFont, PRUint32 ch); gfxFontEntry* WhichFontSupportsChar(const nsTArray<nsRefPtr<gfxFontEntry> >& foo, PRUint32 ch); gfxFontEntry* WhichPrefFontSupportsChar(PRUint32 aCh) gfxPlatform ==> pref font lists, general lookups gfxFontFamily *FindFontFamily(const nsAString& aName); gfxFontEntry *FindFontEntry(const nsAString& aName, const gfxFontStyle& aFontStyle); gfxFontEntry* FindFontForChar(const PRUint32 aCh, gfxFont *aPrevFont); GetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<gfxFontEntry> > *array) SetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<gfxFontEntry> >& array)
see also bug 366664.
This patch implements font matching under Mac OS X via generic font matching code in gfxFontGroup using code based on Stuart's Qt font handling code. The ComputeRanges routine sets up an array of ranges within a string, each with an associated font. ComputeRange calls FindFontForChar_NFE on each character, which tests the cmaps of fonts in the font group, followed by pref fonts and system fonts. Pref font and system fonts are handled in WhichPrefFontSupportsChar_NFE and WhichSystemFontSupportsChar_NFE. The _NFE suffix is temporary until I can move this over to all platforms. As a result, the font matching code I wrote in gfxAtsuiFonts (CmapFontMatcher) goes away (sniffle, sniffle...). Platform-specific font objects inherit from: gfxFontEntry - style information (italic, weight, etc.) - character map gfxFontFamily - maps <font family, style> ==> gfxFontEntry (FindFontForStyle) - style ==> list of weights handled by platform-specific code (FindWeightsForStyle) So if platform X needs to implement font matching, they will need: - setup code in InitTextRun to call ComputeRanges and then interface with the platform layout code - appropriate methods for WhichPrefFontSupportsChar_NFE and WhichSystemFontSupportsChar_NFE - subclasses of gfxFontEntry/gfxFontFamily to implement TestCharacterMap The next step is to get this running on Windows, then wait for Stuart to get back so he has a chance to evaluate this before I attempt to work on the Linux version.
Priority: -- → P1
Move ComputeRanges out of UniscribeItem code and use generic version in gfxFontGroup. Need to move the CJK pref handling code into gfxPlatform and reduce it.
FindFontEntry now uses generic style matching. Next step is to make sure this compiles on Linux, figure out how to integrate into Pango or FT code.
Cleanup procedure names.
Attachment #327568 - Attachment is obsolete: true
Comment on attachment 328314 [details] [diff] [review] patch, v.0.5, cleanup Ok, I think this should be good for now. I'd like to move the name completely out of gfxFont but that would mean doing more work on the Linux font code. I'll spin off a separate bug for that. Follow-on work will happen with bug 441473.
Comment on attachment 328314 [details] [diff] [review] patch, v.0.5, cleanup i'd really like +gfxFont::gfxFont(const nsAString &aName, const gfxFontStyle *aFontStyle, gfxFontEntry *aFontEntry) : to just take a FontEntry and Style (in that order) I might suggest renaming FontEntry to FontFace as well. otherwise, this looks great. good job.
Adjust the gfxFont constructor to only take a font entry, style. gfxPangoFont is initialized with a stub version of a gfxPangoFontEntry that is only used for the name. Decided not to rename FontEntry ==> FontFace right now as this will cause all sorts of pain in follow-on patches at this point.
Attachment #332183 - Attachment description: patch, v.0.5, const for gfxFont takes font entry, style → patch, v.0.6, const for gfxFont takes font entry, style
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.