Comments (8)
Thank you for reporting this. I think I fixed it just now.
from msdfgen.
Thank you for the quick response!
The shape is rendered correctly now, but only if I use the generateMSDF_legacy
function; if I use the new generateMSDF
function it creates just a black output.
from msdfgen.
Please link the exact input where this happens. The one you posted earlier behaves correctly for me.
from msdfgen.
I parsed the svg myself into cubic segments and did not use the SVG importer from your project, so maybe that is why it works for you.
This is the test case for the above teardrop shape (I hardcoded the edge values):
Shape dfShape;
Contour &contour = dfShape.addContour();
contour.addEdge(new CubicSegment(Point2(258.599060, 396.484863), Point2(269.933899, 386.063660), Point2(410.555725, 323.508911), Point2(117.682785, 187.383301)));
contour.addEdge(new CubicSegment(Point2(117.682785, 187.383301), Point2(117.682785, 187.383301), Point2(199.505142, 441.436646), Point2(258.599060, 396.484863)));
contour.addEdge(new CubicSegment(Point2(258.599060, 396.484863), Point2(258.599060, 396.484863), Point2(258.599060, 396.484863), Point2(258.599060, 396.484863)));
Vector2 scale(1, 1);
Vector2 translate(0, 0);
edgeColoringSimple(dfShape, 1, 0);
Bitmap<FloatRGB> msdfOutput(512, 512);
// this works fine
generateMSDF_legacy(msdfOutput, dfShape, 5, scale, translate);
// this just fills msdfOutput with -infinity for all values
generateMSDF(msdfOutput, dfShape, 5, scale, translate);
from msdfgen.
In the code you posted, the last edge segment has the exact same value for all points. My program won't be able to deal with such an edge, because it for example needs to compute the direction of edges at their endpoints. I would argue this qualifies as invalid input, but maybe I should be trying to identify and remove these during shape normalization (which you didn't call anyway).
from msdfgen.
Interesting, thanks. I thought that maybe the last edge was a problem.
I would suggest not removing it during normalization (unless you would replace it with a working equivalent), but to check for such a case in the validate() method. I could open a pull request if you want to.
from msdfgen.
The thing is that we are dealing with floating point numbers, so more often than not, they might not be exactly equal, but maybe differ by a tiny fraction, and then I can't detect it. I can't just reject any vertices that seem "too close", because it could be intentional. That's why I think it should be up to the caller to provide a valid input.
from msdfgen.
That's why I think it should be up to the caller to provide a valid input.
Exactly, but your validate() method should reflect that - if the input is valid or not.
And it is in my opinion absolutely OK to reject vertices in the same edge that are closer than a very small delta (which can also be zero), as such input usually only leads to problems with later calculations and rounding errors.
from msdfgen.
Related Issues (20)
- Just a couple of questions.
- Msdf generation fails on symbol with several nested holes HOT 4
- Alpha as input ? HOT 1
- Allow FT_LOAD_DEFAULT in import-font extension HOT 5
- Confusing SignedDistance calculation in QuadraticSegment::signedDistance
- Inverting Y Axis makes uneven baseline HOT 2
- Segfault on Empty Shape
- Chinese character rendering issues HOT 5
- The effect of render small character is not good HOT 2
- Outline effect is not good on some glphys HOT 4
- Failure to import SVG file with empty initial <g> element HOT 4
- Using vcpkg leads to compiler error in VS2022 HOT 4
- Incorrect rendering of SVG with internal path HOT 1
- New release soon? HOT 1
- Call project() after cmake_minimum_required() HOT 6
- Artifact on a certain glyph HOT 4
- SVG with Quadradic path commands generates an SDF instead of MSDF HOT 3
- Multiple character output HOT 1
- Render HOT 2
- SDF from glyph curves? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msdfgen.