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

Implement SVG in OT support. #64530

Merged
merged 1 commit into from
Nov 14, 2022
Merged

Implement SVG in OT support. #64530

merged 1 commit into from
Nov 14, 2022

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Aug 17, 2022

Implements support for SVG emoji fonts.

Screenshot 2022-10-12 at 20 23 02

  • SVG is pre-processed using XMLParser to remove unrelated glyphs from the multi-glyph documents (first time glyph rendering might be slow with fonts that use large mult-glyph documets).
  • Document view box is used only to determine aspect ratio, real viewbox is calculated from bounding boxes of top level elements.
  • XMLParser is changed to accept external data pointer without making a copy (some fonts have a single 20MB SVG with all glyphs).

@fire
Copy link
Member

fire commented Aug 18, 2022

@hermet

ThorVG, which is used by Godot to rasterize SVGs, seems to be unable to load SVGs without viewBox attribute and unable to get bounding box of the SVG objects.

Also, ThorVG unable to extract and rasterize part of SVG using object id, which might be necessary for some SVG fonts.

Some feedback.

@mgrudzinska
Copy link

@fire thanks for letting us know!
We'll try to solve the issues on the TVG side.
If you find any svg file which doesn't display as it should, please open issue in the ThorVG repo.

@bruvzg
Copy link
Member Author

bruvzg commented Oct 12, 2022

With some hacks, got it working.

@bruvzg bruvzg force-pushed the svg_in_ot branch 2 times, most recently from cf73d09 to 05ba695 Compare October 12, 2022 09:23
@bruvzg

This comment was marked as outdated.

@bruvzg bruvzg force-pushed the svg_in_ot branch 4 times, most recently from 104dee1 to 3347713 Compare October 12, 2022 17:12
@bruvzg bruvzg changed the title [WIP] Implement SVG in OT support. Implement SVG in OT support. Oct 12, 2022
@bruvzg bruvzg marked this pull request as ready for review October 12, 2022 19:21
@bruvzg bruvzg requested review from a team as code owners October 12, 2022 19:21
@fire
Copy link
Member

fire commented Oct 16, 2022

Is this ready to review / merge?

@bruvzg
Copy link
Member Author

bruvzg commented Oct 17, 2022

Is this ready to review / merge?

It is ready.

@akien-mga
Copy link
Member

It doesn't seem to be implemented yet for the GDExtension builds of the TextServer. How do you envision it working? The multiple dependencies and separate module make it a bit tricky.

@bruvzg

This comment was marked as outdated.

@bruvzg
Copy link
Member Author

bruvzg commented Nov 4, 2022

Added GDExtension build support and moved tvg_svginot code to the text servers.

SVG is pre-processed using XMLParser to remove unrelated glyphs from the multi-glyph documents (first time glyph rendering might be slow with fonts that use large mult-glyph documets).

This part is much slower with GDExtension, due to lack of += operators in String and unexposed XMLParser::_open_buffer.

@bruvzg bruvzg marked this pull request as ready for review November 4, 2022 12:51
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#ifndef THORVG_SVG_IN_OT_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the exact same code in both modules, maybe we could avoid the duplication by allowing ourselves a relative include of the files in the other module? I.e. have text_server_fb code compile and look for ../text_server_adv/thorvg_svg_in_ot.h?

It's a bit dirty because it means that text_server_fb couldn't build if text_server_adv is deleted from the tree, but that might be better than fully duplicating the code?

Also, how is the current duplication handled if both modules are compiled together?

Copy link
Member Author

@bruvzg bruvzg Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit dirty because it means that text_server_fb couldn't build if text_server_adv is deleted from the tree, but that might be better than fully duplicating the code?

For the header it's probably OK, but for the thorvg_svg_in_ot.cpp it might be an issue.
Edit: SCons will not accept the same file in the two places - scons: *** Two environments with different actions were specified for the same target:

Also, how is the current duplication handled if both modules are compiled together?

It's in the different compile units and is not used from any other code, so should not be an issue.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@akien-mga akien-mga modified the milestones: 4.x, 4.0 Nov 14, 2022
@akien-mga akien-mga merged commit 471c42e into godotengine:master Nov 14, 2022
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants