bug 396315. get type1 fonts fonts mostly displaying correctly. (also fixes bug 410801. use postscript opentype fonts for fallback) r=vlad

git-svn-id: svn://10.0.0.236/trunk@247709 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pavlov%pavlov.net 2008-03-13 04:16:05 +00:00
parent 95b560c2bb
commit 3432f51ae9
3 changed files with 45 additions and 29 deletions

View File

@ -192,11 +192,8 @@ public:
PRPackedBool mUnicodeFont;
PRPackedBool mSymbolFont;
<<<<<<< gfxWindowsFonts.h
PRPackedBool mIsType1;
=======
PRPackedBool mIsBadUnderlineFont;
>>>>>>> 1.68
std::bitset<256> mCharset;
std::bitset<128> mUnicodeRanges;

View File

@ -912,9 +912,9 @@ public:
* S_OK - things succeeded
* GDI_ERROR - things failed to shape. Might want to try again after calling DisableShaping()
*/
HRESULT Shape() {
HRESULT rv;
HRESULT ShapeUniscribe() {
HRESULT rv;
HDC shapeDC = nsnull;
const PRUnichar *str = mAlternativeString ? mAlternativeString : mRangeString;
@ -960,20 +960,34 @@ public:
shapeDC = mDC;
continue;
}
#ifdef DEBUG_pavlov
if (rv == USP_E_SCRIPT_NOT_IN_FONT) {
ScriptGetCMap(mDC, mCurrentFont->ScriptCache(), str, mRangeString, 0, mGlyphs.Elements());
PRUnichar foo[LF_FACESIZE+1];
GetTextFaceW(mDC, LF_FACESIZE, foo);
printf("bah\n");
}
else if (FAILED(rv))
printf("%d\n", rv);
#endif
return rv;
}
}
HRESULT ShapeGDI() {
SelectFont();
mGlyphs.SetLength(mRangeLength);
mNumGlyphs = mRangeLength;
GetGlyphIndicesW(mDC, mRangeString, mRangeLength,
(WORD*) mGlyphs.Elements(),
GGI_MARK_NONEXISTING_GLYPHS);
for (PRUint32 i = 0; i < mItemLength; ++i)
mClusters[i] = i;
return S_OK;
}
HRESULT Shape() {
/* Type1 fonts don't like Uniscribe */
if (mCurrentFont->GetFontEntry()->mIsType1)
return ShapeGDI();
return ShapeUniscribe();
}
PRBool ShapingEnabled() {
return (mScriptItem->a.eScript != SCRIPT_UNDEFINED);
}
@ -1053,16 +1067,21 @@ public:
mAdvances.SetLength(mNumGlyphs);
PRBool allCJK = PR_TRUE;
for (PRUint32 i = 0; i < mRangeLength; i++) {
const PRUnichar ch = mRangeString[i];
if (ch == ' ' || FindCharUnicodeRange(ch) == kRangeSetCJK)
continue;
allCJK = PR_FALSE;
break;
/* Type1 fonts need to use GDI to be rendered so only do this
* check if we're not a type1 font */
if (!mCurrentFont->GetFontEntry()->mIsType1) {
for (PRUint32 i = 0; i < mRangeLength; i++) {
const PRUnichar ch = mRangeString[i];
if (ch == ' ' || FindCharUnicodeRange(ch) == kRangeSetCJK)
continue;
allCJK = PR_FALSE;
break;
}
}
if (allCJK)
if (allCJK || mCurrentFont->GetFontEntry()->mIsType1)
return PlaceGDI();
return PlaceUniscribe();

View File

@ -122,10 +122,13 @@ gfxWindowsPlatform::FontEnumProc(const ENUMLOGFONTEXW *lpelfe,
nsRefPtr<FontEntry> fe;
if (!thisp->mFonts.Get(name, &fe)) {
fe = new FontEntry(nsDependentString(logFont.lfFaceName), (PRUint16)fontType);
fe = new FontEntry(nsDependentString(logFont.lfFaceName));
thisp->mFonts.Put(name, fe);
}
if (metrics.ntmFlags & NTM_TYPE1)
fe->mIsType1 = PR_TRUE;
// mark the charset bit
fe->mCharset[metrics.tmCharSet] = 1;
@ -135,11 +138,6 @@ gfxWindowsPlatform::FontEnumProc(const ENUMLOGFONTEXW *lpelfe,
// store the default font weight
fe->mDefaultWeight = metrics.tmWeight;
if (metrics.ntmFlags & NTM_TYPE1) {
fe->mSymbolFont = PR_TRUE;
fe->mUnicodeFont = PR_FALSE;
}
fe->mFamily = logFont.lfPitchAndFamily & 0xF0;
fe->mPitch = logFont.lfPitchAndFamily & 0x0F;
@ -213,8 +211,10 @@ gfxWindowsPlatform::FontGetCMapDataProc(nsStringHashKey::KeyType aKey,
nsresult rv = ReadCMAP(hdc, aFontEntry);
if (NS_FAILED(rv)) {
if (aFontEntry->mIsType1)
aFontEntry->mSymbolFont = PR_TRUE;
aFontEntry->mUnicodeFont = PR_FALSE;
//printf("%s failed to get cmap\n", NS_ConvertUTF16toUTF8(aFontEntry->mName).get());
//printf("%d, %s failed to get cmap\n", aFontEntry->mIsType1, NS_ConvertUTF16toUTF8(aFontEntry->mName).get());
}
SelectObject(hdc, oldFont);