mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 396315. get type1 fonts fonts mostly displaying correctly. (also fixes bug 410801. use postscript opentype fonts for fallback) r=vlad
This commit is contained in:
parent
f6f259ceaa
commit
7911a69906
@ -62,16 +62,16 @@ class FontEntry
|
||||
public:
|
||||
THEBES_INLINE_DECL_REFCOUNTING(FontEntry)
|
||||
|
||||
FontEntry(const nsAString& aName, PRUint16 aFontType) :
|
||||
mName(aName), mFontType(aFontType), mDefaultWeight(0),
|
||||
mUnicodeFont(PR_FALSE), mSymbolFont(PR_FALSE), mIsBadUnderlineFont(PR_FALSE),
|
||||
mCharset(0), mUnicodeRanges(0)
|
||||
FontEntry(const nsAString& aName) :
|
||||
mName(aName), mDefaultWeight(0),
|
||||
mUnicodeFont(PR_FALSE), mSymbolFont(PR_FALSE), mIsType1(PR_FALSE),
|
||||
mIsBadUnderlineFont(PR_FALSE), mCharset(0), mUnicodeRanges(0)
|
||||
{
|
||||
}
|
||||
|
||||
PRBool IsCrappyFont() const {
|
||||
/* return if it is a bitmap, old school font or not a unicode font */
|
||||
return (!mUnicodeFont || mSymbolFont || mFontType != TRUETYPE_FONTTYPE);
|
||||
/* return if it is a bitmap not a unicode font */
|
||||
return (!mUnicodeFont || mSymbolFont);
|
||||
}
|
||||
|
||||
PRBool MatchesGenericFamily(const nsACString& aGeneric) const {
|
||||
@ -185,14 +185,18 @@ public:
|
||||
// The family name of the font
|
||||
nsString mName;
|
||||
|
||||
PRUint16 mFontType;
|
||||
PRUint16 mDefaultWeight;
|
||||
|
||||
PRUint8 mFamily;
|
||||
PRUint8 mPitch;
|
||||
|
||||
PRPackedBool mUnicodeFont;
|
||||
PRPackedBool mSymbolFont;
|
||||
<<<<<<< gfxWindowsFonts.h
|
||||
PRPackedBool mIsType1;
|
||||
=======
|
||||
PRPackedBool mIsBadUnderlineFont;
|
||||
>>>>>>> 1.68
|
||||
|
||||
std::bitset<256> mCharset;
|
||||
std::bitset<128> mUnicodeRanges;
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user