vcl/inc/win/salgdi.h | 1 - vcl/inc/win/winlayout.hxx | 16 ---------------- vcl/win/gdi/salfont.cxx | 12 ++++++++++-- vcl/win/gdi/winlayout.cxx | 34 ---------------------------------- 4 files changed, 10 insertions(+), 53 deletions(-)
New commits: commit d1bad9c12d61c9f662abe6439b87a057bb54c8ca Author: Khaled Hosny <khaledho...@eglug.org> Date: Mon Jan 2 01:22:32 2017 +0200 Simplify setting Kashida width on Windows This should also make sure we are getting it from the current font, which the old, convoluted way does not seem to guarantee. Change-Id: If0a4cf18e472b1489115eeb7b1b2bdbb5f13abb0 Reviewed-on: https://gerrit.libreoffice.org/32595 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Khaled Hosny <khaledho...@eglug.org> diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index d974e76..f6faf4a 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -376,7 +376,6 @@ public: bool bVertical, std::vector< sal_Int32 >& rWidths, Ucs2UIntMap& rUnicodeEnc ) override; - int GetMinKashidaWidth(); virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) override; virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override; diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index d339df3..ecd25746 100644 --- a/vcl/inc/win/winlayout.hxx +++ b/vcl/inc/win/winlayout.hxx @@ -157,18 +157,6 @@ public: private: // TODO: also add HFONT??? Watch out for issues with too many active fonts... -public: - SCRIPT_CACHE& GetScriptCache() const - { return maScriptCache; } -private: - mutable SCRIPT_CACHE maScriptCache; - -public: - bool InitKashidaHandling( HDC ); - int GetMinKashidaWidth() const { return mnMinKashidaWidth; } - int GetMinKashidaGlyph() const { return mnMinKashidaGlyph; } - -private: GlyphCache maGlyphCache; public: bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& rGraphics); @@ -177,10 +165,6 @@ public: { return maGlyphCache; } - -private: - mutable int mnMinKashidaWidth; - mutable int mnMinKashidaGlyph; }; class TextOutRenderer diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index b8da03d..9860d5f 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -980,6 +980,16 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa const RawFontData aHheaRawData(getHDC(), nHheaTag); const RawFontData aOS2RawData(getHDC(), nOS2Tag); + WCHAR nKashidaCh = 0x0640; + WORD nKashidaGid; + DWORD ret = GetGlyphIndicesW(getHDC(), &nKashidaCh, 1, &nKashidaGid, GGI_MARK_NONEXISTING_GLYPHS); + if (ret != GDI_ERROR && nKashidaGid != 0xFFFF) + { + int nKashidaWidth = 0; + if (GetCharWidthI(getHDC(), nKashidaGid, 1, nullptr, &nKashidaWidth)) + rxFontMetric->SetMinKashida(nKashidaWidth); + } + // get the font metric OUTLINETEXTMETRICW aOutlineMetric; const bool bOK = GetOutlineTextMetricsW(getHDC(), sizeof(OUTLINETEXTMETRICW), &aOutlineMetric); @@ -1004,8 +1014,6 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa const std::vector<uint8_t> rHhea(aHheaRawData.get(), aHheaRawData.get() + aHheaRawData.size()); const std::vector<uint8_t> rOS2(aOS2RawData.get(), aOS2RawData.get() + aOS2RawData.size()); rxFontMetric->ImplCalcLineSpacing(rHhea, rOS2, aOutlineMetric.otmEMSquare); - - rxFontMetric->SetMinKashida( GetMinKashidaWidth() ); } const FontCharMapRef WinSalGraphics::GetFontCharMap() const diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 04724d8..6436c61 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -596,14 +596,6 @@ SalLayout* WinSalGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbac return new CommonSalLayout(getHDC(), *mpWinFontEntry[nFallbackLevel], *mpWinFontData[nFallbackLevel]); } -int WinSalGraphics::GetMinKashidaWidth() -{ - if( !mpWinFontEntry[0] ) - return 0; - mpWinFontEntry[0]->InitKashidaHandling( getHDC() ); - return mpWinFontEntry[0]->GetMinKashidaWidth(); -} - LogicalFontInstance * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel) { return mpWinFontEntry[nFallbackLevel]; @@ -611,37 +603,11 @@ LogicalFontInstance * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel) WinFontInstance::WinFontInstance( FontSelectPattern& rFSD ) : LogicalFontInstance( rFSD ) -, mnMinKashidaWidth( -1 ) -, mnMinKashidaGlyph( -1 ) { - maScriptCache = nullptr; } WinFontInstance::~WinFontInstance() { - if( maScriptCache != nullptr ) - ScriptFreeCache( &maScriptCache ); -} - -bool WinFontInstance::InitKashidaHandling( HDC hDC ) -{ - if( mnMinKashidaWidth >= 0 ) // already cached? - return mnMinKashidaWidth; - - // initialize the kashida width - mnMinKashidaWidth = 0; - mnMinKashidaGlyph = 0; - - SCRIPT_FONTPROPERTIES aFontProperties; - aFontProperties.cBytes = sizeof (aFontProperties); - SCRIPT_CACHE& rScriptCache = GetScriptCache(); - HRESULT nRC = ScriptGetFontProperties( hDC, &rScriptCache, &aFontProperties ); - if( nRC != 0 ) - return false; - mnMinKashidaWidth = aFontProperties.iKashidaWidth; - mnMinKashidaGlyph = aFontProperties.wgKashida; - - return true; } PhysicalFontFace* WinFontFace::Clone() const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits