Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate fonts to deployment and remove internet requirement #667

Open
SamProf opened this issue Aug 2, 2020 · 3 comments
Open

Integrate fonts to deployment and remove internet requirement #667

SamProf opened this issue Aug 2, 2020 · 3 comments

Comments

@SamProf
Copy link
Owner

SamProf commented Aug 2, 2020

Look at
https://github.com/SamProf/MatBlazor/blob/master/src/MatBlazor/wwwroot/dist/matBlazor.css

You are referencing https://fonts.googleapis.com.

I would consider it a requirement.
These fonts are generated based on the client that is requesting them. It is not a trivial task of just downloading a font file.

Originally posted by @rokx in #610 (comment)

@damianog
Copy link
Contributor

damianog commented Oct 18, 2020

@SamProf , this feature is foundamental on an isolated service from internet.
Maybe you could only add an "offline" version of the style ex: "matBlazorOffline.css" without importing the one from internet and let the final user to embed the one he need.
Actually I embed the roboto fonts and material design icons with libman.json file on the root of my web project:

{
  "version": "1.0",
  "defaultProvider": "unpkg",
  "libraries": [
    {
      "library": "roboto-fontface-material@0.1.0",
      "destination": "wwwroot/roboto-fontface-material/"
    },
    {
      "library": "material-design-icons-iconfont@6.1.0",
      "destination": "wwwroot/material-design-icons-iconfont/",
      "files": [
        "dist/LICENSE",
        "dist/material-design-icons.css",
        "dist/material-design-icons.css.map",
        "dist/fonts/MaterialIcons-Regular.eot",
        "dist/fonts/MaterialIcons-Regular.json",
        "dist/fonts/MaterialIcons-Regular.ttf",
        "dist/fonts/MaterialIcons-Regular.woff",
        "dist/fonts/MaterialIcons-Regular.woff2"
      ]
    }
  ]
}

image

@bihe
Copy link

bihe commented Dec 6, 2020

A rather simple "solution" is to download dist/matBlazor.css and remove the two lines

@import url(https://fonts.googleapis.com/css?family=Roboto:300,400,500);
@import url(https://fonts.googleapis.com/icon?family=Material+Icons);

and reference the "changed" css.

<link href="css/matBlazor.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" /> <!-- custom styles -->

My site.css contains the definitions to use the local fonts

/* roboto-300 - latin */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 300;
  src: url('../fonts/roboto-v20-latin-300.eot'); /* IE9 Compat Modes */
  src: local(''),
       url('../fonts/roboto-v20-latin-300.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('../fonts/roboto-v20-latin-300.woff2') format('woff2'), /* Super Modern Browsers */
       url('../fonts/roboto-v20-latin-300.woff') format('woff'), /* Modern Browsers */
       url('../fonts/roboto-v20-latin-300.ttf') format('truetype'), /* Safari, Android, iOS */
       url('../fonts/roboto-v20-latin-300.svg#Roboto') format('svg'); /* Legacy iOS */
}
/* roboto-regular - latin */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/roboto-v20-latin-regular.eot'); /* IE9 Compat Modes */
  src: local(''),
       url('../fonts/roboto-v20-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('../fonts/roboto-v20-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
       url('../fonts/roboto-v20-latin-regular.woff') format('woff'), /* Modern Browsers */
       url('../fonts/roboto-v20-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
       url('../fonts/roboto-v20-latin-regular.svg#Roboto') format('svg'); /* Legacy iOS */
}
/* roboto-500 - latin */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  src: url('../fonts/roboto-v20-latin-500.eot'); /* IE9 Compat Modes */
  src: local(''),
       url('../fonts/roboto-v20-latin-500.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('../fonts/roboto-v20-latin-500.woff2') format('woff2'), /* Super Modern Browsers */
       url('../fonts/roboto-v20-latin-500.woff') format('woff'), /* Modern Browsers */
       url('../fonts/roboto-v20-latin-500.ttf') format('truetype'), /* Safari, Android, iOS */
       url('../fonts/roboto-v20-latin-500.svg#Roboto') format('svg'); /* Legacy iOS */
}
/* roboto-700 - latin */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/roboto-v20-latin-700.eot'); /* IE9 Compat Modes */
  src: local(''),
       url('../fonts/roboto-v20-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('../fonts/roboto-v20-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
       url('../fonts/roboto-v20-latin-700.woff') format('woff'), /* Modern Browsers */
       url('../fonts/roboto-v20-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
       url('../fonts/roboto-v20-latin-700.svg#Roboto') format('svg'); /* Legacy iOS */
}

/* material icons */
@font-face {
  font-family: 'Material Icons';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/Material-Icons-Regular.woff2') format('woff2');
}

.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
}

I've downloaded Google fonts with help of google-fonts-helper and Material Icons using this trick.

Resulting in "local traffic"

image

@samerios
Copy link

Hi what about this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants