diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2017-01-02 01:22:32 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2017-01-08 02:48:19 +0000 |
commit | d1bad9c12d61c9f662abe6439b87a057bb54c8ca (patch) | |
tree | 52260e4651283f5a7d58fd280ccb4fee170f7d1a /vcl/win/gdi | |
parent | 9aea56370ae78a43c3543159571ea0454c1619eb (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/win/gdi')
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 12 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 34 |
2 files changed, 10 insertions, 36 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index b8da03d9f0bf..9860d5f1392c 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 04724d89ad46..6436c618cda9 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 |