Navigation Menu

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

Please add support for SVG OpenType fonts! #21

Closed
Emasoft opened this issue Apr 20, 2017 · 12 comments
Closed

Please add support for SVG OpenType fonts! #21

Emasoft opened this issue Apr 20, 2017 · 12 comments

Comments

@Emasoft
Copy link

Emasoft commented Apr 20, 2017

Please add support for SVG OpenType fonts!
We use them extensively in our opengl games!

img_0433

https://blogs.adobe.com/creativecloud/photoshop-cc-adds-support-for-opentype−svg-fonts-an-in-depth-look/

https://www.microsoft.com/typography/otspec/svg.htm

@amaranth
Copy link

amaranth commented Apr 28, 2017

Note that this would require writing an SVG implementation which the original announcement post said wouldn't be likely:

Full support for SVG is probably out of scope of Pathfinder, but perhaps the subset used in practice is small enough to support.

The subset mentioned there was a hopeful comment on SVG usage in emojis being limited. Your examples seem to not be so limited. You'd need an SVG implementation (possibly using pathfinder for path rendering) that you could then plug in to pathfinder. Perhaps you could wire librsvg up for this but I suspect it'll be non-trivial.

@Emasoft
Copy link
Author

Emasoft commented Apr 28, 2017

I think that it will be necessary for two reasons:

  1. opentype-svg fonts are becoming very popular, and their usage is growing fast since photoshop started supporting them, and it is not limited to emojis anymore. The boundary between svg and fonts is becoming more and more blurred, and it is going to disappear altogether;
  2. There is no better way to show the amazing performances of the pathfinder renderer than opentype-svg fonts. No other typography engine is fast enough to be able to handle opentype-svg fonts. Pathfinder will shine with opentype-svg fonts. Svg is mostly made of bezier curves (and you can convert any svg geometry element in a bezier path equivalent), so most part of the job is already done. Pathfinder should only add things like color gradients fills and clip rects, a small addition. The core engine is already there. Supporting the remaining SVG features natively would be easy. No need of (slow and cumbersome) external libraries.

@amaranth
Copy link

You may not need to add much to pathfinder in order to support everything needed to render SVG but the harder part will be parsing SVG to generate the rendering commands.

@codeyash
Copy link

codeyash commented Apr 30, 2017

@Emasoft sounds you know a lot. Help pathfinder project by submitting pull request of SVG implementation.
I'm just a user to the project so you can confirm with project owner if like my idea.

@pcwalton
Copy link
Contributor

pcwalton commented May 2, 2017

I'm working on full scene rasterization, which would enable SVG. The hard part here is avoiding swamping the GPU in draw calls. This will require a rewrite of most of Pathfinder, but it looks promising so far.

@Emasoft
Copy link
Author

Emasoft commented May 2, 2017

@pcwalton This is an awesome news!

@imoldfella
Copy link

Interesting approach from

http://gaps-zju.org/pathrendering/GPUpathrendering.pdf

"We generate both fragments and spans as line primitives
in a single vertex buffer, then render everything in a single draw
call. Each span is rendered as a horizontal line passing through the
relevant pixel centers, and each boundary fragment is rendered as a
degenerated line one pixel in length"

@pcwalton
Copy link
Contributor

pcwalton commented Aug 27, 2017

I'm working on demonstrating how to render a subset of SVG as part of the demo. Supporting all of SVG, however, is out of scope for Pathfinder, as filters, clipping, etc. would duplicate code in WebRender. If you need broad support for SVG, use WebRender instead, which Pathfinder will eventually integrate into.

@pcwalton
Copy link
Contributor

@imoldfella I do not believe that that approach can ever be as fast as Pathfinder 2's B-mesh tessellation.

@Emasoft
Copy link
Author

Emasoft commented Aug 27, 2017

@pcwalton Wow! Do you have any benchmark yet? I suppose your code could become the reference for 2D tessellation, as Pixar OpenSubdiv is for 3D bezier patches tesselation ( https://github.com/PixarAnimationStudios/OpenSubdiv )!
On a modern GPU OpenSubdiv takes less than 3ms to subdivide a character of 30,000 polygons to the second level of subdivision (500,000 polygons).

@imoldfella
Copy link

imoldfella commented Aug 28, 2017

@pcwalton The part I thought was interesting is that they use the compute shader to build the data for one big draw command. I'm not sure how color pathfinder depth/color peels an SVG drawing into coverage buffers, but I was imagining something similar could happen where the fill stage of pathfinder creates multiple coverage buffers while simultaneously creating data for an attribute-less draw command to assemble them into the overall image. Frostbite apparently does something similar. https://frostbite-wp-prd.s3.amazonaws.com/wp-content/uploads/2016/03/29204330/GDC_2016_Compute.pdf. Your comment about swamping the GPU in draw calls prompted the thought.

They note that this approach has a side benefit of making it easy to fit the vector rendering into a more comprehensive pipeline; e.g in pathfinders case it might make an elegant way to integrate with webrender. They give the example of using nvidia's nvpr extension to do clipping of their output.

@pcwalton
Copy link
Contributor

pcwalton commented Oct 7, 2017

I have an SVG demo now successfully rendering the tiger. Let's close this and open more specific bugs for particular SVG features that folks need.

@pcwalton pcwalton closed this as completed Oct 7, 2017
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

5 participants