[Libreoffice-commits] core.git: vcl/inc vcl/source vcl/win
Khaled Hosny
khaledhosny at eglug.org
Sat Oct 22 11:16:38 UTC 2016
vcl/inc/CommonSalLayout.hxx | 6 ---
vcl/inc/win/salgdi.h | 1
vcl/source/gdi/CommonSalLayout.cxx | 65 +++++++++----------------------------
vcl/win/gdi/salfont.cxx | 18 ----------
vcl/win/gdi/winlayout.cxx | 2 -
5 files changed, 19 insertions(+), 73 deletions(-)
New commits:
commit 2148c853b0d0deea92b97a810950f4d9f0cbb152
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Fri Oct 21 21:00:21 2016 -0700
Simplify CommonSalLayout constructor on Windows
We can use GDI to load the font tables after all, no need for all the
complications to use DirectWrite to load them. Should also make it work on
Windows XP (untested).
Change-Id: Id49fc524e6da983d76669a078f8b7d624f955703
Reviewed-on: https://gerrit.libreoffice.org/30156
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>
diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index 76eb3eb..0dd44b2 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -43,9 +43,6 @@ class CommonSalLayout : public GenericSalLayout
const FontSelectPattern& mrFontSelData;
css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
#ifdef _WIN32
- HDC mhDC;
- HFONT mhFont;
- D2DWriteTextOutRenderer* mpD2DRenderer;
#elif defined(MACOSX) || defined(IOS)
const CoreTextStyle& mrCoreTextStyle;
#else
@@ -58,8 +55,7 @@ class CommonSalLayout : public GenericSalLayout
public:
#if defined(_WIN32)
- explicit CommonSalLayout(WinSalGraphics*, WinFontInstance&, const WinFontFace&);
- void InitFont() const override;
+ explicit CommonSalLayout(HDC, WinFontInstance&, const WinFontFace&);
#elif defined(MACOSX) || defined(IOS)
explicit CommonSalLayout(const CoreTextStyle&);
const CoreTextStyle& getFontData() const { return mrCoreTextStyle; };
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index d694cf6..359c566 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -360,7 +360,6 @@ private:
void DrawTextLayout(const CommonSalLayout&, HDC);
public:
- static sal_uLong GetTable( const char pTagName[5], const unsigned char*&, void*&, IDWriteFontFace*& );
// public SalGraphics methods, the interface to the independent vcl part
// get device resolution
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 96762f1..0fba16b 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -27,20 +27,6 @@
#include <salgdi.hxx>
#include <unicode/uchar.h>
-#if defined(_WIN32)
-struct WinSalGraphicsWithIDFace
-{
- WinSalGraphics* mpWSL;
- IDWriteFontFace* mpIDFace;
- void* mpTableContext;
-
- WinSalGraphicsWithIDFace( WinSalGraphics* pWSL, IDWriteFontFace* pIDFace )
- : mpWSL( pWSL ),
- mpIDFace( pIDFace ),
- mpTableContext( nullptr )
- {}
-};
-#endif
static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pUserData)
{
@@ -53,9 +39,17 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pU
sal_uLong nLength = 0;
#if defined(_WIN32)
- const unsigned char* pBuffer = nullptr;
- WinSalGraphicsWithIDFace* pWSLWithIDFace = static_cast<WinSalGraphicsWithIDFace*>(pUserData);
- nLength = WinSalGraphics::GetTable(pTagName, pBuffer, pWSLWithIDFace->mpTableContext, pWSLWithIDFace->mpIDFace);
+ unsigned char* pBuffer = nullptr;
+ HFONT hFont = static_cast<HFONT>(pUserData);
+ HDC hDC = GetDC(nullptr);
+ SelectObject(hDC, hFont);
+ nLength = ::GetFontData(hDC, OSL_NETDWORD(nTableTag), 0, nullptr, 0);
+ if (nLength > 0 && nLength != GDI_ERROR)
+ {
+ pBuffer = new unsigned char[nLength];
+ ::GetFontData(hDC, OSL_NETDWORD(nTableTag), 0, pBuffer, nLength);
+ }
+ ReleaseDC(nullptr, hDC);
#elif defined(MACOSX) || defined(IOS)
unsigned char* pBuffer = nullptr;
CoreTextFontFace* pFont = static_cast<CoreTextFontFace*>(pUserData);
@@ -63,8 +57,8 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pU
if (nLength > 0)
{
pBuffer = new unsigned char[nLength];
+ pFont->GetFontTable(pTagName, pBuffer);
}
- pFont->GetFontTable(pTagName, pBuffer);
#else
const unsigned char* pBuffer = nullptr;
ServerFont* pFont = static_cast<ServerFont*>(pUserData);
@@ -73,15 +67,7 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pU
hb_blob_t* pBlob = nullptr;
if (pBuffer != nullptr)
-#if defined(_WIN32)
- pBlob = hb_blob_create(reinterpret_cast<const char*>(pBuffer), nLength, HB_MEMORY_MODE_READONLY, pWSLWithIDFace,
- [](void* userData)
- {
- WinSalGraphicsWithIDFace* pUData = static_cast<WinSalGraphicsWithIDFace*>(userData);
- pUData->mpIDFace->ReleaseFontTable(pUData->mpTableContext);
- }
- );
-#elif defined(MACOSX) || defined(IOS)
+#if defined(_WIN32) || defined(MACOSX) || defined(IOS)
pBlob = hb_blob_create(reinterpret_cast<const char*>(pBuffer), nLength, HB_MEMORY_MODE_READONLY,
pBuffer, [](void* data){ delete[] static_cast<unsigned char*>(data); });
#else
@@ -171,26 +157,14 @@ void CommonSalLayout::ParseFeatures(const OUString& name)
}
#if defined(_WIN32)
-CommonSalLayout::CommonSalLayout(WinSalGraphics* WSL, WinFontInstance& rWinFontInstance, const WinFontFace& rWinFontFace)
-: mrFontSelData(rWinFontInstance.maFontSelData),
- mhDC(WSL->getHDC()),
- mhFont(static_cast<HFONT>(GetCurrentObject(WSL->getHDC(), OBJ_FONT))),
- mpD2DRenderer(nullptr)
+CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& rWinFontInstance, const WinFontFace& rWinFontFace)
+: mrFontSelData(rWinFontInstance.maFontSelData)
{
mpHbFont = rWinFontFace.GetHbFont();
if (!mpHbFont)
{
- mpD2DRenderer = dynamic_cast<D2DWriteTextOutRenderer*>(&TextOutRenderer::get());
- WinSalGraphicsWithIDFace* pWSLWithIDFace = new WinSalGraphicsWithIDFace(WSL, mpD2DRenderer->GetDWriteFontFace(mhDC));
- hb_face_t* pHbFace= hb_face_create_for_tables( getFontTable, pWSLWithIDFace,
- [](void* pUserData)
- {
- WinSalGraphicsWithIDFace* pUData = static_cast<WinSalGraphicsWithIDFace*>( pUserData );
- if(pUData->mpIDFace)
- pUData->mpIDFace->Release();
- delete pUData;
- }
- );
+ HFONT hFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT));
+ hb_face_t* pHbFace = hb_face_create_for_tables(getFontTable, hFont, nullptr);
mpHbFont = createHbFont(pHbFace);
rWinFontFace.SetHbFont(mpHbFont);
@@ -202,11 +176,6 @@ CommonSalLayout::CommonSalLayout(WinSalGraphics* WSL, WinFontInstance& rWinFontI
ParseFeatures(mrFontSelData.maTargetName);
}
-void CommonSalLayout::InitFont() const
-{
- SelectObject(mhDC, mhFont);
-}
-
#elif defined(MACOSX) || defined(IOS)
CommonSalLayout::CommonSalLayout(const CoreTextStyle& rCoreTextStyle)
: mrFontSelData(rCoreTextStyle.maFontSelData),
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 44580ff..956459b 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1062,24 +1062,6 @@ void WinFontFace::ReadCmapTable( HDC hDC ) const
}
}
-sal_uLong WinSalGraphics::GetTable( const char pTagName[5], const unsigned char*& pResBuffer, void*& pTableContext, IDWriteFontFace*& pIDFace )
-{
- if( !pIDFace )
- return 0;
- const void* pResBuf;
- UINT32 nSize;
- BOOL bExists;
- HRESULT hr = S_OK;
- const DWORD nTableTag = DWRITE_MAKE_OPENTYPE_TAG( pTagName[0], pTagName[1], pTagName[2], pTagName[3] );
- hr = pIDFace->TryGetFontTable( nTableTag, &pResBuf, &nSize, &pTableContext, &bExists );
- if( SUCCEEDED( hr ) && ( bExists ) )
- {
- pResBuffer = static_cast<const unsigned char*>(pResBuf);
- return static_cast<sal_uLong>(nSize);
- }
- return 0;
-}
-
void WinFontFace::GetFontCapabilities( HDC hDC ) const
{
// read this only once per font
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 476248e..d82f86d 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -3828,7 +3828,7 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
if (SalLayout::UseCommonLayout())
{
- return new CommonSalLayout(this, rFontInstance, rFontFace);
+ return new CommonSalLayout(getHDC(), rFontInstance, rFontFace);
}
else
{
More information about the Libreoffice-commits
mailing list