Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unite path possible bug? #505

Closed
ontic opened this issue Jul 27, 2014 · 20 comments
Closed

Unite path possible bug? #505

ontic opened this issue Jul 27, 2014 · 20 comments

Comments

@ontic
Copy link

ontic commented Jul 27, 2014

I've been playing around with paper.js the past few weeks and have really come to like it, but I've encountered mixed results when trying to unite paths.

I am trying to create an outline of multiple paths by uniting them, so they'll form a cut contour. The paths I am trying to unite were derived from an SVG font, explaining the problems I've encountered is difficult, so I've uploaded a functional demo to my server.

Demo URL: http://goo.gl/1SPeo1

Test Case 1:
Firstname: Adam
Font: Lobster
Result: The glyphs "d" and "a" are not united

Test Case 2:
Firstname: adam
Font: Lobster
Result: This works perfectly!

Test Case 3:
Firstname: Adam
Font: Lucida
Result: This works perfectly!

Test Case 4:
Firstname: Kaitlin
Font: Lucida
Result: The glyphs "i", "t", "l", "i" and "n" are not united

I'm sure if you try typing other words, you'll discover more problems/inconsistencies. I'd appreciate your assistance in resolving this.

Regards,
Adam

@ontic
Copy link
Author

ontic commented Jul 28, 2014

If you need any more details or files just let me know. Although you should be able to inspect/copy the source from the link above.

@lehni
Copy link
Member

lehni commented Jul 28, 2014

@hkrish I think this is one for you. I am wondering if we should still try and fix the current boolean code a bit more before implementing the new version, e.g. using the improved solve qubic approach?

@hkrish
Copy link
Contributor

hkrish commented Jul 28, 2014

I will take a look at this.
@lehni We can certainly fix the current code for issues like these. But there are another set of issues we cannot fix, like overlapping paths etc. I will also try to move more functionality to the new cubic solver.

@lehni
Copy link
Member

lehni commented Jul 28, 2014

Yes I understand that. I think it'd be good to fix the issues that we started working on already, move to the new solver, so there's less pressure on the work on the new approach. And I'm happy to help with this!

@ontic
Copy link
Author

ontic commented Jul 28, 2014

@lehni @hkrish I wasn't sure if the inconsistencies were caused by the fonts I used, how I parsed the font using PHP, or just the way I coded project. It seems like you's are ironing out some bugs in regards to uniting paths, I'll keep a close eye on your commits. I think having a solid API for handling fonts and glyphs in this manner would be a great feature to the library. E.g.

var font = new paper.Font({json|xml});
font.name
font.glyphs (array of paper.Glyph instances)
font.unitsPerEm
font.ascent
...

var text = new paper.PointText(new paper.Point(0, 0));
text.content = 'Some Text';
text.font = font;

var paths = text.toPaths();

I'm more of a PHP developer, but if there's anything I can assist with just let me know. Cheers

@lehni
Copy link
Member

lehni commented Jul 28, 2014

Yeah a font API would be lovely and is something we keep planning for the future.

If you could perhaps isolate some simple test-cases from your app that use SVG-style path-data (path#pathData) to illustrate the boolean operations that go wrong, that'd be great!

@lehni
Copy link
Member

lehni commented Jul 28, 2014

Oh, and if you'd like to work on the Font API that'd be great! How much do you know about Font formats?

@ontic
Copy link
Author

ontic commented Jul 29, 2014

@lehni No worries, I'll strip down my sandbox application so there are no dependencies (jQuery & Bootstrap) and hard code the font information (JSON object) which is currently being produced using PHP. I might have time to do this tonight, once I separate the individual test cases I'll upload them to my server (as well as a .zip file for you guys to download).

I'm happy to have a crack at creating an API for handling fonts, although I'm no expert when it comes to the different formats. But I don't think any of us need to be. Rather than trying to accommodate various formats (TTF, OTF, WOFF, SVG, etc) it would be better to have your own conventions for how font information should be supplied.

Take https://github.com/sorccu/cufon for example, they don't try and render text/glyphs for all types of fonts (which would be difficult using just JavaScript). Instead their website allows users to upload and convert fonts to a format there library is familiar with. You could do something similar using the open source software http://fontforge.org.

"FontForge -- An outline font editor that lets you create your own postscript, truetype, opentype, cid-keyed, multi-master, cff, svg and bitmap (bdf, FON, NFNT) fonts, or edit existing ones."

Using FontForge you're able to convert different types of fonts to various formats, but we really only need the font converted to SVG, from SVG you can then easily convert it JSON or a format you think is best.

What are your thoughts?

@ontic
Copy link
Author

ontic commented Aug 1, 2014

Sorry for the delay, my day job has been keeping me busy.

Sandbox: http://adamdyson.com.au/sandbox/index.php
Files: http://adamdyson.com.au/sandbox.zip

I'll hopefully get a chance to map out an API for handling fonts over the weekend. Let me know how you get on with this uniting paths issue.

@hkrish
Copy link
Contributor

hkrish commented Aug 1, 2014

Thanks @ontic. I would take a look at this soon.

@rponudic
Copy link

@ontic Your examples are not anymore online so I can't tell you for sure, but the problem you are describing seems to be quite similar to the one I had. Maybe this will help you out:

#540

@ontic
Copy link
Author

ontic commented Oct 20, 2014

@rponudic Unfortunately the issues are unrelated. The shapes (glyphs) I was creating were CompoundPaths which rendered perfectly, the issue/bug I encountered was when I tried to unite certain paths, some united fine but others had unexpected results. Thanks anyway.

@hkrish @lehni Any progress on this issue?

@lehni
Copy link
Member

lehni commented Oct 20, 2014

@ontic It'd be good if you could keep your examples alive as long as the bug is not solved.

@oayoub84
Copy link

Hi everybody, i don't know if i had to open issue or just post in this one, because the bug i encountered is aslo related to unite() function, but not with a complex paths as @ontic, just with sample one:

var path = new Path({
segments: [[30, 25], [30, 100], [250, 100], [250, 25]],
fillColor: 'red'
});
path.closed = true;

var path2 = new Path({
segments: [[200, 25], [200, 100], [300, 100], [300, 25]],
fillColor: 'black'
});
path2.closed = true;

// Join the paths:
var newpath = path.unite(path2);
newpath.selected = true;

path.remove();
path2.remove();

This is the result:
http://grab.by/BxBa

Excepted result in one big rectangle.

@lehni
Copy link
Member

lehni commented Jan 2, 2015

@Masix, your issue is the same as #450, not the one described here.

@lehni
Copy link
Member

lehni commented Jan 2, 2015

@ontic if you want this looked at, please put your test case up again. Otherwise I will close this bug in a couple of weeks. Thanks.

@ontic
Copy link
Author

ontic commented Jan 4, 2015

@lehni Yes I do desperately! I've re-uploaded the test cases and bundled the files in a .zip

https://www.adamdyson.com.au/sandbox.zip

@lehni
Copy link
Member

lehni commented Jan 4, 2015

Thanks! Got it now and will turn it into simpler test-cases based on JSON export of the problematic data.

@ontic
Copy link
Author

ontic commented Jan 5, 2015

@lehni Ok great! Let me know if I can help in any way.

@lehni
Copy link
Member

lehni commented Aug 18, 2015

With all the recent fixes to boolean operations in place, I am happy to announce that all the problems mentioned above are now working as they should!

@hkrish & @iconexperience, that's pretty good news I think! : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants