vcl: take into account the font width is the average font width

I'm changing the Font class function names:

- SetSize       -> SetFontSize
- GetSize       -> GetFontSize
- SetHeight     -> SetFontHeight
- GetHeight     -> GetFontHeight
- SetWidth      -> SetAverageFontWidth
- GetWidth      -> GetAverageFontWidth

That's because it really makes no sense to say that there is a
single constant font width because obviously proportional fonts
don't have one - the best we can do is an average font width,
which is what folks like Microsoft sort of do already. On a fixed
font, the average is still accurate, for obvious reasons :-)

I'm also not a fan of GetSize/SetSize as I find it a might too
generic.

Change-Id: Ib80a604ba62d6883fd6cbc7994da763976be5c70
Reviewed-on: https://gerrit.libreoffice.org/22069
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
This commit is contained in:
Chris Sherlock
2016-02-03 10:13:00 +11:00
parent 91a7580e03
commit 697d445ed0
172 changed files with 541 additions and 545 deletions

View File

@@ -808,7 +808,7 @@ namespace cppcanvas
// TODO(Q3): This code smells of programming by
// coincidence (the next two if statements)
::Size rFontSizeLog( rFont.GetSize() );
::Size rFontSizeLog( rFont.GetFontSize() );
if (rFontSizeLog.Height() == 0)
{
@@ -823,8 +823,8 @@ namespace cppcanvas
if( nFontWidthLog != 0 )
{
vcl::Font aTestFont = rFont;
aTestFont.SetWidth( 0 );
sal_Int32 nNormalWidth = rParms.mrVDev.GetFontMetric( aTestFont ).GetWidth();
aTestFont.SetAverageFontWidth( 0 );
sal_Int32 nNormalWidth = rParms.mrVDev.GetFontMetric( aTestFont ).GetAverageFontWidth();
if( nNormalWidth != nFontWidthLog )
if( nNormalWidth )
aFontMatrix.m00 = (double)nFontWidthLog / nNormalWidth;
@@ -888,7 +888,7 @@ namespace cppcanvas
{
// calculate shadow offset (similar to outdev3.cxx)
// TODO(F3): better match with outdev3.cxx
sal_Int32 nShadowOffset = static_cast<sal_Int32>(1.5 + ((rParms.mrVDev.GetFont().GetHeight()-24.0)/24.0));
sal_Int32 nShadowOffset = static_cast<sal_Int32>(1.5 + ((rParms.mrVDev.GetFont().GetFontHeight()-24.0)/24.0));
if( nShadowOffset < 1 )
nShadowOffset = 1;