|
| 1 | +diff --git a/Makefile b/Makefile |
| 2 | +index 3ad5891..2c1c596 100644 |
| 3 | +--- a/Makefile |
| 4 | ++++ b/Makefile |
| 5 | +@@ -150,7 +150,7 @@ else |
| 6 | + COMPILE = $(CC) $(ANSIFLAGS) \ |
| 7 | + $(INCLUDES:%=$I%) \ |
| 8 | + $(CFLAGS) \ |
| 9 | +- $(FT_DEMO_CFLAGS) -I$(TOP_DIR_2)/skia/ -DHAVE_SKIA |
| 10 | ++ $(FT_DEMO_CFLAGS) -I$(TOP_DIR_2)/sn/svgnative/include/ -I$(TOP_DIR_2)/sn/svgnative/skia/include/core/ -I$(TOP_DIR_2)/sn/svgnative/skia/ -DHAVE_SKIA |
| 11 | + |
| 12 | + |
| 13 | + # Enable C99 for gcc to avoid warnings. |
| 14 | +@@ -189,10 +189,10 @@ else |
| 15 | + # `FT_DEMO_LDFLAGS` has been set in `unix-cc.mk`, too. |
| 16 | + override CC = $(CCraw) |
| 17 | + LINK_CMD = $(LIBTOOL) --mode=link $(CC) \ |
| 18 | +- -L$(TOP_DIR_2)/skia/out/Release/ -lsvg -lskia -lskshaper -lskunicode -lGL -lfontconfig -lharfbuzz \ |
| 19 | ++ -L$(TOP_DIR_2)/sn/svgnative/build/linux/ -lSVGNativeViewerLib -L$(TOP_DIR_2)/sn/svgnative/skia/out/Release/ -lskia -lGL -lfontconfig \ |
| 20 | + $(subst /,$(COMPILER_SEP),$(LDFLAGS)) |
| 21 | + LINK_LIBS = $(subst /,$(COMPILER_SEP),$(FTLIB) $(EFENCE)) \ |
| 22 | +- -L$(TOP_DIR_2)/skia/out/Release/ -lsvg -lskia -lskshaper -lskunicode -lGL -lfontconfig -lharfbuzz \ |
| 23 | ++ -L$(TOP_DIR_2)/sn/svgnative/build/linux/ -lSVGNativeViewerLib -L$(TOP_DIR_2)/sn/svgnative/skia/out/Release/ -lskia -lGL -lfontconfig \ |
| 24 | + $(FT_DEMO_LDFLAGS) |
| 25 | + else |
| 26 | + LINK_CMD = $(CC) $(subst /,$(COMPILER_SEP),$(LDFLAGS)) |
| 27 | ++++ b/README.svg-native |
| 28 | +@@ -0,0 +1,4 @@ |
| 29 | ++To run: |
| 30 | ++ |
| 31 | ++LD_LIBRARY_PATH=sn/svgnative/build/linux/: ./bin/.libs/ftgrid -s TrajanColor-Concept.otf |
| 32 | ++LD_LIBRARY_PATH=sn/svgnative/build/linux/: ./bin/.libs/ftgrid -s Nabla-Regular.ttf |
| 33 | +diff --git a/src/skia-port.c b/src/skia-port.c |
| 34 | +index d1c8b7a..e818778 100644 |
| 35 | +--- a/src/skia-port.c |
| 36 | ++++ b/src/skia-port.c |
| 37 | +@@ -38,9 +38,8 @@ |
| 38 | + |
| 39 | + #ifdef HAVE_SKIA |
| 40 | + |
| 41 | +-#include "modules/svg/include/SkSVGDOM.h" |
| 42 | +-#include "modules/svg/include/SkSVGNode.h" |
| 43 | +-#include "modules/svg/include/SkSVGRenderContext.h" // SkSVGPresentationContext |
| 44 | ++#include "svgnative/SVGDocument.h" |
| 45 | ++#include "svgnative/ports/skia/SkiaSVGRenderer.h" |
| 46 | + #include "include/core/SkBitmap.h" |
| 47 | + #include "include/core/SkCanvas.h" |
| 48 | + #include "include/core/SkMatrix.h" |
| 49 | +@@ -186,15 +185,10 @@ |
| 50 | + state = &state_dummy; |
| 51 | + |
| 52 | + /* Form an `sk_sp<SkSVGDOM>` by loading the SVG document. */ |
| 53 | +- SkMemoryStream svgmem(document->svg_document, |
| 54 | +- document->svg_document_length, false /*not copying */); |
| 55 | +- sk_sp<SkSVGDOM> svg = SkSVGDOM::MakeFromStream(svgmem); |
| 56 | +- |
| 57 | +- //svg->getRoot()->intrinsicSize(); |
| 58 | +- if (svg->containerSize().isEmpty()) { |
| 59 | +- SkSize size = SkSize::Make(units_per_EM, units_per_EM); |
| 60 | +- svg->setContainerSize(size); |
| 61 | +- } |
| 62 | ++ auto renderer = std::make_shared<SVGNative::SkiaSVGRenderer>(); |
| 63 | ++ char *s = strndup((char *)document->svg_document, |
| 64 | ++ document->svg_document_length); |
| 65 | ++ auto svg = std::unique_ptr<SVGNative::SVGDocument>(SVGNative::SVGDocument::CreateSVGDocument(s, renderer)); |
| 66 | + // Do we care about the viewBox attribute? It is auto I think, anyway. |
| 67 | + |
| 68 | + /* |
| 69 | +@@ -245,12 +239,12 @@ |
| 70 | + /* Set up a transformation matrix. */ |
| 71 | + recordingCanvas->concat(m); |
| 72 | + |
| 73 | ++ renderer->SetSkCanvas(recordingCanvas); |
| 74 | + /* If the document contains only one glyph, `start_glyph_id` and */ |
| 75 | + /* `end_glyph_id` have the same value. Otherwise `end_glyph_id` */ |
| 76 | + /* is larger. */ |
| 77 | + if ( start_glyph_id < end_glyph_id ) |
| 78 | + { |
| 79 | +- SkSVGPresentationContext pctx; |
| 80 | + char id[32]; |
| 81 | + /* Render only the element with its ID equal to `glyph<ID>`. */ |
| 82 | + sprintf( id, "glyph%u", slot->glyph_index ); |
| 83 | +@@ -262,12 +256,12 @@ |
| 84 | + * whole. In the case of OT-SVG, there is no extra |
| 85 | + * Context, so leaving it as default is fine. |
| 86 | + */ |
| 87 | +- svg->renderNode(recordingCanvas, pctx, id); |
| 88 | ++ svg->Render(id, svg->Width(), svg->Height()); |
| 89 | + } |
| 90 | + else |
| 91 | + { |
| 92 | + /* Render the whole document */ |
| 93 | +- svg->render(recordingCanvas); |
| 94 | ++ svg->Render(svg->Width(), svg->Height()); |
| 95 | + } |
| 96 | + |
| 97 | + /* Get the bounding box of the drawing. */ |
0 commit comments