Skip to content
Snippets Groups Projects
Unverified Commit 50b5b418 authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub
Browse files

Merge pull request #4425 from paulkaplan/faster-text-tile-rendering

Use fontInliner instead of entire SVGRenderer for showing costume tiles.
parents d7549bec a37ea675
No related branches found
No related tags found
No related merge requests found
import storage from './storage';
import {SVGRenderer} from 'scratch-svg-renderer';
import {inlineSvgFonts} from 'scratch-svg-renderer';
// Contains 'font-family', but doesn't only contain 'font-family="none"'
const HAS_FONT_REGEXP = 'font-family(?!="none")';
......@@ -21,9 +21,7 @@ const getCostumeUrl = (function () {
if (asset.assetType === storage.AssetType.ImageVector) {
const svgString = asset.decodeText();
if (svgString.match(HAS_FONT_REGEXP)) {
const svgRenderer = new SVGRenderer();
svgRenderer.loadString(svgString);
const svgText = svgRenderer.toString(true /* shouldInjectFonts */);
const svgText = inlineSvgFonts(svgString);
cachedUrl = `data:image/svg+xml;utf8,${encodeURIComponent(svgText)}`;
} else {
cachedUrl = asset.encodeDataURI();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment