Closed Bug 116151 Opened 24 years ago Closed 24 years ago

review new FreeType2 code for FreeType checkin

Categories

(Core :: Internationalization, defect)

x86
Linux
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: bstell, Assigned: bstell)

References

Details

Attachments

(1 file, 8 obsolete files)

this is to help manage the checkin of the code that interacts with the FreeType2 library and implements the moz font object for this code
Attached patch patch; nsFreeType.cpp/h (obsolete) — — Splinter Review
Blocks: 116147
brian, I don't think I really understood the intrinsic detail of your work. I could not spot anything suspecious except a small issue below. Make sure the issue below is not a real issue or fix it if it is. Then r=shanjian #if (!defined(HAVE_FREETYPE2)), should you have a dummy implementation of "static nsFreeTypeFont * nsFreeTypeFont ::NewFont(nsFreeTypeFace *, PRUint16, const char *);" ?
Assignee: shanjian → bstell
it simplifies the code in nsFontMetrics.cpp thanks Shanjian
Status: NEW → ASSIGNED
Attached patch Makefile.in (obsolete) — — Splinter Review
Summary: review config changes for FreeType checkin → review new FreeType2 code for FreeType checkin
brian, Let me state my question. When "HAVE_FREETYPE2" is not defined, you declare a static member for "nsFreeTypeFont ::NewFont". But I did not see a dummy implementation of this declaration in nsFreeType.cpp file. So I was wondering that you might have a link time error when compile without "HAVE_FREETYPE2" .
Its declared in both cases: +#if (!defined(HAVE_FREETYPE2)) +// nsFreeType stubs for development systems without a FreeType dev env +class nsFreeTypeFace; +class nsFreeTypeFont : public nsFontGTK { +public: + static nsFreeTypeFont *NewFont(nsFreeTypeFace *, PRUint16, const char *); +}; +#else ... +class nsFreeTypeFont : public nsFontGTK +{ +public: + + nsFreeTypeFont(); + nsFreeTypeFont(nsFreeTypeFace *, PRUint16, const char *); + virtual ~nsFreeTypeFont(void); + static nsFreeTypeFont *NewFont(nsFreeTypeFace *, PRUint16, const char *); + + void LoadFont(void); + ...
add myself to cc list.
Attached patch de-rotted patch (obsolete) — — Splinter Review
de-rotted and moved nsFreeType.{h,cpp} from gfx/src/gtk to gfx/src/x11shared
Attachment #62306 - Attachment is obsolete: true
Attachment #62602 - Attachment is obsolete: true
added function suggested by Shanjian for case when not MOZ_ENABLE_FREETYPE2
Attachment #67371 - Attachment is obsolete: true
Shanjian: would you kindly review this? Thanks
Assignee: bstell → shanjian
Status: ASSIGNED → NEW
1, Can all those stub function declaration like "typedef FT_Error (*FT_Done_Face_t)(FT_Face);" and "extern FT_Done_Face_t nsFT_Done_Face;" be moved to nsFreeType.cpp files? Or they are needed by some other files? 2, Function "deltaMicroSeconds" should be defined and implemented within "#ifdef DEBUG_bstell" if they are only needed for performance measuring purpose. 3, + inline PRBool FreeTypeAvailable() { return sAvailable; }; + inline static FTC_Manager GetFTCacheManager() { return sFTCacheManager; }; + inline static FT_Library GetLibrary() { return sFreeTypeLibrary; }; + inline static FTC_Image_Cache GetImageCache() { return sImageCache; }; "inline" is redundant if implementation just follows. "FreeTypeAvailable()" might also need a "static". Otherwise you might have to have a "nsFreeType" instance to access it. 4, In "nsFreeType::InitGlobals", if freetype library availability is not a rare issue, "nsFreeType::InitLibrary" probably should be called earlier. 5, Do you plan to add "IsFreeTypeFont" to "nsFontGTK"?If not, its existence has no reason. If yes, add a "nsFontGTK::GetFontType" might be better for future extension.
Assignee: shanjian → bstell
Shanjain: thank you for your prompt and careful work on this. > 1, Can all those stub function declaration like > "typedef FT_Error (*FT_Done_Face_t)(FT_Face);" and Some of these are used in other files, such as (*FT_Done_Face_t)(FT_Face) which is use in nsFontCatalog.cpp. For maintainability, I would prefer to keep all these together unless there is some reason to separate them. > 2, Function "deltaMicroSeconds" should be defined and implemented > within "#ifdef DEBUG_bstell" if they are only needed for performance > measuring purpose. Good idea. > 3, > + inline PRBool FreeTypeAvailable() { return sAvailable; }; > + inline static FTC_Manager GetFTCacheManager() { return sFTCacheManager; }; > + inline static FT_Library GetLibrary() { return sFreeTypeLibrary; }; > + inline static FTC_Image_Cache GetImageCache() { return sImageCache; }; > "inline" is redundant if implementation just follows. It is my understanding that inline means "put this right in the code each time" whereas "defined in the header file" actually makes a subroutine call. I don't have strong feelings about this so if you do I can change this. > "FreeTypeAvailable()" might also need a "static". Otherwise you might have > to have a "nsFreeType" instance to access it. I'll look at this. > 4, In "nsFreeType::InitGlobals", if freetype library availability is not a > rare issue, "nsFreeType::InitLibrary" probably should be called earlier. Could you elaborate on why calling it earlier might be better? > 5, Do you plan to add "IsFreeTypeFont" to "nsFontGTK"?If not, its existence > has no reason. Yes, in other parts of this work nsFontGTK gets a IsFreeTypeFont method. > If yes, add a "nsFontGTK::GetFontType" might be better for future extension. Very interesting idea. I'm feeling very short on time so would it be okay if we postpone this improvment for later?
2, On secound thought, I think your current implementation is better. A member function defined within the class definition is taken to be an inline member function. There should be no harm to declare it explicitly, though not necessary. So leave it that way. 4, I mean instead of + gFreeTypeFaces = new nsHashtable(); + if (!gFreeTypeFaces) { + return NS_ERROR_OUT_OF_MEMORY; + } + if (!nsFreeType::InitLibrary()) { + // since the library may not be available on any given system + // failing to load is not considered a fatal error + // return NS_ERROR_OUT_OF_MEMORY; + } how about: + if (!nsFreeType::InitLibrary()) { + // since the library may not be available on any given system + // failing to load is not considered a fatal error + // return NS_ERROR_OUT_OF_MEMORY; + } + gFreeTypeFaces = new nsHashtable(); + if (!gFreeTypeFaces) { + return NS_ERROR_OUT_OF_MEMORY; + } In case there is no library, we don't bother to create a hash table. 5, Yes, I am OK with that (ie. postpone it for later).
Attached patch changes req by Shanjian (obsolete) — — Splinter Review
I moved "gFreeTypeFaces = new nsHashtable" to after "nsFreeType::InitLibrary".
Attachment #67373 - Attachment is obsolete: true
Could you put "deltaMicroSeconds" within "#ifdef DEBUG_bstell" , after that, r=shanjian
Attachment #67783 - Attachment is obsolete: true
Comment on attachment 67859 [details] [diff] [review] wrap deltaMicroSeconds in #ifdef ENABLE_TIME_MACROS looks fine to me. r=shanjian
Attachment #67859 - Flags: review+
some comments on "deltaMicroSeconds" patch, I don't mean to sound picky, but I just wrote down what I was thinking as I went through this patch. 1) nsFreeType.h: a) globals kinda bug me, shouldn't these go in a service, or be part of a class? b) OS2_* #defines, do all platforms need this? It sounds like OS/2. c) yank DEBUG_bstell ifdefs, or define them to something like DEBUG_truetype and then write an if clause to turn this on for DEBUG_bstell. 2) nsFreeType.cpp: a) FLOOR #define assumes 64-bit, look at xpcom/build/malloc.c:4595 for definition that uses size. b) nsFT_Done_Face: does this (and other variables near it) need to be global? See 1a. c) PR_NOW() usage should be cleaner, maybe the resolution here doesn't matter. Call it once, before the printf. d) I hate goto statements. They are hard to read, any chance of going to if/else? If not then that's ok. e) nsFreeTypeFont::NewFont(), first |if| is always true (ximage). f) Where is FREE_FONT_PRINTF defined? I couldn't find it, maybe already checked in. g) You're including xpcom & nspr headers, why use plain "int" return values? PRInt32's? h) Bit-shifting is using int's, longs, and assuming that 16 is gonna work. What about 64-bit architectures? I don't need answers to all of these, I am mostly concerned with "does this work?", portability, and memory/global bloat issues.
oops, one more: nsFreeTypeGetFaceID() has a char buf[32] in there, then we're adding stuff to it. ? string class?
Attached patch changes req by mcafee (obsolete) — — Splinter Review
> a) globals kinda bug me, shouldn't these > go in a service, or be part of a class? Moved the function pointers to class statics. > b) OS2_* #defines, do all platforms need this? It sounds like OS/2. These are bit defines for a field in a table in a TrueType font. > c) yank DEBUG_bstell ifdefs, or define them to > something like DEBUG_truetype and then write > an if clause to turn this on for DEBUG_bstell. Since the timers were only used for debug I got rid of the timer defines. > a) FLOOR #define assumes 64-bit, look at > xpcom/build/malloc.c:4595 for definition that > uses size. These modify FreeType 26.6 "fixed floating point" integers (32 bit numbers where 26 bit are for the integer part and 6 bits are for the fraction). Prepended 'FT_' to these macros. > b) nsFT_Done_Face: does this (and other variables near it) > need to be global? See 1a. Fixes when the function pointers were made class statics. > c) PR_NOW() usage should be cleaner, maybe the resolution here > doesn't matter. Call it once, before the printf. Gone. > d) I hate goto statements. They are hard to read, any chance > of going to if/else? If not then that's ok. I use goto to standardize error cleanup. I removed the cases where the goto was only called once. > e) nsFreeTypeFont::NewFont(), first |if| is always true (ximage). This is a place holder for where to add Xrender support. Added a comment there. > f) Where is FREE_FONT_PRINTF defined? I couldn't find it, maybe > already checked in. It is defined in bug 116153. I will need to be careful on checkin order (or perhaps comment this out until if needed. > g) You're including xpcom & nspr headers, why use plain "int" > return values? PRInt32's? Done. > h) Bit-shifting is using int's, longs, and assuming that 16 > is gonna work. What about 64-bit architectures? The (x)>>16 is converting from FT_Fixed 16.16 format. I made this a macro FT_16_16_TO_REG(). > I don't need answers to all of these, I am mostly concerned with > "does this work?", portability, and memory/global bloat issues. This code is disabled by default by a pref so it should only end up adding a load and test ref test to the standard setup. > nsFreeTypeGetFaceID() has a char buf[32] in there, > then we're adding stuff to it. ? string class? Just sprintf'ing a number into a buffer so I can append it onto a name. The number will range from 1-10.
Attachment #67859 - Attachment is obsolete: true
r=mcafee
Attachment #68257 - Attachment is obsolete: true
Attachment #69526 - Attachment is obsolete: true
Comment on attachment 69539 [details] [diff] [review] de-rot for MathML define sr=mscott, I delegated my reviewing powers to mcafee who is more familiar with this stuff then I am. So now that he has reviewed it, I'm putting my official sr into this bug.
Attachment #69539 - Flags: superreview+
checked in
set status
set status
Status: NEW → ASSIGNED
marking fixed
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
QA Contact: teruko → bstell
the code for the bug has been checked in so I'm closing out this "needs review" bug
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: