summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2016-02-03 10:13:00 +1100
committerChris Sherlock <chris.sherlock79@gmail.com>2016-02-04 03:17:26 +0000
commit697d445ed0c7b60e463243db89af32e2145b475b (patch)
tree5a74d57cdc97f82bc78a686dee345a229a082a72 /canvas
parent91a7580e03d5b47c6e2513afce85ddee45e730b6 (diff)
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>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/cairo/cairo_canvasfont.cxx4
-rw-r--r--canvas/source/cairo/cairo_canvashelper_text.cxx8
-rw-r--r--canvas/source/cairo/cairo_textlayout.cxx8
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.cxx8
-rw-r--r--canvas/source/opengl/ogl_canvashelper.cxx4
-rw-r--r--canvas/source/vcl/canvasfont.cxx4
-rw-r--r--canvas/source/vcl/impltools.cxx8
-rw-r--r--canvas/source/vcl/spritecanvashelper.cxx2
-rw-r--r--canvas/source/vcl/spritehelper.cxx2
9 files changed, 24 insertions, 24 deletions
diff --git a/canvas/source/cairo/cairo_canvasfont.cxx b/canvas/source/cairo/cairo_canvasfont.cxx
index 505ebd2acf01..8aca75baa26a 100644
--- a/canvas/source/cairo/cairo_canvasfont.cxx
+++ b/canvas/source/cairo/cairo_canvasfont.cxx
@@ -68,7 +68,7 @@ namespace cairocanvas
const bool bOldMapState( pOutDev->IsMapModeEnabled() );
pOutDev->EnableMapMode(false);
- const Size aSize = pOutDev->GetFontMetric( *maFont ).GetSize();
+ const Size aSize = pOutDev->GetFontMetric( *maFont ).GetFontSize();
const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 );
double fStretch = (rFontMatrix.m00 + rFontMatrix.m01);
@@ -78,7 +78,7 @@ namespace cairocanvas
const long nNewWidth = ::basegfx::fround( aSize.Width() * fStretch );
- maFont->SetWidth( nNewWidth );
+ maFont->SetAverageFontWidth( nNewWidth );
pOutDev->EnableMapMode(bOldMapState);
}
diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx b/canvas/source/cairo/cairo_canvashelper_text.cxx
index f1c829da3126..03246f7b37a7 100644
--- a/canvas/source/cairo/cairo_canvashelper_text.cxx
+++ b/canvas/source/cairo/cairo_canvashelper_text.cxx
@@ -81,7 +81,7 @@ namespace cairocanvas
if( !::rtl::math::approxEqual(aScale.getX(), aScale.getY()) )
{
// retrieve true font width
- const sal_Int32 nFontWidth( rOutDev.GetFontMetric( io_rVCLFont ).GetWidth() );
+ const sal_Int32 nFontWidth( rOutDev.GetFontMetric( io_rVCLFont ).GetAverageFontWidth() );
const sal_Int32 nScaledFontWidth( ::basegfx::fround(nFontWidth * aScale.getX()) );
@@ -92,13 +92,13 @@ namespace cairocanvas
return false;
}
- io_rVCLFont.SetWidth( nScaledFontWidth );
+ io_rVCLFont.SetAverageFontWidth( nScaledFontWidth );
}
if( !::rtl::math::approxEqual(aScale.getY(), 1.0) )
{
- const sal_Int32 nFontHeight( io_rVCLFont.GetHeight() );
- io_rVCLFont.SetHeight( ::basegfx::fround(nFontHeight * aScale.getY()) );
+ const sal_Int32 nFontHeight( io_rVCLFont.GetFontHeight() );
+ io_rVCLFont.SetFontHeight( ::basegfx::fround(nFontHeight * aScale.getY()) );
}
io_rVCLFont.SetOrientation( static_cast< short >( ::basegfx::fround(-fmod(nRotate, 2*M_PI)*(1800.0/M_PI)) ) );
diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index 1e076b3f2f4d..8bb4d46cd074 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -430,8 +430,8 @@ namespace cairocanvas
continue;
vcl::Font aFont = rOutDev.GetFont();
- long nWidth = aFont.GetWidth();
- long nHeight = aFont.GetHeight();
+ long nWidth = aFont.GetAverageFontWidth();
+ long nHeight = aFont.GetFontHeight();
if (nWidth == 0)
nWidth = nHeight;
if (nWidth == 0 || nHeight == 0)
@@ -487,7 +487,7 @@ namespace cairocanvas
SAL_INFO(
"canvas.cairo",
- "Size:(" << aFont.GetWidth() << "," << aFont.GetHeight()
+ "Size:(" << aFont.GetAverageFontWidth() << "," << aFont.GetFontHeight()
<< "), Pos (" << rOutpos.X() << "," << rOutpos.Y()
<< "), G("
<< (cairo_glyphs.size() > 0 ? cairo_glyphs[0].index : -1)
@@ -507,7 +507,7 @@ namespace cairocanvas
//faux bold
if (rSysFontData.bFakeBold)
{
- double bold_dx = 0.5 * sqrt( 0.7 * aFont.GetHeight() );
+ double bold_dx = 0.5 * sqrt( 0.7 * aFont.GetFontHeight() );
int total_steps = 1 * ((int) (bold_dx + 0.5));
// loop to draw the text for every half pixel of displacement
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx
index cd5f5e903668..8de5f73afeee 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.cxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx
@@ -130,7 +130,7 @@ namespace dxcanvas
// adjust to stretched font
if(!::rtl::math::approxEqual(rFontMatrix.m00, rFontMatrix.m11))
{
- const Size aSize = xVirtualDevice->GetFontMetric( aFont ).GetSize();
+ const Size aSize = xVirtualDevice->GetFontMetric( aFont ).GetFontSize();
const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 );
double fStretch = (rFontMatrix.m00 + rFontMatrix.m01);
@@ -139,7 +139,7 @@ namespace dxcanvas
const sal_Int32 nNewWidth = ::basegfx::fround( aSize.Width() * fStretch );
- aFont.SetWidth( nNewWidth );
+ aFont.SetAverageFontWidth( nNewWidth );
}
// set font
@@ -259,7 +259,7 @@ namespace dxcanvas
// adjust to stretched font
if(!::rtl::math::approxEqual(rFontMatrix.m00, rFontMatrix.m11))
{
- const Size aSize = xVirtualDevice->GetFontMetric( aFont ).GetSize();
+ const Size aSize = xVirtualDevice->GetFontMetric( aFont ).GetFontSize();
const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 );
double fStretch = (rFontMatrix.m00 + rFontMatrix.m01);
@@ -268,7 +268,7 @@ namespace dxcanvas
const sal_Int32 nNewWidth = ::basegfx::fround( aSize.Width() * fStretch );
- aFont.SetWidth( nNewWidth );
+ aFont.SetAverageFontWidth( nNewWidth );
}
// set font
diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx
index b14cc87e5f8a..51a7dd9c9f60 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -738,7 +738,7 @@ namespace oglcanvas
// adjust to stretched font
if(!::rtl::math::approxEqual(rFontMatrix.m00, rFontMatrix.m11))
{
- const Size aSize = pVDev->GetFontMetric( aFont ).GetSize();
+ const Size aSize = pVDev->GetFontMetric( aFont ).GetFontSize();
const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 );
double fStretch = (rFontMatrix.m00 + rFontMatrix.m01);
@@ -747,7 +747,7 @@ namespace oglcanvas
const sal_Int32 nNewWidth = ::basegfx::fround( aSize.Width() * fStretch );
- aFont.SetWidth( nNewWidth );
+ aFont.SetAverageFontWidth( nNewWidth );
}
// set font
diff --git a/canvas/source/vcl/canvasfont.cxx b/canvas/source/vcl/canvasfont.cxx
index f65fdf2273ee..cd78c2feda9a 100644
--- a/canvas/source/vcl/canvasfont.cxx
+++ b/canvas/source/vcl/canvasfont.cxx
@@ -68,7 +68,7 @@ namespace vclcanvas
const bool bOldMapState( rOutDev.IsMapModeEnabled() );
rOutDev.EnableMapMode(false);
- const Size aSize = rOutDev.GetFontMetric( *maFont ).GetSize();
+ const Size aSize = rOutDev.GetFontMetric( *maFont ).GetFontSize();
const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 );
double fStretch = (rFontMatrix.m00 + rFontMatrix.m01);
@@ -78,7 +78,7 @@ namespace vclcanvas
const long nNewWidth = ::basegfx::fround( aSize.Width() * fStretch );
- maFont->SetWidth( nNewWidth );
+ maFont->SetAverageFontWidth( nNewWidth );
rOutDev.EnableMapMode(bOldMapState);
}
diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx
index be277286fafc..49afca1d78dd 100644
--- a/canvas/source/vcl/impltools.cxx
+++ b/canvas/source/vcl/impltools.cxx
@@ -117,7 +117,7 @@ namespace vclcanvas
if( !::rtl::math::approxEqual(aScale.getX(), aScale.getY()) )
{
// retrieve true font width
- const sal_Int32 nFontWidth( rOutDev.GetFontMetric( io_rVCLFont ).GetWidth() );
+ const sal_Int32 nFontWidth( rOutDev.GetFontMetric( io_rVCLFont ).GetAverageFontWidth() );
const sal_Int32 nScaledFontWidth( ::basegfx::fround(nFontWidth * aScale.getX()) );
@@ -128,13 +128,13 @@ namespace vclcanvas
return false;
}
- io_rVCLFont.SetWidth( nScaledFontWidth );
+ io_rVCLFont.SetAverageFontWidth( nScaledFontWidth );
}
if( !::rtl::math::approxEqual(aScale.getY(), 1.0) )
{
- const sal_Int32 nFontHeight( io_rVCLFont.GetHeight() );
- io_rVCLFont.SetHeight( ::basegfx::fround(nFontHeight * aScale.getY()) );
+ const sal_Int32 nFontHeight( io_rVCLFont.GetFontHeight() );
+ io_rVCLFont.SetFontHeight( ::basegfx::fround(nFontHeight * aScale.getY()) );
}
io_rVCLFont.SetOrientation( static_cast< short >( ::basegfx::fround(-fmod(nRotate, 2*M_PI)*(1800.0/M_PI)) ) );
diff --git a/canvas/source/vcl/spritecanvashelper.cxx b/canvas/source/vcl/spritecanvashelper.cxx
index c7aee1ffb867..65d1141f7203 100644
--- a/canvas/source/vcl/spritecanvashelper.cxx
+++ b/canvas/source/vcl/spritecanvashelper.cxx
@@ -103,7 +103,7 @@ namespace vclcanvas
const Point& rPos )
{
vcl::Font aVCLFont;
- aVCLFont.SetHeight( 20 );
+ aVCLFont.SetFontHeight( 20 );
aVCLFont.SetColor( Color( INFO_COLOR ) );
rOutDev.SetTextAlign(ALIGN_TOP);
diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx
index 8c6af62accfe..8dd45e0df909 100644
--- a/canvas/source/vcl/spritehelper.cxx
+++ b/canvas/source/vcl/spritehelper.cxx
@@ -315,7 +315,7 @@ namespace vclcanvas
// paint sprite prio
vcl::Font aVCLFont;
- aVCLFont.SetHeight( std::min(long(20),aOutputSize.Height()) );
+ aVCLFont.SetFontHeight( std::min(long(20),aOutputSize.Height()) );
aVCLFont.SetColor( COL_RED );
rTargetSurface.SetTextAlign(ALIGN_TOP);