Repository: flutter
Issue: Add an API for Getting Glyph Outlines as Paths
Labels: c: new feature,framework,a: typography,c: proposal,P3,team-engine,triaged-engine

### Use case

There are cases where apps need access to more than just the rendered text glyphs. This is especially common in design software where text glyphs need to be converted into shapes to allow for tweaking them, animating them, or styling them.

Skia for example has getPath:

https://github.com/google/skia/blob/main/include/core/SkFont.h

```cpp
    /** Modifies path to be the outline of the glyph.
        If the glyph has an outline, modifies path to be the glyph's outline and returns true.
        The glyph outline may be empty. Degenerate contours in the glyph outline will be skipped.
        If glyph is described by a bitmap, returns false and ignores path parameter.

        @param glyphID  index of glyph
        @param path     pointer to existing SkPath
        @return         true if glyphID is described by path
     */
    bool getPath(SkGlyphID glyphID, SkPath* path) const;

    /** Returns path corresponding to glyph array.

        @param glyphIDs      array of glyph indices
        @param count         number of glyphs
        @param glyphPathProc function returning one glyph description as path
        @param ctx           function context
   */
    void getPaths(const SkGlyphID glyphIDs[], int count,
                  void (*glyphPathProc)(const SkPath* pathOrNull, const SkMatrix& mx, void* ctx),
                  void* ctx) const;

    /** Returns SkFontMetrics associated with SkTypeface.
        The return value is the recommended spacing between lines: the sum of metrics
        descent, ascent, and leading.
        If metrics is not nullptr, SkFontMetrics is copied to metrics.
        Results are scaled by text size but does not take into account
        dimensions required by text scale, text skew, fake bold,
        style stroke, and SkPathEffect.

        @param metrics  storage for SkFontMetrics; may be nullptr
        @return         recommended spacing between lines
    */
    
 ```

This has come up here before, but I believe is lacking a more specific issue as @Hixie requested:

https://github.com/flutter/flutter/issues/137064

Flutter should expose an API (possibly on TextPainter) to get the paths raw for text. 

### Proposal

Add the ability to get Glyph / Shapes from TextPainter (GlyphInfo already exists but there isn't a nice method for getting the entire list for the current text):


```dart
class GlyphPath {
   /// the glyph corresponding to this path
   final GlyphInfo glyph;
   
   /// the relative placement of this glyph
   final Offset offset;
   
   /// return a Path object for rendering
   Path toPath();
}

List<GlyphPath> getGlyphs()
```

This would suffice for some usecases, but Path lacks some basic ability to read back the path data at the moment if you need to alter it to Path, will need to add the following, mirroring the underlying data from Skia (https://api.skia.org/classSkPath.html), or some equivalent:

```dart

List<PathVerb> getVerbs();
List<Offset> getPoints();

```