From e9916b0ca221016add9268b6d83dffc4be457fac Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 6 May 2019 11:39:24 +0200 Subject: Add basic SVG in OpenType support. --- src/display/drawing-text.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/display/drawing-text.cpp') diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 9d81d736d..b92886691 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -584,7 +584,34 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are if (g->_ctm.isSingular()) continue; dc.transform(g->_ctm); if (g->_drawable) { - dc.path(*g->_font->PathVector(g->_glyph)); + if (g->_font->FontHasSVG()) { + Inkscape::Pixbuf* pixbuf = g->_font->PixBuf(g->_glyph); + if (pixbuf) { + // Geom::OptRect box = bounds_exact(*g->_font->PathVector(g->_glyph)); + // if (box) { + // Inkscape::DrawingContext::Save save(dc); + // dc.newPath(); + // dc.rectangle(*box); + // dc.setLineWidth(0.01); + // dc.setSource(0x8080ffff); + // dc.stroke(); + // } + { + // pixbuf is in font design units, scale to embox. + double scale = g->_font->GetDesignUnits(); + if (scale <= 0) scale = 1000; + Inkscape::DrawingContext::Save save(dc); + dc.translate(0, 1); + dc.scale(1.0/scale, -1.0/scale); + dc.setSource(pixbuf->getSurfaceRaw(), 0, 0); + dc.paint(1); + } + } else { + dc.path(*g->_font->PathVector(g->_glyph)); + } + } else { + dc.path(*g->_font->PathVector(g->_glyph)); + } } } -- cgit v1.2.3