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

Support drawing text along a curved path and on a mesh #16477

Open
dnfield opened this issue Apr 11, 2018 · 10 comments
Open

Support drawing text along a curved path and on a mesh #16477

dnfield opened this issue Apr 11, 2018 · 10 comments

Comments

@dnfield
Copy link
Member

@dnfield dnfield commented Apr 11, 2018

I would like to be able to draw text on a non-linear path, e.g. like so: https://fiddle.skia.org/c/@draw_text_on_path

It doesn't appear to be possible to do that today - the Paragraph and Canvas.drawParagraph() classes/methods only appear to support drawing text baselined on a straight line (and paragraph in particular is heavily geared to laying out potentially multi-line text in straight lines).

As linked above, Skia has a method for drawing text on a path, but that seems to fall outside of the text/paragraph painting model used by Flutter and I'm not entirely sure it'd be appropriate for Flutter's design - however, it seems like it would be fairly easy to implement if it could fit in with the design.

It would be nice to have the ability to apply various styles to the text along the path, if that can be done cheaply (I have some doubts that it could be done cheaplym and I could live without it).

This would help to support #1831 and possibly #15501

@haralduna

This comment has been minimized.

Copy link

@haralduna haralduna commented Apr 17, 2018

I find Flutter really interesting and I about to rewrite an Android application (https://kinsmap.com) to Flutter. I am using draw text on path extensively, and I would need this function. I may be able to contribute to the implementation as well, but I have no Flutter specific experience.

@dnfield dnfield changed the title Support drawing text along a path Support drawing text along a (curved) path Apr 17, 2018
@dnfield dnfield changed the title Support drawing text along a (curved) path Support drawing text along a curved path Apr 17, 2018
@dnfield

This comment has been minimized.

Copy link
Member Author

@dnfield dnfield commented Apr 19, 2018

As I've looked at this, it seems like somewhere along the way there should be a sibling class to Paragraph for non-linearly laid out text. This could end up using the Skia method to render the glyphs using the drawTextOnPath method instead of the drawTextBlob that's currently used to render multi-styled runs. This could still use the HarfBuzz shaped glyphs - but I'm not entirely clear on how that would get supported (whether there's enough exposed already in libtxt or whether libtxt would need some additional plumbing). My sense so far is that it would probably make sense to extend libtxt to support this as well.

@dnfield

This comment has been minimized.

Copy link
Member Author

@dnfield dnfield commented May 17, 2018

@jason-simmons - Could I get your thoughts on making some changes in libtxt to support this? It seems to me like that would make the most sense - have a class for laying our text that doesn't do line breaking, and could be used to call drawTextOnPath instead of drawTextBlob seems to make the most sense to me. It could potentially leverage existing logic in libtxt for styling and Harfbuzz interfaces.

What do you think?

@dnfield

This comment has been minimized.

Copy link
Member Author

@dnfield dnfield commented May 27, 2018

Another way to do this: add a Path to TextStyle that, if set, corresponds to an SkPath on libtxt's TextStyle, which (if set), would somehow use drawTextOnPath rather than drawTextBlob.

@hnvn

This comment has been minimized.

Copy link

@hnvn hnvn commented Jul 17, 2018

Hi, is there anything new about this feature?

@dnfield

This comment has been minimized.

Copy link
Member Author

@dnfield dnfield commented Jul 18, 2018

I see this as related to #18656 (comment) at this point.

I think it'd be good to have an API for drawing non-wordbroken text on Canvases, whether on a path or not.

@jan-tosovsky-cz

This comment has been minimized.

Copy link

@jan-tosovsky-cz jan-tosovsky-cz commented Oct 23, 2018

Just FYI, Skia's drawTextOnPath method has been removed, see https://groups.google.com/forum/#!topic/skia-discuss/971LXXfT1o0
However, there is some replacement.

@Tyxz

This comment has been minimized.

Copy link

@Tyxz Tyxz commented Apr 13, 2019

@jan-tosovsky-cz What is the replacement in flutter? Or better: How to do that: " it was entirely reimplemented recently in SkTextOnPath.[h,cpp], so you should feel free to copy those files into your project(s) directly."
I can't figure out how to include a cpp into dart.

@ayalma

This comment has been minimized.

Copy link

@ayalma ayalma commented Apr 30, 2019

I think I need it too

@ride4sun

This comment has been minimized.

Copy link

@ride4sun ride4sun commented May 20, 2019

me too...

@Hixie Hixie added this to the Stretch Goals milestone Jun 11, 2019
@Hixie Hixie changed the title Support drawing text along a curved path Support drawing text along a curved path and on a mesh Jul 11, 2019
@Hixie Hixie modified the milestones: Stretch Goals, New Stretch Goals Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.