Index: abi/src/af/gr/win/gr_Win32CharWidths.cpp =================================================================== RCS file: /cvsroot/abi/src/af/gr/win/gr_Win32CharWidths.cpp,v retrieving revision 1.4 diff -u -r1.4 gr_Win32CharWidths.cpp --- abi/src/af/gr/win/gr_Win32CharWidths.cpp 2000/11/08 14:09:31 1.4 +++ abi/src/af/gr/win/gr_Win32CharWidths.cpp 2001/01/04 01:04:19 @@ -56,6 +56,13 @@ UINT k; int w; + // Windows NT and Windows 95 support the Unicode Font file. + // All of the Unicode glyphs can be rendered if the glyph is found in + // the font file. However, Windows 95 does not support the Unicode + // characters other than the characters for which the particular codepage + // of the font file is defined. + // Reference Microsoft knowledge base: + // Q145754 - PRB ExtTextOutW or TextOutW Unicode Text Output Is Blank if (UT_IsWinNT()) { for (k=c0; k<=c1; k++) @@ -66,14 +73,35 @@ } else { - for (k=c0; k<=c1; k++) + HFONT hFont = (HFONT) GetCurrentObject(hdc, OBJ_FONT); + LOGFONT aLogFont; + int iRes = GetObject(hFont, sizeof(LOGFONT), &aLogFont); + UT_ASSERT(iRes); + + if(aLogFont.lfCharSet == SYMBOL_CHARSET) + { + // Symbol character handling + for (k=c0; k<=c1; k++) + { + SIZE Size; + char str[sizeof(UT_UCSChar)]; + int iConverted = WideCharToMultiByte(CP_ACP, NULL, + (unsigned short*) &k, 1, str, sizeof(str), NULL, NULL); + GetTextExtentPoint32A(hdc, str, iConverted, &Size); + setWidth(k,Size.cx); + } + } + else { - SIZE Size; - char str[sizeof(UT_UCSChar)]; - int iConverted = WideCharToMultiByte(CP_ACP, NULL, - (unsigned short*) &k, 1, str, sizeof(str), NULL, NULL); - GetTextExtentPoint32A(hdc, str, iConverted, &Size); - setWidth(k,Size.cx); + // Unicode font and default character sets + for (k=c0; k<=c1; k++) + { + SIZE Size; + wchar_t sz1[2]; + sz1[0] = k; + GetTextExtentPoint32W(hdc, sz1, 1, &Size); + setWidth(k,Size.cx); + } } } } Index: abi/src/af/gr/win/gr_Win32Graphics.cpp =================================================================== RCS file: /cvsroot/abi/src/af/gr/win/gr_Win32Graphics.cpp,v retrieving revision 1.51 diff -u -r1.51 gr_Win32Graphics.cpp --- abi/src/af/gr/win/gr_Win32Graphics.cpp 2000/12/27 17:36:18 1.51 +++ abi/src/af/gr/win/gr_Win32Graphics.cpp 2001/01/04 01:04:23 @@ -116,10 +116,6 @@ now, we're hard-coding a hack. */ - // TMN: 27 Dec 2000 - OEM_CHARSET is needed to display - // extended unicode chars. - lf.lfCharSet = OEM_CHARSET; - UT_sint32 iHeight = convertDimension(pszFontSize); lf.lfHeight = -(iHeight); @@ -163,6 +159,13 @@ strcpy(lf.lfFaceName, pszFontFamily); } + // Get character set value from the font itself + LOGFONT enumlf = { 0 }; + enumlf.lfCharSet = DEFAULT_CHARSET; + strcpy(enumlf.lfFaceName, lf.lfFaceName); + EnumFontFamiliesEx(GetDC(NULL), &enumlf, + (FONTENUMPROC)fontEnumProcedure, (LPARAM)&lf, 0); + lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; // Choose only True Type fonts. lf.lfQuality = PROOF_QUALITY; @@ -174,39 +177,47 @@ return new GR_Win32Font(hFont); } +int GR_Win32Graphics::fontEnumProcedure(const LOGFONT *pLogFont, const TEXTMETRIC *pTextMetric, DWORD Font_type, LPARAM lParam) +{ + LOGFONT *lf = (LOGFONT *) lParam; + lf->lfCharSet = pLogFont->lfCharSet; + return 0; +} + void GR_Win32Graphics::drawChar(UT_UCSChar Char, UT_sint32 xoff, UT_sint32 yoff) { - SelectObject(m_hdc, m_pFont->getHFONT()); + HFONT hFont = m_pFont->getHFONT(); + SelectObject(m_hdc, hFont); SetTextAlign(m_hdc, TA_LEFT | TA_TOP); SetBkMode(m_hdc, TRANSPARENT); // TODO: remember and reset? UT_UCSChar currentChar = remapGlyph(Char, UT_FALSE); - // TMN: 27 Dec 2000 - TODO: Understand why the code previously - // checked for NT. Why did it use ExtTextOutA if not NT? ExtTextOutW - // is implemented in Win9x+ also. - // If _you_ - the reader - knows this and also think it's safe to - // remove the code within the "#if 0" block, please do. -#if 0 + // Windows NT and Windows 95 support the Unicode Font file. + // All of the Unicode glyphs can be rendered if the glyph is found in + // the font file. However, Windows 95 does not support the Unicode + // characters other than the characters for which the particular codepage + // of the font file is defined. + // Reference Microsoft knowledge base: + // Q145754 - PRB ExtTextOutW or TextOutW Unicode Text Output Is Blank + LOGFONT lf; + int iRes = GetObject(hFont, sizeof(LOGFONT), &lf); + UT_ASSERT(iRes); - if (UT_IsWinNT()) - { - ExtTextOutW(m_hdc, xoff, yoff, 0, NULL, ¤tChar, 1, NULL); - } - else + if (UT_IsWinNT() == UT_FALSE && lf.lfCharSet == SYMBOL_CHARSET) { + // Symbol character handling for Win9x char str[sizeof(UT_UCSChar)]; int iConverted = WideCharToMultiByte(CP_ACP, NULL, ¤tChar, 1, str, sizeof(str), NULL, NULL); ExtTextOutA(m_hdc, xoff, yoff, 0, NULL, str, iConverted, NULL); } - -#else - - ExtTextOutW(m_hdc, xoff, yoff, 0, NULL, ¤tChar, 1, NULL); - -#endif + else + { + // Unicode font and default character set handling for WinNT and Win9x + ExtTextOutW(m_hdc, xoff, yoff, 0, NULL, ¤tChar, 1, NULL); + } } void GR_Win32Graphics::drawChars(const UT_UCSChar* pChars, @@ -215,7 +226,8 @@ { UT_ASSERT(pChars); - SelectObject(m_hdc, m_pFont->getHFONT()); + HFONT hFont = m_pFont->getHFONT(); + SelectObject(m_hdc, hFont); SetTextAlign(m_hdc, TA_LEFT | TA_TOP); SetBkMode(m_hdc, TRANSPARENT); // TODO: remember and reset? @@ -225,19 +237,20 @@ currentChars[i] = remapGlyph(pChars[iCharOffset + i], UT_FALSE); } - // TMN: 27 Dec 2000 - TODO: Understand why the code previously - // checked for NT. Why did it use ExtTextOutA if not NT? ExtTextOutW - // is implemented in Win9x+ also. - // If _you_ - the reader - knows this and also think it's safe to - // remove the code within the "#if 0" block, please do. -#if 0 + // Windows NT and Windows 95 support the Unicode Font file. + // All of the Unicode glyphs can be rendered if the glyph is found in + // the font file. However, Windows 95 does not support the Unicode + // characters other than the characters for which the particular codepage + // of the font file is defined. + // Reference Microsoft knowledge base: + // Q145754 - PRB ExtTextOutW or TextOutW Unicode Text Output Is Blank + LOGFONT lf; + int iRes = GetObject(hFont, sizeof(LOGFONT), &lf); + UT_ASSERT(iRes); - if (UT_IsWinNT()) + if (UT_IsWinNT() == UT_FALSE && lf.lfCharSet == SYMBOL_CHARSET) { - ExtTextOutW(m_hdc, xoff, yoff, 0, NULL, currentChars, iLength, NULL); - } - else - { + // Symbol character handling for Win9x char* str = new char[iLength * sizeof(UT_UCSChar)]; int iConverted = WideCharToMultiByte(CP_ACP, NULL, currentChars, iLength, @@ -245,12 +258,11 @@ ExtTextOutA(m_hdc, xoff, yoff, 0, NULL, str, iConverted, NULL); delete [] str; } - -#else - - ExtTextOutW(m_hdc, xoff, yoff, 0, NULL, currentChars, iLength, NULL); - -#endif + else + { + // Unicode font and default character set handling for WinNT and Win9x + ExtTextOutW(m_hdc, xoff, yoff, 0, NULL, currentChars, iLength, NULL); + } delete [] currentChars; } Index: abi/src/af/gr/win/gr_Win32Graphics.h =================================================================== RCS file: /cvsroot/abi/src/af/gr/win/gr_Win32Graphics.h,v retrieving revision 1.29 diff -u -r1.29 gr_Win32Graphics.h --- abi/src/af/gr/win/gr_Win32Graphics.h 2000/12/27 17:36:18 1.29 +++ abi/src/af/gr/win/gr_Win32Graphics.h 2001/01/04 01:04:24 @@ -80,6 +80,7 @@ const char* pszFontWeight, const char* pszFontStretch, const char* pszFontSize); + static int CALLBACK fontEnumProcedure(const LOGFONT *pLogFont, const TEXTMETRIC *pTextMetric, DWORD Font_type, LPARAM lParam); virtual UT_uint32 getFontAscent(); virtual UT_uint32 getFontDescent(); virtual void drawLine(UT_sint32, UT_sint32, UT_sint32, UT_sint32);