Commit Graph

42 Commits

Author SHA1 Message Date
Patrick Walton a443e41909 Guard band clipping 2018-12-14 18:52:34 -08:00
Patrick Walton 8f5eb1ca60 add strokes 2018-12-14 14:33:33 -08:00
Patrick Walton a2522e3845 wip 2018-11-14 10:33:53 -08:00
Paul Rouget 6d7dd604f8 Euclid and lyon updates 2018-07-27 11:40:45 +02:00
Nicolas Silva 46d1878ef5 Update lyon and euclid dependencies. 2018-07-11 00:27:42 +02:00
Patrick Walton dbd3a36f3d Generate a reasonable normal for the superfluous control point generated
for lines.
2018-03-21 14:56:24 -07:00
Patrick Walton cffff886c3 Be more robust in the presence of duplicated points when computing
normals
2018-03-07 11:53:44 -08:00
Patrick Walton db6986ca1f Take the orientation of a path into account when computing normals 2018-03-07 11:21:08 -08:00
Patrick Walton 18121208d4 Update euclid to 0.17 and Lyon to 0.10 2018-03-06 15:06:06 -08:00
Patrick Walton b60275e5ea Convert cubic curves to quadratic ones in fonts 2018-03-06 13:10:29 -08:00
Patrick Walton f718aa9ce3 Make the FreeType API match the Core Graphics one 2018-03-05 17:15:17 -08:00
Patrick Walton a84b7c7cbd Replace ECAA with "Stencil AAA", a distance-based antialiasing
technique similar to the new MCAA.

This new technique simplifies the code significantly by unifying lines,
curves, and transformed curves. Blog posts forthcoming.
2018-02-17 10:45:25 -08:00
Patrick Walton 5bd68dec65 Port Pathfinder to use Lyon for Bézier curve math.
This removes a whole lot of code from `pathfinder_path_utils`. Hopefully
the remaining code can go upstream.

These changes regress quality of stroke widths for cubic curves, because
they move fill-to-stroke conversion before cubic-to-quadratic
conversion. To fix that, we will need to recursively subdivide when
doing fill-to-stroke conversion.
2018-01-29 12:47:47 -08:00
Patrick Walton 2ec5dbfa42 Fix minor comment typo 2018-01-21 13:06:47 -08:00
Patrick Walton 952186c638 Document `pathfinder_font_renderer`. 2018-01-05 16:59:49 -08:00
Patrick Walton c68f16f6ba Write more API documentation 2018-01-05 15:52:15 -08:00
Patrick Walton 32c20ec649 Document most of `pathfinder_path_utils`. 2018-01-05 14:20:50 -08:00
Patrick Walton 4b887174f8 Document some more of `pathfinder_path_utils` 2018-01-05 12:35:01 -08:00
Patrick Walton 452ade0012 Document `pathfinder_path_utils::cubic` 2018-01-05 12:19:23 -08:00
Patrick Walton 2c2afe2fc0 Only emit a `ClosePath` command in a `PathBufferStream` if the subpath
is closed.

Closes #60.
2018-01-03 15:31:34 -08:00
Patrick Walton f132117d4c Don't add overlapping points to close paths in the stroking algorithm.
These extra points are unnecessary and can confuse the partitioner,
because they sometimes prevent it from detecting winding numbers
properly. This is a bug in the partitioner and should be fixed, but we
shouldn't be generating these points to begin with.

Partially addresses #57.
2017-12-21 13:22:23 -08:00
Patrick Walton 98250b9232 Close stroke paths as necessary.
Partially addresses #57.
2017-12-21 11:56:12 -08:00
Patrick Walton f04f39afd6 Close subpaths explicitly.
Partially addresses #57.
2017-12-20 13:41:01 -08:00
Patrick Walton 6a81ec4893 Make SVG stroke width more accurate, and switch to XCAA by default.
Partially addresses #57.
2017-12-20 10:40:21 -08:00
Patrick Walton 6942bb51ca Add support for full 3D transforms, including rotation, to SVG in XCAA mode. 2017-11-28 16:15:06 -08:00
Patrick Walton 8897145f54 Add a simple command-line frontend for use as part of a build process 2017-11-06 13:28:32 -08:00
Patrick Walton 0a4fcb4841 Add a cubic curve command stream.
This is a prerequisite for handling CFF fonts.
2017-10-23 20:05:36 -07:00
Patrick Walton 314185684c Implement stem darkening and split ECAA into ECAA and MCAA.
We now implement stem darkening (also known as font dilation) like
macOS and FreeType under certain configurations. This pushes out font
outlines along their normals slightly in order to make small text easier
to read. This is especially important when performing gamma correction,
as otherwise text can end up too light.

Because the stem darkening is implemented in the vertex shader, it can
easily break the mesh. Therefore, I needed to implement a new rendering
mode that does not use the mesh. It's a variant of ECAA, and for
clarity's sake I've renamed the related antialiasing methods:

* MCAA stands for "mesh coverage antialiasing" and is the new name for
what was called "ECAA" prior to this patch.

* ECAA now stands for "edge coverage antialiasing". It does not use the
mesh but rather computes winding numbers from scratch for every pixel.
Surprisingly, despite being worse asymptotically, this usually ends up
being faster than MCAA at small font sizes, presumably because there are
fewer vertices to transform.

* XCAA, "exact coverage antialiasing" is a generic term that refers to
both ECAA and MCAA. References to ECAA have been changed to XCAA as
needed.
2017-10-15 13:28:49 -07:00
Patrick Walton b6a60ef987 Make FreeType no longer a dependency of `path-utils` 2017-10-04 19:03:38 -07:00
Patrick Walton 8de1970682 Implement stroking ourselves, and rename `PathSegment` to `PathCommand`.
This makes Pathfinder no longer use the FreeType stroker.
2017-10-04 18:57:30 -07:00
Patrick Walton e78d7ed575 Recursively approximate cubic Béziers with quadratics to an error bound.
Gets the tiger rendering properly, as far as I can tell.
2017-09-29 16:30:17 -07:00
Patrick Walton c37fd1f1e8 Ignore intersections beyond the sweep line.
Improves the outer stroke of the tiger.
2017-09-25 19:15:36 -07:00
Patrick Walton 93de8383f9 Replace the implicitization algorithm for curve intersection with a
simpler one based on binary search and the quadratic formula.

This does a better job avoiding floating point error and improves the
rendering of the tiger.
2017-09-25 18:51:02 -07:00
Patrick Walton 8c518deebe Do a better job of approximating cubic Bézier curves with quadratics
This still isn't great, but it's a lot better than the old approximation, which was just bogus.
2017-09-22 17:15:19 -07:00
Patrick Walton 88f1d3f108 Fix de Casteljau subdivision when a curve has two inflection points 2017-09-22 13:40:41 -07:00
Patrick Walton be1b100826 Split B-quads whose curves' convex hulls intersect in most cases.
Avoids some rendering artefacts with Loop-Blinn, improving the tiger.
2017-09-21 22:47:00 -07:00
Patrick Walton 4ac11e9010 Switch to a more robust intersection algorithm based on implicitization 2017-09-20 21:23:56 -07:00
Patrick Walton d644f1b6a6 Implement curve-curve and curve-line intersection, untested as of yet 2017-09-18 21:00:34 -07:00
Patrick Walton a7d75f913c Split paths into monotonic segments before partitioning them in the demo 2017-09-12 09:35:57 -07:00
Patrick Walton c3e02d6faa Add a streaming API for monotonic path conversion, untested as of yet 2017-09-11 22:28:14 -07:00
Patrick Walton c36896e337 Implement path stroking using the FreeType stroker.
I'm not too happy with this, as I discovered a segfault in FreeType that doesn't give me confidence
in this as a solution for the long term. Additionally, this exposes the problems in the partitioner
with lack of winding fill rule, proper handling of self-intersections, and splitting of paths at
their extrema. (I believe these problems should be fairly straightforward to handle, but we just
don't handle them yet.)
2017-09-08 16:50:27 -07:00
Patrick Walton 3e5b53f13c Partially refactor the path APIs to be streaming, like Lyon 2017-09-08 13:09:00 -07:00