Hi, Can someone with Windows please test the attached patch from Khaled? Please don't push as is, this needs to be encapsulated in the new SAL_USE_NEW_LINEHEIGHT=1 environment, so both old and new handling need to be available. Eike -- PGP/OpenPGP/GnuPG encrypted mail preferred in all private communication. Key ID: 0x293C05FD - 997A 4C60 CE41 0149 0DB3 9E96 2F1A D073 293C 05FD
--- Begin Message ---
- Khaled Hosny <khaledhosny -AT- eglug.org>
- Fri, 2 Sep 2011 10:46:44 +0200
On Thu, Sep 01, 2011 at 10:31:14AM +0200, Khaled Hosny wrote:It shouldn't be hard to adapt GetFontMetric implementation in vcl/win/source/gdi/salgdi3.cxx to use the new function and have the same logic as the unix code.Here is a patch that, hopefully, does this, but I couldn't test it and it might not even compile. Regards, Khaled -- Khaled Hosny Egyptian ArabFrom 0743024ea07abd98b19eaf1ffecd6bb111681c58 Mon Sep 17 00:00:00 2001 From: Khaled Hosny <khaledhosny@eglug.org> Date: Fri, 2 Sep 2011 10:24:16 +0200 Subject: [PATCH] Use GetOutlineTextMetrics instead of GetTextMetrics Follow up of commit 3364fef GetOutlineTextMetrics returns an OUTLINETEXTMETRIC struct containing typographic ascent/descent among other font metrics. The CKJ external leading hack have been removed as well. --- vcl/win/source/gdi/salgdi3.cxx | 51 +++++++++++----------------------------- 1 files changed, 14 insertions(+), 37 deletions(-) diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index fdb9296..ad8dbe0 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -1764,24 +1764,24 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLe pMetric->maName = reinterpret_cast<const sal_Unicode*>(aFaceName); // get the font metric - TEXTMETRICA aWinMetric; - const bool bOK = GetTextMetricsA( mhDC, &aWinMetric ); + OUTLINETEXTMETRICA aWinMetric; + const bool bOK = GetOutlineTextMetricsA( mhDC, &aWinMetric ); // restore the HDC to the font in the base level SelectFont( mhDC, hOldFont ); if( !bOK ) return; // device independent font attributes - pMetric->meFamily = ImplFamilyToSal( aWinMetric.tmPitchAndFamily );; - pMetric->mbSymbolFlag = (aWinMetric.tmCharSet == SYMBOL_CHARSET); - pMetric->meWeight = ImplWeightToSal( aWinMetric.tmWeight ); - pMetric->mePitch = ImplMetricPitchToSal( aWinMetric.tmPitchAndFamily ); - pMetric->meItalic = aWinMetric.tmItalic ? ITALIC_NORMAL : ITALIC_NONE; + pMetric->meFamily = ImplFamilyToSal( aWinMetric.otmTextMetrics.tmPitchAndFamily );; + pMetric->mbSymbolFlag = (aWinMetric.otmTextMetrics.tmCharSet == SYMBOL_CHARSET); + pMetric->meWeight = ImplWeightToSal( aWinMetric.otmTextMetrics.tmWeight ); + pMetric->mePitch = ImplMetricPitchToSal( aWinMetric.otmTextMetrics.tmPitchAndFamily ); + pMetric->meItalic = aWinMetric.otmTextMetrics.tmItalic ? ITALIC_NORMAL : ITALIC_NONE; pMetric->mnSlant = 0; // device dependend font attributes - pMetric->mbDevice = (aWinMetric.tmPitchAndFamily & TMPF_DEVICE) != 0; - pMetric->mbScalableFont = (aWinMetric.tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE)) != 0; + pMetric->mbDevice = (aWinMetric.otmTextMetrics.tmPitchAndFamily & TMPF_DEVICE) != 0; + pMetric->mbScalableFont = (aWinMetric.otmTextMetrics.tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE)) != 0; if( pMetric->mbScalableFont ) { // check if there are kern pairs @@ -1798,34 +1798,11 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLe } // transformation dependend font metrics - pMetric->mnWidth = static_cast<int>( mfFontScale[nFallbackLevel] * aWinMetric.tmAveCharWidth ); - pMetric->mnIntLeading = static_cast<int>( mfFontScale[nFallbackLevel] * aWinMetric.tmInternalLeading ); - pMetric->mnExtLeading = static_cast<int>( mfFontScale[nFallbackLevel] * aWinMetric.tmExternalLeading ); - pMetric->mnAscent = static_cast<int>( mfFontScale[nFallbackLevel] * aWinMetric.tmAscent ); - pMetric->mnDescent = static_cast<int>( mfFontScale[nFallbackLevel] * aWinMetric.tmDescent ); - - // #107888# improved metric compatibility for Asian fonts... - // TODO: assess workaround below for CWS >= extleading - // TODO: evaluate use of aWinMetric.sTypo* members for CJK - if( mpWinFontData[nFallbackLevel] && mpWinFontData[nFallbackLevel]->SupportsCJK() ) - { - pMetric->mnIntLeading += pMetric->mnExtLeading; - - // #109280# The line height for Asian fonts is too small. - // Therefore we add half of the external leading to the - // ascent, the other half is added to the descent. - const long nHalfTmpExtLeading = pMetric->mnExtLeading / 2; - const long nOtherHalfTmpExtLeading = pMetric->mnExtLeading - nHalfTmpExtLeading; - - // #110641# external leading for Asian fonts. - // The factor 0.3 has been confirmed with experiments. - long nCJKExtLeading = static_cast<long>(0.30 * (pMetric->mnAscent + pMetric->mnDescent)); - nCJKExtLeading -= pMetric->mnExtLeading; - pMetric->mnExtLeading = (nCJKExtLeading > 0) ? nCJKExtLeading : 0; - - pMetric->mnAscent += nHalfTmpExtLeading; - pMetric->mnDescent += nOtherHalfTmpExtLeading; - } + pMetric->mnWidth = static_cast<int>( mfFontScale[nFallbackLevel] * aWinMetric.otmTextMetrics.tmAveCharWidth ); + pMetric->mnExtLeading = static_cast<int>( mfFontScale[nFallbackLevel] * aWinMetric.otmLineGap ); + pMetric->mnAscent = mfFontScale[nFallbackLevel] * aWinMetric.otmAscent; + pMetric->mnDescent = -mfFontScale[nFallbackLevel] * aWinMetric.otmDescent; + pMetric->mnIntLeading = pMetric->mnAscent + pMetric->mnDescent - ( mfFontScale[nFallbackLevel] * aWinMetric.otmEMSquare ); pMetric->mnMinKashida = GetMinKashidaWidth(); } -- 1.7.0.4_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
--- End Message ---
Attachment:
signature.asc
Description: Digital signature