tdf#103588: Draw with the right font on Windows
Apparently without implementing InitFont(), we might end up drawing with the wrong font, thanks to the arcane ways GDI API. Change-Id: I224de138446d4a536e13992efa98b0f04609576a
This commit is contained in:
@@ -42,9 +42,12 @@ class CommonSalLayout : public GenericSalLayout
|
||||
hb_font_t* mpHbFont;
|
||||
const FontSelectPattern& mrFontSelData;
|
||||
css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
|
||||
#if defined(MACOSX) || defined(IOS)
|
||||
#ifdef _WIN32
|
||||
HDC mhDC;
|
||||
HFONT mhFont;
|
||||
#elif defined(MACOSX) || defined(IOS)
|
||||
const CoreTextStyle& mrCoreTextStyle;
|
||||
#elif !defined(_WIN32)
|
||||
#else
|
||||
FreetypeFont& mrFreetypeFont;
|
||||
#endif
|
||||
|
||||
@@ -57,6 +60,7 @@ class CommonSalLayout : public GenericSalLayout
|
||||
public:
|
||||
#if defined(_WIN32)
|
||||
explicit CommonSalLayout(HDC, WinFontInstance&, const WinFontFace&);
|
||||
void InitFont() const override { SelectObject(mhDC, mhFont); };
|
||||
const FontSelectPattern& getFontSelData() const { return mrFontSelData; };
|
||||
#elif defined(MACOSX) || defined(IOS)
|
||||
explicit CommonSalLayout(const CoreTextStyle&);
|
||||
|
@@ -172,12 +172,13 @@ void CommonSalLayout::ParseFeatures(const OUString& name)
|
||||
#if defined(_WIN32)
|
||||
CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& rWinFontInstance, const WinFontFace& rWinFontFace)
|
||||
: mrFontSelData(rWinFontInstance.maFontSelData)
|
||||
, mhDC(hDC)
|
||||
, mhFont(static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT)))
|
||||
{
|
||||
mpHbFont = rWinFontFace.GetHbFont();
|
||||
if (!mpHbFont)
|
||||
{
|
||||
HFONT hFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT));
|
||||
hb_face_t* pHbFace = hb_face_create_for_tables(getFontTable, hFont, nullptr);
|
||||
hb_face_t* pHbFace = hb_face_create_for_tables(getFontTable, mhFont, nullptr);
|
||||
|
||||
mpHbFont = createHbFont(pHbFace);
|
||||
rWinFontFace.SetHbFont(mpHbFont);
|
||||
|
Reference in New Issue
Block a user