Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


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
 Arab
From 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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.