diff options
Diffstat (limited to 'emfio/source/reader/mtftools.cxx')
-rw-r--r-- | emfio/source/reader/mtftools.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 0d918af72dc0..53564c34f82b 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -385,10 +385,13 @@ namespace emfio // calculate measured TextLength const vcl::Font& rFontCandidate(maCurrentMetaFontAction->GetFont()); pTempVirtualDevice->SetFont(rFontCandidate); - const tools::Long nMeasuredTextLength(pTempVirtualDevice->GetTextWidth(rText)); + tools::Long nMeasuredTextLength(pTempVirtualDevice->GetTextWidth(rText)); + // on failure, use original length + if (!nMeasuredTextLength) + nMeasuredTextLength = nImportedTextLength; // compare expected and imported TextLengths - if(nImportedTextLength != nMeasuredTextLength) + if (nImportedTextLength != nMeasuredTextLength) { const double fFactorText(static_cast<double>(nImportedTextLength) / static_cast<double>(nMeasuredTextLength)); const double fFactorTextPercent(fabs(1.0 - fFactorText) * 100.0); @@ -417,6 +420,9 @@ namespace emfio rFontCandidate2.SetAverageFontWidth(static_cast<tools::Long>(fCorrectedAverageFontWidth)); pTempVirtualDevice->SetFont(rFontCandidate2); nCorrectedTextLength = pTempVirtualDevice->GetTextWidth(rText); + // on failure, use original length + if (!nCorrectedTextLength) + nCorrectedTextLength = nImportedTextLength; } const double fFactorCorrectedText(static_cast<double>(nImportedTextLength) / static_cast<double>(nCorrectedTextLength)); |