The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Layer boundaries

These changes was commited to the Birdfont repository Sun, 14 Jun 2015 12:55:41 +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>
Sun, 14 Jun 2015 12:55:41 +0000 (14:55 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 14 Jun 2015 12:55:41 +0000 (14:55 +0200)
commit 3499414693682fd3247374951bc26182d06b4b39
tree 3f298406b87266b046498f2f992a2e394d78c27f
parent 704e94eb2b7532d5616fbf73afcae0d9527b4807
Layer boundaries

libbirdfont/Layer.vala
--- a/libbirdfont/Layer.vala +++ b/libbirdfont/Layer.vala @@ -85,7 +85,39 @@ return layer; } - + + public void get_boundaries (out double x, out double y, out double w, out double h) { + double px, py, px2, py2; + + px = Glyph.CANVAS_MAX; + py = Glyph.CANVAS_MAX; + px2 = Glyph.CANVAS_MIN; + py2 = Glyph.CANVAS_MIN; + + foreach (Path p in get_all_paths ().paths) { + if (px > p.xmin) { + px = p.xmin; + } + + if (py > p.ymin) { + py = p.ymin; + } + + if (px2 < p.xmax) { + px2 = p.xmax; + } + + if (py2 < p.ymax) { + py2 = p.ymax; + } + } + + w = px2 - px; + h = py2 - py; + x = px; + y = py2; + } + public void print (int indent = 0) { foreach (Path p in paths.paths) { for (int i = 0; i < indent; i++) {