diff --git a/lib/src/rive_text.dart b/lib/src/rive_text.dart index 0e2eb12..f7a4c83 100644 --- a/lib/src/rive_text.dart +++ b/lib/src/rive_text.dart @@ -274,14 +274,31 @@ class TextRun { ); @override - toString() => 'TextRun($fontSize:$unicharCount:$styleId)'; + String toString() => 'TextRun($fontSize:$unicharCount:$styleId)'; } abstract class Font { static Future initialize() => initFont(); - static Font? decode(Uint8List bytes) => decodeFont(bytes); + static Font? decode(Uint8List bytes) { + return decodeFont(bytes); + } + RawPath getPath(int glyphId); void dispose(); TextShapeResult shape(String text, List runs); + + final HashMap _glyphPaths = HashMap(); + ui.Path getUiPath(int glyphId) { + var glyphPath = _glyphPaths[glyphId]; + if (glyphPath != null) { + return glyphPath; + } + var path = ui.Path(); + var rawPath = getPath(glyphId); + rawPath.issueCommands(path); + rawPath.dispose(); + _glyphPaths[glyphId] = path; + return path; + } }