diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-03 10:13:00 +1100 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-04 03:17:26 +0000 |
commit | 697d445ed0c7b60e463243db89af32e2145b475b (patch) | |
tree | 5a74d57cdc97f82bc78a686dee345a229a082a72 /drawinglayer | |
parent | 91a7580e03d5b47c6e2513afce85ddee45e730b6 (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 'drawinglayer')
4 files changed, 15 insertions, 15 deletions
diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index ac7b01fe4451..3931d196ac1b 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -2730,7 +2730,7 @@ namespace /** SIMPLE, DONE */ const MetaFontAction* pA = static_cast<const MetaFontAction*>(pAction); rPropertyHolders.Current().setFont(pA->GetFont()); - Size aFontSize(pA->GetFont().GetSize()); + Size aFontSize(pA->GetFont().GetFontSize()); if(0 == aFontSize.Height()) { @@ -2745,7 +2745,7 @@ namespace aFontSize = OutputDevice::LogicToLogic( aFontSize, MAP_PIXEL, rPropertyHolders.Current().getMapUnit()); - aCorrectedFont.SetSize(aFontSize); + aCorrectedFont.SetFontSize(aFontSize); rPropertyHolders.Current().setFont(aCorrectedFont); } diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index eac624c8804c..bec31951dd37 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -415,11 +415,11 @@ namespace drawinglayer { const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aRetval)); - if(aUnscaledFontMetric.GetWidth() > 0) + if(aUnscaledFontMetric.GetAverageFontWidth() > 0) { const double fScaleFactor((double)nWidth / (double)nHeight); - const sal_uInt32 nScaledWidth(basegfx::fround((double)aUnscaledFontMetric.GetWidth() * fScaleFactor)); - aRetval.SetWidth(nScaledWidth); + const sal_uInt32 nScaledWidth(basegfx::fround((double)aUnscaledFontMetric.GetAverageFontWidth() * fScaleFactor)); + aRetval.SetAverageFontWidth(nScaledWidth); } } #endif @@ -453,7 +453,7 @@ namespace drawinglayer // TODO: eKerning // set FontHeight and init to no FontScaling - o_rSize.setY(rFont.GetSize().getHeight() > 0 ? rFont.GetSize().getHeight() : 0); + o_rSize.setY(rFont.GetFontSize().getHeight() > 0 ? rFont.GetFontSize().getHeight() : 0); o_rSize.setX(o_rSize.getY()); #ifdef WIN32 @@ -462,15 +462,15 @@ namespace drawinglayer // needs to do extra stuff to detect the correct width (since it's // zero and not equal the font height) and its relationship to // the height - if(rFont.GetSize().getWidth() > 0) + if(rFont.GetFontSize().getWidth() > 0) { vcl::Font aUnscaledFont(rFont); - aUnscaledFont.SetWidth(0); + aUnscaledFont.SetAverageFontWidth(0); const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aUnscaledFont)); - if(aUnscaledFontMetric.GetWidth() > 0) + if(aUnscaledFontMetric.GetAverageFontWidth() > 0) { - const double fScaleFactor((double)rFont.GetSize().getWidth() / (double)aUnscaledFontMetric.GetWidth()); + const double fScaleFactor((double)rFont.GetFontSize().getWidth() / (double)aUnscaledFontMetric.GetAverageFontWidth()); o_rSize.setX(fScaleFactor * o_rSize.getY()); } } @@ -479,9 +479,9 @@ namespace drawinglayer // is easier achieved since width == height is interpreted as no // scaling. Ergo, Width == 0 means width == height, and width != 0 // means the scaling is in the direct relation of width to height - if(rFont.GetSize().getWidth() > 0) + if(rFont.GetFontSize().getWidth() > 0) { - o_rSize.setX((double)rFont.GetSize().getWidth()); + o_rSize.setX((double)rFont.GetFontSize().getWidth()); } #endif return aRetval; diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index bd24eedcb218..a24ca8ab5503 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -911,9 +911,9 @@ namespace drawinglayer (sal_Int32)ceil(aRangeLogic.getMaxX()), (sal_Int32)ceil(aRangeLogic.getMaxY())); pPDFControl->Location = aRectLogic; - Size aFontSize(pPDFControl->TextFont.GetSize()); + Size aFontSize(pPDFControl->TextFont.GetFontSize()); aFontSize = OutputDevice::LogicToLogic(aFontSize, MapMode(MAP_POINT), mpOutputDevice->GetMapMode()); - pPDFControl->TextFont.SetSize(aFontSize); + pPDFControl->TextFont.SetFontSize(aFontSize); mpPDFExtOutDevData->BeginStructureElement(vcl::PDFWriter::Form); mpPDFExtOutDevData->CreateControl(*pPDFControl.get()); diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index c8e7257eff78..bfb5e46bcf7c 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -137,7 +137,7 @@ namespace drawinglayer } // Don't draw fonts without height - if( aFont.GetHeight() <= 0 ) + if( aFont.GetFontHeight() <= 0 ) return; // handle additional font attributes |