@@ -48,7 +48,7 @@ private EmbeddableFont(String fontName, List<String> fallbacks, Map<FontStyle, S
4848 css = dfonts .stream ().map (d -> generateFontFaceCSS (d )).collect (Collectors .joining (" " ));
4949 fonts = dfonts .stream ().collect (Collectors .toMap (d -> d .style , d -> d .font ()));
5050
51- familyDeclaration = "'" + fontName + "', " + fallbacks .stream ().map (s -> "'" + s + "'" ).collect (Collectors .joining (", " )).replaceAll ("'sans-serif'" , "sans-serif" );
51+ familyDeclaration = "'" + fontName + " Light', '" + fontName + " ', " + fallbacks .stream ().map (s -> "'" + s + "'" ).collect (Collectors .joining (", " )).replaceAll ("'sans-serif'" , "sans-serif" );
5252
5353 }
5454
@@ -133,15 +133,18 @@ private static String generateFontFaceCSS(DownloadedFont downloadedFont) {
133133 // Base64 encode the font bytes
134134 // It would be nice to subset the characters and only include what's needed, to save file sizes
135135 String base64Font = Base64 .getEncoder ().encodeToString (downloadedFont .raw ());
136+ String fontName = downloadedFont .font ().getFontName ();
136137 return """
137138 @font-face {
138139 font-family: '%s';
139140 src:
140- url('data:font/ttf;base64,%s') format('truetype');
141- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
141+ url('data:font/ttf;base64,%s') format('truetype'),
142+ local(%s),
143+ local(%s);
144+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
142145 font-style: normal;
143146 }
144- """ .formatted (downloadedFont . font (). getFontName (), base64Font );
147+ """ .formatted (fontName , base64Font , fontName , fontName . replaceAll ( " " , "" ) );
145148 }
146149
147150 public String getFamilyDeclaration () {
0 commit comments