diff options
-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 29b31438b399..fdb8496f1563 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -386,10 +386,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 && nMeasuredTextLength) + if (nImportedTextLength != nMeasuredTextLength) { const double fFactorText(static_cast<double>(nImportedTextLength) / static_cast<double>(nMeasuredTextLength)); const double fFactorTextPercent(fabs(1.0 - fFactorText) * 100.0); @@ -418,6 +421,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)); |