The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Last to first in SVG paths

These changes was commited to the Birdfont repository Sat, 09 Jul 2016 20:05:36 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 09 Jul 2016 20:05:36 +0000 (22:05 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 09 Jul 2016 20:05:36 +0000 (22:05 +0200)
commit bc893cd7d66a76ece205930228fedfa0b51688d7
tree 60ae4835ca19468f48337ea92383066fd99e06a2
parent a4b451760c01d61291105e7702732ed2ca768d2d
Last to first in SVG paths

libsvgbird/Doubles.vala
libsvgbird/Points.vala
libsvgbird/SvgFile.vala
--- a/libsvgbird/Doubles.vala +++ b/libsvgbird/Doubles.vala @@ -47,6 +47,20 @@ } data[index].value = p; + } + + public void set_type (int index, uchar t) { + if (unlikely (index < 0)) { + warning ("index < 0"); + return; + } + + if (unlikely (index >= size)) { + warning ("index >= size"); + return; + } + + data[index].type = t; } public void insert (int position, double p) {
--- a/libsvgbird/Points.vala +++ b/libsvgbird/Points.vala @@ -18,11 +18,16 @@ public class Points : GLib.Object { public Doubles point_data = new Doubles.for_capacity (100); - public bool closed = false; + public bool closed; + public int size { get { return point_data.size; } + } + + public void set_type (int index, uchar p) { + point_data.set_type (index, p); } public void set_double (int index, double p) {
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -798,12 +798,17 @@ // all instructions are padded + double first_x = 0; + double first_y = 0; for (int i = 0; i < points_size; i++) { // FIXME: add more types if (bezier_points[i].type == 'M') { + first_x = bezier_points[i].x0; + first_y = bezier_points[i].y0; + points.add_type (POINT_LINE); - points.add (bezier_points[i].x0); - points.add (bezier_points[i].y0); + points.add (first_x); + points.add (first_y); points.add (0); points.add (0); points.add (0); @@ -850,6 +855,16 @@ points.add (rotation); } else if (bezier_points[i].type == 'z') { points.closed = true; + + points.add_type (POINT_LINE); + points.add (first_x); + points.add (first_y); + points.add (0); + points.add (0); + points.add (0); + points.add (0); + points.add (0); + path_data.add (points); points = new Points (); } else {