From 771469cdd4fc9734827491b1425f437dbcbb8126 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 30 Dec 2025 17:03:14 +0100 Subject: [PATCH] re-enable old behavior --- .../lib/src/build_system/targets/assets.dart | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/lib/src/build_system/targets/assets.dart b/packages/flutter_tools/lib/src/build_system/targets/assets.dart index adcc5526181..c166466c81a 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/assets.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/assets.dart @@ -12,7 +12,7 @@ import '../../base/file_system.dart'; import '../../build_info.dart'; import '../../dart/package_map.dart'; import '../../devfs.dart'; -import '../../flutter_manifest.dart' hide FontAsset; +import '../../flutter_manifest.dart' show AssetTransformerEntry; import '../../isolated/native_assets/dart_hook_result.dart'; import '../build_system.dart'; import '../depfile.dart'; @@ -73,6 +73,15 @@ Future copyAssets( ]; final outputs = []; + final iconTreeShaker = IconTreeShaker( + environment, + assetBundle.entries[kFontManifestJson]?.content as DevFSStringContent?, + processManager: environment.processManager, + logger: environment.logger, + fileSystem: environment.fileSystem, + artifacts: environment.artifacts, + targetPlatform: targetPlatform, + ); final shaderCompiler = ShaderCompiler( processManager: environment.processManager, logger: environment.logger, @@ -148,8 +157,11 @@ Future copyAssets( } } case AssetKind.font: - // stop bundling any fonts for now - doCopy = false; + doCopy = !await iconTreeShaker.subsetFont( + input: content.file as File, + outputPath: file.path, + relativePath: entry.key, + ); case AssetKind.shader: doCopy = !await shaderCompiler.compileShader( input: content.file as File, @@ -214,6 +226,13 @@ Future copyAssets( final DevFSContent content = entry.value.content; if (content is DevFSFileContent && content.file is File) { inputs.add(content.file as File); + if (!await iconTreeShaker.subsetFont( + input: content.file as File, + outputPath: file.path, + relativePath: entry.key, + )) { + await (content.file as File).copy(file.path); + } } else { await file.writeAsBytes(await entry.value.contentsAsBytes()); } @@ -225,7 +244,8 @@ Future copyAssets( }), ); } - return Depfile(inputs + assetBundle.additionalDependencies, outputs); + final depfile = Depfile(inputs + assetBundle.additionalDependencies, outputs); + return depfile; } /// Copy the assets defined in the flutter manifest into a build directory.