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
d4bc6d5e
Commit
d4bc6d5e
authored
Mar 25, 2016
by
Jason Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add all variants of the Roboto font as assets to Material Design apps
parent
b070be22
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
35 deletions
+118
-35
material_fonts.version
bin/cache/material_fonts.version
+1
-1
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+2
-1
build_apk.dart
packages/flutter_tools/lib/src/commands/build_apk.dart
+4
-1
build_flx.dart
packages/flutter_tools/lib/src/commands/build_flx.dart
+3
-1
flx.dart
packages/flutter_tools/lib/src/flx.dart
+57
-31
material_fonts.yaml
packages/flutter_tools/schema/material_fonts.yaml
+51
-0
No files found.
bin/cache/material_fonts.version
View file @
d4bc6d5e
https://storage.googleapis.com/flutter_infra/flutter/fonts/
b1e27075635f686ce12784a90125de693b4c360c
/fonts.zip
https://storage.googleapis.com/flutter_infra/flutter/fonts/
1f5dd1af1b8e0672c7303a2f6197a29375ad1385
/fonts.zip
packages/flutter_tools/lib/src/android/android_device.dart
View file @
d4bc6d5e
...
...
@@ -286,7 +286,8 @@ class AndroidDevice extends Device {
String
localBundlePath
=
await
flx
.
buildFlx
(
toolchain
,
mainPath:
mainPath
mainPath:
mainPath
,
includeRobotoFonts:
false
);
printTrace
(
'Starting bundle for
$this
.'
);
...
...
packages/flutter_tools/lib/src/commands/build_apk.dart
View file @
d4bc6d5e
...
...
@@ -435,7 +435,10 @@ Future<int> buildAndroid(
}
else
{
// Find the path to the main Dart file; build the FLX.
String
mainPath
=
findMainDartFile
(
target
);
String
localBundlePath
=
await
flx
.
buildFlx
(
toolchain
,
mainPath:
mainPath
);
String
localBundlePath
=
await
flx
.
buildFlx
(
toolchain
,
mainPath:
mainPath
,
includeRobotoFonts:
false
);
return
_buildApk
(
platform
,
components
,
localBundlePath
,
keystore
,
outputFile
);
}
...
...
packages/flutter_tools/lib/src/commands/build_flx.dart
View file @
d4bc6d5e
...
...
@@ -23,6 +23,7 @@ class BuildFlxCommand extends FlutterCommand {
argParser
.
addOption
(
'snapshot'
,
defaultsTo:
defaultSnapshotPath
);
argParser
.
addOption
(
'depfile'
,
defaultsTo:
defaultDepfilePath
);
argParser
.
addOption
(
'working-dir'
,
defaultsTo:
defaultWorkingDirPath
);
argParser
.
addFlag
(
'include-roboto-fonts'
,
defaultsTo:
true
);
usesPubOption
();
}
...
...
@@ -56,7 +57,8 @@ class BuildFlxCommand extends FlutterCommand {
depfilePath:
argResults
[
'depfile'
],
privateKeyPath:
argResults
[
'private-key'
],
workingDirPath:
argResults
[
'working-dir'
],
precompiledSnapshot:
argResults
[
'precompiled'
]
precompiledSnapshot:
argResults
[
'precompiled'
],
includeRobotoFonts:
argResults
[
'include-roboto-fonts'
]
).
then
((
int
result
)
{
if
(
result
==
0
)
printStatus
(
'Built
$outputPath
.'
);
...
...
packages/flutter_tools/lib/src/flx.dart
View file @
d4bc6d5e
...
...
@@ -29,6 +29,9 @@ const String defaultWorkingDirPath = 'build/flx';
const
String
_kSnapshotKey
=
'snapshot_blob.bin'
;
const
String
_kFontSetMaterial
=
'material'
;
const
String
_kFontSetRoboto
=
'roboto'
;
class
_Asset
{
final
String
source
;
final
String
base
;
...
...
@@ -37,25 +40,34 @@ class _Asset {
_Asset
({
this
.
source
,
this
.
base
,
this
.
key
});
}
const
String
_kMaterialIconsKey
=
'fonts/MaterialIcons-Regular.ttf'
;
Map
<
String
,
dynamic
>
_readMaterialFontsManifest
()
{
String
fontsPath
=
path
.
join
(
path
.
absolute
(
ArtifactStore
.
flutterRoot
),
'packages'
,
'flutter_tools'
,
'schema'
,
'material_fonts.yaml'
);
List
<
Map
<
String
,
dynamic
>>
_getMaterialFonts
()
{
return
[{
'family'
:
'MaterialIcons'
,
'fonts'
:
[{
'asset'
:
_kMaterialIconsKey
}]
}];
return
loadYaml
(
new
File
(
fontsPath
).
readAsStringSync
());
}
List
<
_Asset
>
_getMaterialAssets
()
{
return
<
_Asset
>[
new
_Asset
(
base:
'
${ArtifactStore.flutterRoot}
/bin/cache/artifacts/material_fonts'
,
source
:
'MaterialIcons-Regular.ttf'
,
key:
_kMaterialIconsKey
)
];
final
Map
<
String
,
dynamic
>
_materialFontsManifest
=
_readMaterialFontsManifest
();
List
<
Map
<
String
,
dynamic
>>
_getMaterialFonts
(
String
fontSet
)
{
return
_materialFontsManifest
[
fontSet
];
}
List
<
_Asset
>
_getMaterialAssets
(
String
fontSet
)
{
List
<
_Asset
>
result
=
<
_Asset
>[];
for
(
Map
<
String
,
dynamic
>
family
in
_getMaterialFonts
(
fontSet
))
{
for
(
Map
<
String
,
dynamic
>
font
in
family
[
'fonts'
])
{
String
assetKey
=
font
[
'asset'
];
result
.
add
(
new
_Asset
(
base:
'
${ArtifactStore.flutterRoot}
/bin/cache/artifacts/material_fonts'
,
source
:
path
.
basename
(
assetKey
),
key:
assetKey
));
}
}
return
result
;
}
Map
<
_Asset
,
List
<
_Asset
>>
_parseAssets
(
Map
<
String
,
dynamic
>
manifestDescriptor
,
String
assetBase
)
{
...
...
@@ -144,10 +156,15 @@ ZipEntry _createAssetManifest(Map<_Asset, List<_Asset>> assets) {
return
new
ZipEntry
.
fromString
(
'AssetManifest.json'
,
JSON
.
encode
(
json
));
}
ZipEntry
_createFontManifest
(
Map
<
String
,
dynamic
>
manifestDescriptor
,
List
<
Map
<
String
,
dynamic
>>
additionalFonts
)
{
ZipEntry
_createFontManifest
(
Map
<
String
,
dynamic
>
manifestDescriptor
,
bool
usesMaterialDesign
,
bool
includeRobotoFonts
)
{
List
<
Map
<
String
,
dynamic
>>
fonts
=
<
Map
<
String
,
dynamic
>>[];
if
(
additionalFonts
!=
null
)
fonts
.
addAll
(
additionalFonts
);
if
(
usesMaterialDesign
)
{
fonts
.
addAll
(
_getMaterialFonts
(
_kFontSetMaterial
));
if
(
includeRobotoFonts
)
fonts
.
addAll
(
_getMaterialFonts
(
_kFontSetRoboto
));
}
if
(
manifestDescriptor
!=
null
&&
manifestDescriptor
.
containsKey
(
'fonts'
))
fonts
.
addAll
(
manifestDescriptor
[
'fonts'
]);
if
(
fonts
.
isEmpty
)
...
...
@@ -158,7 +175,8 @@ ZipEntry _createFontManifest(Map<String, dynamic> manifestDescriptor, List<Map<S
/// Build the flx in the build/ directory and return `localBundlePath` on success.
Future
<
String
>
buildFlx
(
Toolchain
toolchain
,
{
String
mainPath:
defaultMainPath
String
mainPath:
defaultMainPath
,
bool
includeRobotoFonts:
true
})
async
{
int
result
;
String
localBundlePath
=
path
.
join
(
'build'
,
'app.flx'
);
...
...
@@ -167,7 +185,8 @@ Future<String> buildFlx(
toolchain
,
snapshotPath:
localSnapshotPath
,
outputPath:
localBundlePath
,
mainPath:
mainPath
mainPath:
mainPath
,
includeRobotoFonts:
includeRobotoFonts
);
if
(
result
==
0
)
return
localBundlePath
;
...
...
@@ -197,7 +216,8 @@ Future<int> build(
String
depfilePath:
defaultDepfilePath
,
String
privateKeyPath:
defaultPrivateKeyPath
,
String
workingDirPath:
defaultWorkingDirPath
,
bool
precompiledSnapshot:
false
bool
precompiledSnapshot:
false
,
bool
includeRobotoFonts:
true
})
async
{
Object
manifest
=
_loadManifest
(
manifestPath
);
if
(
manifest
!=
null
)
{
...
...
@@ -235,7 +255,8 @@ Future<int> build(
assetBasePath:
assetBasePath
,
outputPath:
outputPath
,
privateKeyPath:
privateKeyPath
,
workingDirPath:
workingDirPath
workingDirPath:
workingDirPath
,
includeRobotoFonts:
includeRobotoFonts
);
}
...
...
@@ -245,7 +266,8 @@ Future<int> assemble({
String
assetBasePath:
defaultAssetBasePath
,
String
outputPath:
defaultFlxOutputPath
,
String
privateKeyPath:
defaultPrivateKeyPath
,
String
workingDirPath:
defaultWorkingDirPath
String
workingDirPath:
defaultWorkingDirPath
,
bool
includeRobotoFonts:
true
})
async
{
printTrace
(
'Building
$outputPath
'
);
...
...
@@ -272,18 +294,22 @@ Future<int> assemble({
}
}
List
<
_Asset
>
materialAssets
=
<
_Asset
>[];
if
(
usesMaterialDesign
)
{
for
(
_Asset
asset
in
_getMaterialAssets
())
{
ZipEntry
assetEntry
=
_createAssetEntry
(
asset
);
if
(
assetEntry
==
null
)
return
1
;
zipBuilder
.
addEntry
(
assetEntry
);
}
materialAssets
.
addAll
(
_getMaterialAssets
(
_kFontSetMaterial
));
if
(
includeRobotoFonts
)
materialAssets
.
addAll
(
_getMaterialAssets
(
_kFontSetRoboto
));
}
for
(
_Asset
asset
in
materialAssets
)
{
ZipEntry
assetEntry
=
_createAssetEntry
(
asset
);
if
(
assetEntry
==
null
)
return
1
;
zipBuilder
.
addEntry
(
assetEntry
);
}
zipBuilder
.
addEntry
(
_createAssetManifest
(
assets
));
ZipEntry
fontManifest
=
_createFontManifest
(
manifestDescriptor
,
usesMaterialDesign
?
_getMaterialFonts
()
:
null
);
ZipEntry
fontManifest
=
_createFontManifest
(
manifestDescriptor
,
usesMaterialDesign
,
includeRobotoFonts
);
if
(
fontManifest
!=
null
)
zipBuilder
.
addEntry
(
fontManifest
);
...
...
packages/flutter_tools/schema/material_fonts.yaml
0 → 100644
View file @
d4bc6d5e
material
:
-
family
:
MaterialIcons
fonts
:
-
asset
:
fonts/MaterialIcons-Regular.ttf
roboto
:
-
family
:
Roboto
fonts
:
-
asset
:
fonts/Roboto-Regular.ttf
-
asset
:
fonts/Roboto-Italic.ttf
style
:
italic
-
asset
:
fonts/Roboto-Thin.ttf
weight
:
100
-
asset
:
fonts/Roboto-ThinItalic.ttf
weight
:
100
style
:
italic
-
asset
:
fonts/Roboto-Light.ttf
weight
:
300
-
asset
:
fonts/Roboto-LightItalic.ttf
weight
:
300
style
:
italic
-
asset
:
fonts/Roboto-Medium.ttf
weight
:
500
-
asset
:
fonts/Roboto-MediumItalic.ttf
weight
:
500
style
:
italic
-
asset
:
fonts/Roboto-Bold.ttf
weight
:
700
-
asset
:
fonts/Roboto-BoldItalic.ttf
weight
:
700
style
:
italic
-
asset
:
fonts/Roboto-Black.ttf
weight
:
900
-
asset
:
fonts/Roboto-BlackItalic.ttf
weight
:
900
style
:
italic
-
family
:
RobotoCondensed
fonts
:
-
asset
:
fonts/RobotoCondensed-Regular.ttf
-
asset
:
fonts/RobotoCondensed-Italic.ttf
style
:
italic
-
asset
:
fonts/RobotoCondensed-Light.ttf
weight
:
300
-
asset
:
fonts/RobotoCondensed-LightItalic.ttf
weight
:
300
style
:
italic
-
asset
:
fonts/RobotoCondensed-Bold.ttf
weight
:
700
-
asset
:
fonts/RobotoCondensed-BoldItalic.ttf
weight
:
700
style
:
italic
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