Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7782845e
Unverified
Commit
7782845e
authored
Jul 24, 2020
by
Will Larche
Committed by
GitHub
Jul 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Material] Updated icons and fonts (#61778)
parent
5142a304
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16107 additions
and
2029 deletions
+16107
-2029
material_fonts.version
bin/internal/material_fonts.version
+1
-1
apk_utils.dart
dev/devicelab/lib/framework/apk_utils.dart
+1
-1
update_icons.dart
dev/tools/update_icons.dart
+117
-50
icons.dart
packages/flutter/lib/src/material/icons.dart
+15976
-1969
font_loader.dart
packages/flutter/lib/src/services/font_loader.dart
+1
-1
icon_tree_shaker.dart
..._tools/lib/src/build_system/targets/icon_tree_shaker.dart
+4
-0
material_fonts.yaml
packages/flutter_tools/schema/material_fonts.yaml
+1
-1
icon_tree_shaker_test.dart
...ral.shard/build_system/targets/icon_tree_shaker_test.dart
+6
-6
No files found.
bin/internal/material_fonts.version
View file @
7782845e
flutter_infra/flutter/fonts/
13ac995daa9dda0a6ba0a45f1fccc541e616a74c
/fonts.zip
flutter_infra/flutter/fonts/
75d35d37aa818c40ffb521a8165dbe7d3c1cb8c4
/fonts.zip
dev/devicelab/lib/framework/apk_utils.dart
View file @
7782845e
...
...
@@ -12,7 +12,7 @@ import 'package:flutter_devicelab/framework/utils.dart';
final
List
<
String
>
flutterAssets
=
<
String
>[
'assets/flutter_assets/AssetManifest.json'
,
'assets/flutter_assets/NOTICES'
,
'assets/flutter_assets/fonts/MaterialIcons-Regular.
t
tf'
,
'assets/flutter_assets/fonts/MaterialIcons-Regular.
o
tf'
,
'assets/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf'
,
];
...
...
dev/tools/update_icons.dart
View file @
7782845e
...
...
@@ -11,19 +11,23 @@ import 'dart:io';
import
'package:args/args.dart'
;
import
'package:path/path.dart'
as
path
;
const
String
kOptionCodepointsPath
=
'codepoints'
;
const
String
kOptionIconsPath
=
'icons'
;
const
String
kOptionDryRun
=
'dry-run'
;
const
String
_newCodepointsPathOption
=
'new-codepoints'
;
const
String
_oldCodepointsPathOption
=
'old-codepoints'
;
const
String
_iconsClassPathOption
=
'icons'
;
const
String
_dryRunOption
=
'dry-run'
;
const
String
kDefaultCodepointsPath
=
'bin/cache/artifacts/material_fonts/codepoints'
;
const
String
kDefaultIconsPath
=
'packages/flutter/lib/src/material/icons.dart'
;
const
String
_defaultNewCodepointsPath
=
'codepoints'
;
const
String
_defaultOldCodepointsPath
=
'bin/cache/artifacts/material_fonts/codepoints'
;
const
String
_defaultIconsPath
=
'packages/flutter/lib/src/material/icons.dart'
;
const
String
kB
eginGeneratedMark
=
'// BEGIN GENERATED'
;
const
String
kE
ndGeneratedMark
=
'// END GENERATED'
;
const
String
_b
eginGeneratedMark
=
'// BEGIN GENERATED'
;
const
String
_e
ndGeneratedMark
=
'// END GENERATED'
;
const
Map
<
String
,
String
>
kI
dentifierRewrites
=
<
String
,
String
>{
const
Map
<
String
,
String
>
_i
dentifierRewrites
=
<
String
,
String
>{
'360'
:
'threesixty'
,
'3d_rotation'
:
'threed_rotation'
,
'6_ft'
:
'six_ft'
,
'5g'
:
'five_g'
,
'1k'
:
'one_k'
,
'2k'
:
'two_k'
,
'3k'
:
'three_k'
,
...
...
@@ -68,10 +72,9 @@ const Map<String, String> kIdentifierRewrites = <String, String>{
'23mp'
:
'twenty_three_mp'
,
'24mp'
:
'twenty_four_mp'
,
'class'
:
'class_'
,
};
const
Set
<
String
>
kM
irroredIcons
=
<
String
>{
const
Set
<
String
>
_m
irroredIcons
=
<
String
>{
// This list is obtained from:
// http://google.github.io/material-design-icons/#icons-in-rtl
'arrow_back'
,
...
...
@@ -152,44 +155,90 @@ void main(List<String> args) {
if
(
path
.
basename
(
Directory
.
current
.
path
)
==
'tools'
)
Directory
.
current
=
Directory
.
current
.
parent
.
parent
;
final
ArgParser
argParser
=
ArgParser
();
argParser
.
addOption
(
kOptionCodepointsPath
,
defaultsTo:
kDefaultCodepointsPath
);
argParser
.
addOption
(
kOptionIconsPath
,
defaultsTo:
kDefaultIconsPath
);
argParser
.
addFlag
(
kOptionDryRun
,
defaultsTo:
false
);
final
ArgResults
argResults
=
argParser
.
parse
(
args
);
final
ArgResults
argResults
=
_handleArguments
(
args
);
final
File
iconFile
=
File
(
path
.
absolute
(
argResults
[
kOptionIconsPath
]
as
String
));
if
(!
iconFile
.
existsSync
())
{
stderr
.
writeln
(
'Icons file not found:
${iconFile.path}
'
);
final
File
iconClassFile
=
File
(
path
.
normalize
(
path
.
absolute
(
argResults
[
_iconsClassPathOption
]
as
String
)));
if
(!
iconClassFile
.
existsSync
())
{
stderr
.
writeln
(
'Error: Icons file not found:
${iconClassFile.path}
'
);
exit
(
1
);
}
final
File
newCodepointsFile
=
File
(
path
.
absolute
(
path
.
normalize
(
argResults
[
_newCodepointsPathOption
]
as
String
)));
if
(!
newCodepointsFile
.
existsSync
())
{
stderr
.
writeln
(
'Error: New codepoints file not found:
${newCodepointsFile.path}
'
);
exit
(
1
);
}
final
File
codepointsFile
=
File
(
path
.
absolute
(
argResults
[
kOptionCodepointsPath
]
as
String
));
if
(!
c
odepointsFile
.
existsSync
())
{
stderr
.
writeln
(
'
Codepoints file not found:
${c
odepointsFile.path}
'
);
final
File
oldCodepointsFile
=
File
(
path
.
absolute
(
argResults
[
_oldCodepointsPathOption
]
as
String
));
if
(!
oldC
odepointsFile
.
existsSync
())
{
stderr
.
writeln
(
'
Error: Old codepoints file not found:
${oldC
odepointsFile.path}
'
);
exit
(
1
);
}
final
String
iconData
=
iconFile
.
readAsStringSync
();
final
String
codepointData
=
codepointsFile
.
readAsStringSync
();
final
String
newIconData
=
regenerateIconsFile
(
iconData
,
codepointData
);
final
String
newCodepointsString
=
newCodepointsFile
.
readAsStringSync
();
final
Map
<
String
,
String
>
newTokenPairMap
=
_stringToTokenPairMap
(
newCodepointsString
);
final
String
oldCodepointsString
=
oldCodepointsFile
.
readAsStringSync
();
final
Map
<
String
,
String
>
oldTokenPairMap
=
_stringToTokenPairMap
(
oldCodepointsString
);
if
(
argResults
[
kOptionDryRun
]
as
bool
)
_testIsMapSuperset
(
newTokenPairMap
,
oldTokenPairMap
);
final
String
iconClassFileData
=
iconClassFile
.
readAsStringSync
();
stderr
.
writeln
(
'Generating new token pairs.'
);
final
String
newIconData
=
_regenerateIconsFile
(
iconClassFileData
,
newTokenPairMap
);
if
(
argResults
[
_dryRunOption
]
as
bool
)
{
stdout
.
writeln
(
newIconData
);
else
iconFile
.
writeAsStringSync
(
newIconData
);
}
else
{
stderr
.
writeln
(
'
\n
Writing to
${iconClassFile.path}
.'
);
iconClassFile
.
writeAsStringSync
(
newIconData
);
_cleanUpFiles
(
newCodepointsFile
,
oldCodepointsFile
);
}
}
String
regenerateIconsFile
(
String
iconData
,
String
codepointData
)
{
ArgResults
_handleArguments
(
List
<
String
>
args
)
{
final
ArgParser
argParser
=
ArgParser
()
..
addOption
(
_newCodepointsPathOption
,
defaultsTo:
_defaultNewCodepointsPath
)
..
addOption
(
_oldCodepointsPathOption
,
defaultsTo:
_defaultOldCodepointsPath
)
..
addOption
(
_iconsClassPathOption
,
defaultsTo:
_defaultIconsPath
)
..
addFlag
(
_dryRunOption
,
defaultsTo:
false
);
return
argParser
.
parse
(
args
);
}
Map
<
String
,
String
>
_stringToTokenPairMap
(
String
codepointData
)
{
final
Iterable
<
String
>
cleanData
=
LineSplitter
.
split
(
codepointData
)
.
map
((
String
line
)
=>
line
.
trim
())
.
where
((
String
line
)
=>
line
.
isNotEmpty
);
final
Map
<
String
,
String
>
pairs
=
<
String
,
String
>{};
for
(
final
String
line
in
cleanData
)
{
final
List
<
String
>
tokens
=
line
.
split
(
' '
);
if
(
tokens
.
length
!=
2
)
{
throw
FormatException
(
'Unexpected codepoint data:
$line
'
);
}
pairs
.
putIfAbsent
(
tokens
[
0
],
()
=>
tokens
[
1
]);
}
return
pairs
;
}
String
_regenerateIconsFile
(
String
iconData
,
Map
<
String
,
String
>
tokenPairMap
)
{
final
StringBuffer
buf
=
StringBuffer
();
bool
generating
=
false
;
for
(
final
String
line
in
LineSplitter
.
split
(
iconData
))
{
if
(!
generating
)
if
(!
generating
)
{
buf
.
writeln
(
line
);
if
(
line
.
contains
(
kBeginGeneratedMark
))
{
}
if
(
line
.
contains
(
_beginGeneratedMark
))
{
generating
=
true
;
final
String
iconDeclarations
=
generateIconDeclarations
(
codepointData
);
buf
.
write
(
iconDeclarations
);
}
else
if
(
line
.
contains
(
kEndGeneratedMark
))
{
final
String
iconDeclarationsString
=
<
String
>[
for
(
MapEntry
<
String
,
String
>
entry
in
tokenPairMap
.
entries
)
_generateDeclaration
(
entry
)
].
join
();
buf
.
write
(
iconDeclarationsString
);
}
else
if
(
line
.
contains
(
_endGeneratedMark
))
{
generating
=
false
;
buf
.
writeln
(
line
);
}
...
...
@@ -197,26 +246,44 @@ String regenerateIconsFile(String iconData, String codepointData) {
return
buf
.
toString
();
}
String
generateIconDeclarations
(
String
codepointData
)
{
return
LineSplitter
.
split
(
codepointData
)
.
map
<
String
>((
String
l
)
=>
l
.
trim
())
.
where
((
String
l
)
=>
l
.
isNotEmpty
)
.
map
<
String
>(
getIconDeclaration
)
.
join
();
void
_testIsMapSuperset
(
Map
<
String
,
String
>
newCodepoints
,
Map
<
String
,
String
>
oldCodepoints
)
{
final
Set
<
String
>
newCodepointsSet
=
newCodepoints
.
keys
.
toSet
();
final
Set
<
String
>
oldCodepointsSet
=
oldCodepoints
.
keys
.
toSet
();
if
(!
newCodepointsSet
.
containsAll
(
oldCodepointsSet
))
{
stderr
.
writeln
(
'''Error: New codepoints file does not contain all the existing codepoints.
\n
Missing:
${oldCodepointsSet.difference(newCodepointsSet)}
'''
,
);
exit
(
1
);
}
}
String
getIconDeclaration
(
String
line
)
{
final
List
<
String
>
tokens
=
line
.
split
(
' '
);
if
(
tokens
.
length
!=
2
)
throw
FormatException
(
'Unexpected codepoint data:
$line
'
);
final
String
name
=
tokens
[
0
];
final
String
codepoint
=
tokens
[
1
];
final
String
identifier
=
kIdentifierRewrites
[
name
]
??
name
;
final
String
description
=
name
.
replaceAll
(
'_'
,
' '
);
final
String
rtl
=
kMirroredIcons
.
contains
(
name
)
?
', matchTextDirection: true'
:
''
;
String
_generateDeclaration
(
MapEntry
<
String
,
String
>
tokenPair
)
{
final
String
identifier
=
_generateIdentifier
(
tokenPair
.
key
);
final
String
description
=
tokenPair
.
key
.
replaceAll
(
'_'
,
' '
);
final
String
rtl
=
_mirroredIcons
.
contains
(
tokenPair
.
key
)
?
', matchTextDirection: true'
:
''
;
return
'''
/// <i class="material-icons md-36">
$
name
</i> — material icon named "
$description
".
static const IconData
$identifier
= IconData(0x
$
codepoint
, fontFamily: '
MaterialIcons
'
$rtl
);
/// <i class="material-icons md-36">
$
{tokenPair.key}
</i> — material icon named "
$description
".
static const IconData
$identifier
= IconData(0x
$
{tokenPair.value}
, fontFamily: '
MaterialIcons
'
$rtl
);
'''
;
}
String
_generateIdentifier
(
String
rawIdentifier
)
{
for
(
final
MapEntry
<
String
,
String
>
rewritePair
in
_identifierRewrites
.
entries
)
{
if
(
rawIdentifier
.
startsWith
(
rewritePair
.
key
))
{
return
rawIdentifier
.
replaceFirst
(
rewritePair
.
key
,
_identifierRewrites
[
rewritePair
.
key
]);
}
}
return
rawIdentifier
;
}
// Replace the old codepoints file with the new.
void
_cleanUpFiles
(
File
newCodepointsFile
,
File
oldCodepointsFile
)
{
stderr
.
writeln
(
'
\n
Moving new codepoints file to
${oldCodepointsFile.path}
.
\n
'
);
newCodepointsFile
.
renameSync
(
oldCodepointsFile
.
path
);
}
packages/flutter/lib/src/material/icons.dart
View file @
7782845e
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/services/font_loader.dart
View file @
7782845e
...
...
@@ -34,7 +34,7 @@ class FontLoader {
/// Registers a font asset to be loaded by this font loader.
///
/// The [bytes] argument specifies the actual font asset bytes. Currently,
/// only TrueType (TTF) fonts are supported.
/// only
OpenType (OTF) and
TrueType (TTF) fonts are supported.
void
addFont
(
Future
<
ByteData
>
bytes
)
{
if
(
_loaded
)
throw
StateError
(
'FontLoader is already loaded'
);
...
...
packages/flutter_tools/lib/src/build_system/targets/icon_tree_shaker.dart
View file @
7782845e
...
...
@@ -69,6 +69,10 @@ class IconTreeShaker {
/// The MIME type for ttf fonts.
static
const
Set
<
String
>
kTtfMimeTypes
=
<
String
>{
'font/ttf'
,
// based on internet search
'font/opentype'
,
'font/otf'
,
'application/x-font-opentype'
,
'application/x-font-otf'
,
'application/x-font-ttf'
,
// based on running locally.
};
...
...
packages/flutter_tools/schema/material_fonts.yaml
View file @
7782845e
material
:
-
family
:
MaterialIcons
fonts
:
-
asset
:
fonts/MaterialIcons-Regular.
t
tf
-
asset
:
fonts/MaterialIcons-Regular.
o
tf
packages/flutter_tools/test/general.shard/build_system/targets/icon_tree_shaker_test.dart
View file @
7782845e
...
...
@@ -30,9 +30,9 @@ const String dartPath = '/flutter/dart';
const
String
constFinderPath
=
'/flutter/const_finder.snapshot.dart'
;
const
String
fontSubsetPath
=
'/flutter/font-subset'
;
const
String
inputPath
=
'/input/fonts/MaterialIcons-Regular.
t
tf'
;
const
String
outputPath
=
'/output/fonts/MaterialIcons-Regular.
t
tf'
;
const
String
relativePath
=
'fonts/MaterialIcons-Regular.
t
tf'
;
const
String
inputPath
=
'/input/fonts/MaterialIcons-Regular.
o
tf'
;
const
String
outputPath
=
'/output/fonts/MaterialIcons-Regular.
o
tf'
;
const
String
relativePath
=
'fonts/MaterialIcons-Regular.
o
tf'
;
List
<
String
>
getConstFinderArgs
(
String
appDillPath
)
=>
<
String
>[
dartPath
,
...
...
@@ -270,7 +270,7 @@ void main() {
verify
(
mockProcessManager
.
start
(
fontSubsetArgs
)).
called
(
2
);
});
testWithoutContext
(
'Does not subset a non-
ttf
font'
,
()
async
{
testWithoutContext
(
'Does not subset a non-
supported
font'
,
()
async
{
final
Environment
environment
=
_createEnvironment
(<
String
,
String
>{
kIconTreeShakerFlag:
'true'
,
kBuildMode:
'release'
,
...
...
@@ -553,7 +553,7 @@ const String validFontManifestJson = '''
"family": "MaterialIcons",
"fonts": [
{
"asset": "fonts/MaterialIcons-Regular.
t
tf"
"asset": "fonts/MaterialIcons-Regular.
o
tf"
}
]
},
...
...
@@ -581,7 +581,7 @@ const String invalidFontManifestJson = '''
"famly": "MaterialIcons",
"fonts": [
{
"asset": "fonts/MaterialIcons-Regular.
t
tf"
"asset": "fonts/MaterialIcons-Regular.
o
tf"
}
]
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment