diff options
author | Chr. Rossmanith <ChrRossmanith@gmx.de> | 2012-05-01 16:44:37 +0200 |
---|---|---|
committer | Chr. Rossmanith <ChrRossmanith@gmx.de> | 2012-05-01 16:48:59 +0200 |
commit | 82850c932054a5a1549c3cfbfc61e8e3dcb6e0fb (patch) | |
tree | cc6d029a0c1c8586c543586445c15a2352c04ce1 | |
parent | 9c9bf9a3adf6b885289a698ed270f51554bca86a (diff) |
SVG: use scale in font size and text baseline heuristic
-rw-r--r-- | filter/source/svg/svgreader.cxx | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx index f0d3fdef7422..062c73f56eea 100644 --- a/filter/source/svg/svgreader.cxx +++ b/filter/source/svg/svgreader.cxx @@ -507,8 +507,16 @@ struct AnnotatingVisitor rtl::Reference<SvXMLAttributeList> xAttrs( new SvXMLAttributeList() ); uno::Reference<xml::sax::XAttributeList> xUnoAttrs( xAttrs.get() ); - if (XML_TEXT == nTagId) + if (XML_TEXT == nTagId) { rState.mbIsText = true; + basegfx::B2DTuple aScale, aTranslate; + double fRotate, fShearX; + if (rState.maCTM.decompose(aScale, aTranslate, fRotate, fShearX)) + { + rState.mnFontSize *= aScale.getX(); + } + } + std::pair<StatePool::iterator, bool> aRes = mrStates.insert(rState); SAL_INFO ("svg", "size " << mrStates.size() << " id " << const_cast<State&>(*aRes.first).mnStyleId); @@ -1519,18 +1527,26 @@ struct ShapeWritingVisitor // actually export text xAttrs->Clear(); - // some heuristic attempts to have text output - // baseline-relative - y -= 2.0*maCurrState.mnFontSize/3.0; // extract basic transformations out of CTM basegfx::B2DTuple aScale, aTranslate; double fRotate, fShearX; if (maCurrState.maCTM.decompose(aScale, aTranslate, fRotate, fShearX)) { + // some heuristic attempts to have text output + // baseline-relative + y -= 2.0*maCurrState.mnFontSize/aScale.getX()/3.0; + // apply transform + x *= aScale.getX(); + y *= aScale.getY(); x += aTranslate.getX(); y += aTranslate.getY(); } + else { + // some heuristic attempts to have text output + // baseline-relative + y -= 2.0*maCurrState.mnFontSize/3.0; + } xAttrs->AddAttribute( USTR( "svg:x" ), rtl::OUString::valueOf(pt2mm(x))+USTR("mm")); xAttrs->AddAttribute( USTR( "svg:y" ), rtl::OUString::valueOf(pt2mm(y))+USTR("mm")); |