tdf#116498 Use win metrics for 'DIN Light' font
This adds a special treatment for fonts which rely on the win metrics for correct line spacing calculation. At the moment, only 'DIN Light' is known to need that treatment. Change-Id: Idd9fd6f63083ab7a706e0cbcd33a947d4949d4e9 Reviewed-on: https://gerrit.libreoffice.org/53962 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
This commit is contained in:
@@ -5295,6 +5295,18 @@
|
|||||||
</info>
|
</info>
|
||||||
<value>EmojiOne Color</value>
|
<value>EmojiOne Color</value>
|
||||||
</prop>
|
</prop>
|
||||||
|
<prop oor:name="FontsUseWinMetrics" oor:type="oor:string-list" oor:nillable="false">
|
||||||
|
<info>
|
||||||
|
<desc>
|
||||||
|
Fonts where the win metrics need to be considered in order to display the font correctly
|
||||||
|
Fonts are identified by their name and the font metrics (see fontmetric.cxx:ShouldUseWinMetrics).
|
||||||
|
</desc>
|
||||||
|
</info>
|
||||||
|
<value>
|
||||||
|
<!-- DIN Light (ttf version) has odd metrics. The otf version works fine. -->
|
||||||
|
<it>DIN Light,1509,-503,1509,-483,1997,483</it>
|
||||||
|
</value>
|
||||||
|
</prop>
|
||||||
<prop oor:name="PluginsEnabled" oor:type="xs:boolean" oor:nillable="false">
|
<prop oor:name="PluginsEnabled" oor:type="xs:boolean" oor:nillable="false">
|
||||||
<!-- OldPath: ? -->
|
<!-- OldPath: ? -->
|
||||||
<!-- OldLocation: soffice.ini -->
|
<!-- OldLocation: soffice.ini -->
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include <vcl/dllapi.h>
|
#include <vcl/dllapi.h>
|
||||||
#include <tools/ref.hxx>
|
#include <tools/ref.hxx>
|
||||||
#include "fontattributes.hxx"
|
#include "fontattributes.hxx"
|
||||||
|
#include "sft.hxx"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -96,6 +97,8 @@ public:
|
|||||||
int nUPEM);
|
int nUPEM);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool ShouldUseWinMetrics(vcl::TTGlobalFontInfo& rInfo);
|
||||||
|
|
||||||
// font instance attributes from the font request
|
// font instance attributes from the font request
|
||||||
long mnHeight; // Font size
|
long mnHeight; // Font size
|
||||||
long mnWidth; // Reference Width
|
long mnWidth; // Reference Width
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <i18nlangtag/mslangid.hxx>
|
#include <i18nlangtag/mslangid.hxx>
|
||||||
|
#include <officecfg/Office/Common.hxx>
|
||||||
#include <vcl/fontcharmap.hxx>
|
#include <vcl/fontcharmap.hxx>
|
||||||
#include <vcl/metric.hxx>
|
#include <vcl/metric.hxx>
|
||||||
|
|
||||||
@@ -28,6 +29,8 @@
|
|||||||
#include <PhysicalFontFace.hxx>
|
#include <PhysicalFontFace.hxx>
|
||||||
#include <sft.hxx>
|
#include <sft.hxx>
|
||||||
|
|
||||||
|
#include <com/sun/star/uno/Sequence.hxx>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@@ -398,6 +401,27 @@ void ImplFontMetricData::ImplInitFlags( const OutputDevice* pDev )
|
|||||||
SetFullstopCenteredFlag( bCentered );
|
SetFullstopCenteredFlag( bCentered );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImplFontMetricData::ShouldUseWinMetrics(vcl::TTGlobalFontInfo& rInfo)
|
||||||
|
{
|
||||||
|
OUString aFontIdentifier(
|
||||||
|
GetFamilyName() + ","
|
||||||
|
+ OUString::number(rInfo.ascender) + "," + OUString::number(rInfo.descender) + ","
|
||||||
|
+ OUString::number(rInfo.typoAscender) + "," + OUString::number(rInfo.typoDescender) + ","
|
||||||
|
+ OUString::number(rInfo.winAscent) + "," + OUString::number(rInfo.winDescent));
|
||||||
|
|
||||||
|
css::uno::Sequence<OUString> rWinMetricFontList(
|
||||||
|
officecfg::Office::Common::Misc::FontsUseWinMetrics::get());
|
||||||
|
for (int i = 0; i < rWinMetricFontList.getLength(); ++i)
|
||||||
|
{
|
||||||
|
if (aFontIdentifier == rWinMetricFontList[i])
|
||||||
|
{
|
||||||
|
SAL_INFO("vcl.gdi.fontmetric", "Using win metrics for: " << aFontIdentifier);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate line spacing:
|
* Calculate line spacing:
|
||||||
*
|
*
|
||||||
@@ -440,7 +464,7 @@ void ImplFontMetricData::ImplCalcLineSpacing(const std::vector<uint8_t>& rHheaDa
|
|||||||
if (rInfo.winAscent || rInfo.winDescent ||
|
if (rInfo.winAscent || rInfo.winDescent ||
|
||||||
rInfo.typoAscender || rInfo.typoDescender)
|
rInfo.typoAscender || rInfo.typoDescender)
|
||||||
{
|
{
|
||||||
if (fAscent == 0 && fDescent == 0)
|
if (ShouldUseWinMetrics(rInfo) || (fAscent == 0.0 && fDescent == 0.0))
|
||||||
{
|
{
|
||||||
fAscent = rInfo.winAscent * fScale;
|
fAscent = rInfo.winAscent * fScale;
|
||||||
fDescent = rInfo.winDescent * fScale;
|
fDescent = rInfo.winDescent * fScale;
|
||||||
|
Reference in New Issue
Block a user