Closed
Bug 116151
Opened 24 years ago
Closed 24 years ago
review new FreeType2 code for FreeType checkin
Categories
(Core :: Internationalization, defect)
Tracking
()
VERIFIED
FIXED
People
(Reporter: bstell, Assigned: bstell)
References
Details
Attachments
(1 file, 8 obsolete files)
|
47.66 KB,
patch
|
mscott
:
superreview+
|
Details | Diff | Splinter Review |
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
| Assignee | ||
Comment 1•24 years ago
|
||
Comment 2•24 years ago
|
||
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
| Assignee | ||
Comment 3•24 years ago
|
||
it simplifies the code in nsFontMetrics.cpp
thanks Shanjian
Status: NEW → ASSIGNED
| Assignee | ||
Comment 4•24 years ago
|
||
| Assignee | ||
Updated•24 years ago
|
Summary: review config changes for FreeType checkin → review new FreeType2 code for FreeType checkin
Comment 5•24 years ago
|
||
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" .
| Assignee | ||
Comment 6•24 years ago
|
||
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);
+ ...
Comment 7•24 years ago
|
||
add myself to cc list.
| Assignee | ||
Comment 8•24 years ago
|
||
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
| Assignee | ||
Comment 9•24 years ago
|
||
added function suggested by Shanjian for case when not MOZ_ENABLE_FREETYPE2
Attachment #67371 -
Attachment is obsolete: true
| Assignee | ||
Comment 10•24 years ago
|
||
Shanjian: would you kindly review this?
Thanks
Assignee: bstell → shanjian
Status: ASSIGNED → NEW
Comment 11•24 years ago
|
||
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
| Assignee | ||
Comment 12•24 years ago
|
||
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?
Comment 13•24 years ago
|
||
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).
| Assignee | ||
Comment 14•24 years ago
|
||
I moved "gFreeTypeFaces = new nsHashtable" to after "nsFreeType::InitLibrary".
Attachment #67373 -
Attachment is obsolete: true
Comment 15•24 years ago
|
||
Could you put "deltaMicroSeconds" within "#ifdef DEBUG_bstell" , after that,
r=shanjian
| Assignee | ||
Comment 16•24 years ago
|
||
Attachment #67783 -
Attachment is obsolete: true
Comment 17•24 years ago
|
||
Comment on attachment 67859 [details] [diff] [review]
wrap deltaMicroSeconds in #ifdef ENABLE_TIME_MACROS
looks fine to me. r=shanjian
Attachment #67859 -
Flags: review+
Comment 18•24 years ago
|
||
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.
Comment 19•24 years ago
|
||
oops, one more:
nsFreeTypeGetFaceID() has a char buf[32] in there,
then we're adding stuff to it. ? string class?
| Assignee | ||
Comment 20•24 years ago
|
||
> 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
Comment 21•24 years ago
|
||
r=mcafee
| Assignee | ||
Comment 22•24 years ago
|
||
Attachment #68257 -
Attachment is obsolete: true
| Assignee | ||
Comment 23•24 years ago
|
||
Attachment #69526 -
Attachment is obsolete: true
Comment 24•24 years ago
|
||
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+
| Assignee | ||
Comment 25•24 years ago
|
||
checked in
| Assignee | ||
Comment 26•24 years ago
|
||
set status
| Assignee | ||
Comment 28•24 years ago
|
||
marking fixed
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Updated•24 years ago
|
QA Contact: teruko → bstell
| Assignee | ||
Comment 29•24 years ago
|
||
the code for the bug has been checked in so I'm closing out this "needs review"
bug
Status: RESOLVED → VERIFIED
URL: http://http://
You need to log in
before you can comment on or make changes to this bug.
Description
•