Closed
Bug 144665
Opened 22 years ago
Closed 22 years ago
common printing interface for Postscript and TrueType fonts
Categories
(Core :: Internationalization, enhancement)
Tracking
()
VERIFIED
FIXED
People
(Reporter: bstell, Assigned: zhayupeng)
References
Details
(Keywords: intl)
Attachments
(2 files, 5 obsolete files)
20.72 KB,
patch
|
zhayupeng
:
review+
zhayupeng
:
superreview+
|
Details | Diff | Splinter Review |
5.42 KB,
patch
|
Details | Diff | Splinter Review |
to facilitate printing using both Postscript fonts and TrueType fonts we need a
common (virtual) class interface so the font details are hidden from the
printing code.
per discuss with Brain:
This virtual class need following functions and data(Just for example)
inline int SupportsChar(PRUnichar aChar) { return mCCMap &&
CCMAP_HAS_CHAR(mCCMap, aChar); };
virtual gint GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
virtual gint DrawString(context, nscoord aX, nscoord aY, const PRUnichar*
aString, PRUint32 aLength) = 0;
#ifdef MOZ_MATHML
virtual nsresult
GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics) = 0;
#endif
data:
PRUint16* mCCMap;
And the name of this class should be nsFontPS
Depends on: 144664
No longer depends on: 144664
Summary: common printing interface Postscript and TrueType fonts → common printing interface for Postscript and TrueType fonts
This patch only add new class definition and implementation into
nsFontMetricsPS.cpp. It includes following change:
1) Add class nsFontPS which is the base class for this font interface.
2) Add class nsFontPSAFM which inherit from nsFontPS and implement some virtual
functions for nsFontPS
3) Add several inline setter function into nsFontMetricsPS class. This way, the
font interface class, like nsFontPSAFM can set data of nsFontMetricsPS when
realize font.
4) Add a simple inline getter in nsDeviceContextPS to get the mPSObj from it to
implement drawString font interface.
This patch does not change any logic of current code.
This patch only add new class definition and implementation into
nsFontMetricsPS.cpp. It includes following change:
1) Add class nsFontPS which is the base class for this font interface.
2) Add class nsFontPSAFM which inherit from nsFontPS and implement some virtual
functions for nsFontPS
3) Add several inline setter function into nsFontMetricsPS class. This way, the
font interface class, like nsFontPSAFM can set data of nsFontMetricsPS when
realize font.
4) Add a simple inline getter in nsDeviceContextPS to get the mPSObj from it to
implement drawString font interface.
This patch does not change any logic of current code.
Comment on attachment 100220 [details] [diff] [review]
Patch(only add new classes and functions)
oops, sorry for adding this patch twice because of a network problem.
Attachment #100220 -
Attachment is obsolete: true
Attachment #100221 -
Flags: needs-work+
Comment on attachment 100221 [details] [diff] [review]
Patch(only add new classes and functions)
Needs work to modify code in ps module to use font interface.
First working patch. Ready for r=/sr=...
Issues:
1) I'm not sure how to implement GetBoundingMetrics. Maybe do it later.
2) Need more testing I think.
Attachment #100221 -
Attachment is obsolete: true
This patch fix some problem per Brian's comments from email:
>1) When I printout the www.mozilla.org page with the patch I see overlapping
>text. I do not see any overlap without the patch.
It's caused by a typo in nsFontMetricsPS.h. I have fixed it in this patch
inline void SetSpaceWidth(nscoord aSpaceWidth) { mSpaceWidth = aSpaceWidth; };
vs
inline void SetSpaceWidth(nscoord aAveCharWidth) { mAveCharWidth =
aAveCharWidth; };
>2) Can we add a comment here saying "more font types to come..." or something
>like that?
>+nsFontPS::FindFont(const nsFont& aFont, nsIFontMetrics* aFontMetrics)
done
>3) Nit: I note that the order of the 2 nsRenderingContextPS::DrawString()
>routines was changed. I'm curious if there was some reason for this as the
diff >would be smaller if the functions were not reordered.
I have changed back to orignial order for these two function
Attachment #100399 -
Attachment is obsolete: true
Comment on attachment 100527 [details] [diff] [review]
Patch v2
>+ * In the furture, this function is responsible for font selection
Oops, here is a typeo again. "furture" should be "future" :-P
Reporter | ||
Comment 10•22 years ago
|
||
1) nit: can we change "height" to "size"?
+ nscoord height = NSToCoordRound(fontSize * dev2app);
+ aFontMetrics->SetHeight(height);
+ aFontMetrics->SetEmHeight(height);
+ aFontMetrics->SetMaxAdvance(height);
+ aFontMetrics->SetMaxHeight(height);
2) is this the points to twips constant
+ mAFMInfo->Init(mFont->size / 20);
3) how does the memory work here (where does the copy happen):
mFamilyName = (char*)mAFMInfo->mPSFontInfo->mFamilyName;
...
if (mFamilyName) {
delete mFamilyName;
Assignee | ||
Comment 11•22 years ago
|
||
>1) nit: can we change "height" to "size"?
done
>2) is this the points to twips constant
>+ mAFMInfo->Init(mFont->size / 20);
I think so.
>3) how does the memory work here (where does the copy happen):
> mFamilyName = (char*)mAFMInfo->mPSFontInfo->mFamilyName;
I'm now using nsAutoString for mFamilyName.
Attachment #100527 -
Attachment is obsolete: true
Reporter | ||
Comment 12•22 years ago
|
||
Attachment #100678 -
Flags: review+
Comment 13•22 years ago
|
||
Comment on attachment 100678 [details] [diff] [review]
Patch v3
>+ inline nsAutoString GetFamilyName() { return mFamilyName; };
You shouldn't return this by value. It's a string class that embeds a 128 byte
buffer. If you know that your nsFontPS object lives longer than the code that
uses the result of |GetFamilyName()| you can return a |const nsString&| to it.
>+ nsAutoString mFamilyName;
Also don't store it as a nsAutoString. For member values it's typically better
to use a nsString, which doesn't take up as much space.
With that fixed, sr=jag
Attachment #100678 -
Flags: superreview+
Assignee | ||
Comment 14•22 years ago
|
||
Using nsString instead of nsAutoString and return nsString& instead of
nsAutoString
Attachment #100678 -
Attachment is obsolete: true
Assignee | ||
Comment 15•22 years ago
|
||
Comment on attachment 100844 [details] [diff] [review]
Patch v4 with jag's comments
carry r=/sr=
Attachment #100844 -
Flags: superreview+
Attachment #100844 -
Flags: review+
Assignee | ||
Comment 16•22 years ago
|
||
checked in trunk
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 17•22 years ago
|
||
Move SetupFontAndColor from nsRenderContextPS into nsFontPS interface.
Move mFontIndex and mFamilyName from nsFontPS into nsFontPSAFM.
Comment 18•22 years ago
|
||
True type printing is working on 01-21 trunk build / Linux RH7.2, mark this as
verified.
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•