File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
gwt-material/src/main/java/gwt/material/design/client/font Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ public class FontResourceInjector {
3131 private static Font defaultFont ;
3232
3333 public static void inject (Font font ) {
34+ injectGoogleFontLink ();
35+
3436 String name = getDefaultFont ().getName ();
3537 if (createFontUrlLink (font .getResourceUrl ())) {
3638 name = font .getName ();
@@ -53,6 +55,19 @@ public static void setDefaultFont(Font defaultFont) {
5355 FontResourceInjector .defaultFont = defaultFont ;
5456 }
5557
58+ protected static void injectGoogleFontLink () {
59+ LinkElement fontGoogleApisLink = Document .get ().createLinkElement ();
60+ fontGoogleApisLink .setRel ("preconnect" );
61+ fontGoogleApisLink .setHref ("https://fonts.googleapis.com" );
62+ getHeadElement ().appendChild (fontGoogleApisLink );
63+
64+ LinkElement gstaticLink = Document .get ().createLinkElement ();
65+ gstaticLink .setRel ("preconnect" );
66+ gstaticLink .setHref ("https://fonts.gstatic.com" );
67+ gstaticLink .setAttribute ("crossorigin" , "" );
68+ getHeadElement ().appendChild (gstaticLink );
69+ }
70+
5671 protected static boolean createFontUrlLink (String resourceUrl ) {
5772 if (resourceUrl != null ) {
5873 LinkElement fontUrlLink = Document .get ().createLinkElement ();
You can’t perform that action at this time.
0 commit comments