Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion guides/typography.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ To get started, you first include the `Roboto` font with the 300, 400 and 500 we
You can host it yourself or include it from [Google Fonts][2]:

```html
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
```

Now you can add the appropriate CSS classes to the elements that you want to style:
Expand Down
3 changes: 2 additions & 1 deletion src/dev-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
<base href="/">

<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="theme.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">

<script>
if (window.customElements) {
Expand Down
3 changes: 2 additions & 1 deletion src/e2e-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<base href="/">

<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="theme.css" rel="stylesheet">

<!-- FontAwesome for mat-icon demo. -->
Expand Down
11 changes: 7 additions & 4 deletions src/material/schematics/ng-add/fonts/material-fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ export function addFontsToIndex(options: Schema): Rule {
throw new SchematicsException('No project index HTML file could be found.');
}

const preconnect = `<link rel="preconnect" href="https://fonts.gstatic.com">`;
const fonts = [
'https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap',
'https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap',
'https://fonts.googleapis.com/icon?family=Material+Icons',
];

fonts.forEach(f => {
projectIndexFiles.forEach(indexFilePath => {
appendHtmlElementToHead(host, indexFilePath, `<link href="${f}" rel="stylesheet">`);
projectIndexFiles.forEach(indexFilePath => {
appendHtmlElementToHead(host, indexFilePath, preconnect);

fonts.forEach(font => {
appendHtmlElementToHead(host, indexFilePath, `<link href="${font}" rel="stylesheet">`);
});
});
};
Expand Down
6 changes: 4 additions & 2 deletions src/material/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ describe('ng-add schematic', () => {
// Ensure that the indentation has been determined properly. We want to make sure that
// the created links properly align with the existing HTML. Default CLI projects use an
// indentation of two columns.
expect(htmlContent)
.toContain(' <link rel="preconnect" href="https://fonts.gstatic.com">');
expect(htmlContent)
.toContain(' <link href="https://fonts.googleapis.com/icon?family=Material+Icons"');
expect(htmlContent)
.toContain(
' <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap"');
.toContain(' <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@' +
'300;400;500&display=swap"');
});
});

Expand Down
3 changes: 2 additions & 1 deletion src/universal-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Angular Material Universal Kitchen Sink Test</title>
<link href="theme.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<base href="/">

<style>
Expand Down