Open Aiving opened 1 month ago
I too hope that SVG support can be improved, as I currently can't find a way to resize an SVG to an absolute size because it's not possible to get the actual dimensions of the SVG.
I too hope that SVG support can be improved, as I currently can't find a way to resize an SVG to an absolute size because it's not possible to get the actual dimensions of the SVG.
You can do svg.inner().fContainerSize.fWidth
and svg.inner().fContainerSize.fHeight
to get its size if specified.
I too hope that SVG support can be improved, as I currently can't find a way to resize an SVG to an absolute size because it's not possible to get the actual dimensions of the SVG.
You can do
svg.inner().fContainerSize.fWidth
andsvg.inner().fContainerSize.fHeight
to get its size if specified.
Oh, thank you so much. I was looking at Skia's api docs which say to use getRoot()->intrinsicSize()
which I thought was missing from the bindings.
render_node is used by ot-svg fonts. You'll need to get one of those...
See the skia-python example: https://github.com/rougier/freetype-py/blob/master/examples/ot-svg-example-skia.py
Which loads this skia-python svg code: https://github.com/rougier/freetype-py/blob/master/examples/skia_ot_svg_module.py
Basically in an ot-svg font, many glyphs are collected into one svg document (to allow re-use) but individual glyphs are id'ed as layers with ids.
Currently,
skia-safe
provides relatively little of the SVG functionality that Skia has.There is nothing wrong with this, but the current implementation is only suitable for fairly simple SVG rendering use cases. When, for example, the
fill="currentColor"
attribute starts to be used, there is no way to set a color value forcurrentColor
other than the default. As a result,currentColor
becomes just an alias for black.Also the following functions are not available in
Dom
struct:get_root
,render_node
,container_size
(althoughset_container_size
is there),find_node_by_id
. As a consequence, there are also no structs likeSvgNode
,Svg
andPresentationContext
. Actually adding them is not a complicated process. Almost. I've been trying to implement it myself for a couple of days already. The main headache in this case is theSkSVGProperty
class in Skia, which for some reason in bindings turns intotype SkSVGProperty_ValueT<T> = T
and is not even used anywhere.I would also like to note that I still don't quite understand how
render_node
andfind_node_by_id
should be used, as they both take as one of the parameters theid
of a node, the value of which for, for example, root node, I don't know.