@@ -140,7 +140,7 @@ describe("getFontSubstitution", function () {
140140 expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) $ / ) ;
141141 } ) ;
142142
143- it ( "should substitute an unknown font but with a standard font" , ( ) => {
143+ it ( "should substitute an unknown sans-serif font but with a standard font" , ( ) => {
144144 const fontName = "Foo" ;
145145 const fontSubstitution = getFontSubstitution (
146146 new Map ( ) ,
@@ -172,7 +172,7 @@ describe("getFontSubstitution", function () {
172172 expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) , s a n s - s e r i f $ / ) ;
173173 } ) ;
174174
175- it ( "should substitute an unknown font but with a standard italic font" , ( ) => {
175+ it ( "should substitute an unknown sans-serif font but with a standard italic font" , ( ) => {
176176 const fontName = "Foo-Italic" ;
177177 const fontSubstitution = getFontSubstitution (
178178 new Map ( ) ,
@@ -206,7 +206,7 @@ describe("getFontSubstitution", function () {
206206 expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) , s a n s - s e r i f $ / ) ;
207207 } ) ;
208208
209- it ( "should substitute an unknown font but with a standard bold font" , ( ) => {
209+ it ( "should substitute an unknown sans-serif font but with a standard bold font" , ( ) => {
210210 const fontName = "Foo-Bold" ;
211211 const fontSubstitution = getFontSubstitution (
212212 new Map ( ) ,
@@ -239,7 +239,7 @@ describe("getFontSubstitution", function () {
239239 expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) , s a n s - s e r i f $ / ) ;
240240 } ) ;
241241
242- it ( "should substitute an unknown font but with a standard bold italic font" , ( ) => {
242+ it ( "should substitute an unknown sans-serif font but with a standard bold italic font" , ( ) => {
243243 const fontName = "Foo-BoldItalic" ;
244244 const fontSubstitution = getFontSubstitution (
245245 new Map ( ) ,
@@ -275,6 +275,136 @@ describe("getFontSubstitution", function () {
275275 expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) , s a n s - s e r i f $ / ) ;
276276 } ) ;
277277
278+ it ( "should substitute an unknown serif font but with a standard font" , ( ) => {
279+ const fontName = "Foo" ;
280+ const fontSubstitution = getFontSubstitution (
281+ new Map ( ) ,
282+ idFactory ,
283+ localFontPath ,
284+ fontName ,
285+ "Times-Roman" ,
286+ "TrueType"
287+ ) ;
288+ expect ( fontSubstitution ) . toEqual (
289+ jasmine . objectContaining ( {
290+ guessFallback : false ,
291+ baseFontName : "Foo" ,
292+ src :
293+ "local(Foo),local(Times New Roman),local(Times-Roman),local(Times)," +
294+ "local(Liberation Serif),local(Nimbus Roman),local(Nimbus Roman L)," +
295+ "local(Tinos),local(Thorndale),local(TeX Gyre Termes)," +
296+ "local(FreeSerif),local(Linux Libertine O)," +
297+ "local(Libertinus Serif),local(PT Astra Serif)," +
298+ "local(DejaVu Serif),local(Bitstream Vera Serif)," +
299+ "local(Ubuntu)" ,
300+ style : {
301+ style : "normal" ,
302+ weight : "normal" ,
303+ } ,
304+ } )
305+ ) ;
306+ expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) , s e r i f $ / ) ;
307+ } ) ;
308+
309+ it ( "should substitute an unknown serif font but with a standard italic font" , ( ) => {
310+ const fontName = "Foo-Italic" ;
311+ const fontSubstitution = getFontSubstitution (
312+ new Map ( ) ,
313+ idFactory ,
314+ localFontPath ,
315+ fontName ,
316+ "Times-Italic" ,
317+ "TrueType"
318+ ) ;
319+ expect ( fontSubstitution ) . toEqual (
320+ jasmine . objectContaining ( {
321+ guessFallback : false ,
322+ baseFontName : "Foo-Italic" ,
323+ src :
324+ "local(Foo-Italic),local(Times New Roman Italic)," +
325+ "local(Times-Roman Italic),local(Times Italic)," +
326+ "local(Liberation Serif Italic),local(Nimbus Roman Italic)," +
327+ "local(Nimbus Roman L Italic)," +
328+ "local(Tinos Italic),local(Thorndale Italic)," +
329+ "local(TeX Gyre Termes Italic),local(FreeSerif Italic)," +
330+ "local(Linux Libertine O Italic),local(Libertinus Serif Italic)," +
331+ "local(PT Astra Serif Italic),local(DejaVu Serif Italic)," +
332+ "local(Bitstream Vera Serif Italic),local(Ubuntu Italic)" ,
333+ style : {
334+ style : "italic" ,
335+ weight : "normal" ,
336+ } ,
337+ } )
338+ ) ;
339+ expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) , s e r i f $ / ) ;
340+ } ) ;
341+
342+ it ( "should substitute an unknown serif font but with a standard bold font" , ( ) => {
343+ const fontName = "Foo-Bold" ;
344+ const fontSubstitution = getFontSubstitution (
345+ new Map ( ) ,
346+ idFactory ,
347+ localFontPath ,
348+ fontName ,
349+ "Times-Bold" ,
350+ "TrueType"
351+ ) ;
352+ expect ( fontSubstitution ) . toEqual (
353+ jasmine . objectContaining ( {
354+ guessFallback : false ,
355+ baseFontName : "Foo-Bold" ,
356+ src :
357+ "local(Foo-Bold),local(Times New Roman Bold),local(Times-Roman Bold)," +
358+ "local(Times Bold),local(Liberation Serif Bold)," +
359+ "local(Nimbus Roman Bold),local(Nimbus Roman L Bold)," +
360+ "local(Tinos Bold),local(Thorndale Bold)," +
361+ "local(TeX Gyre Termes Bold)," +
362+ "local(FreeSerif Bold),local(Linux Libertine O Bold)," +
363+ "local(Libertinus Serif Bold),local(PT Astra Serif Bold)," +
364+ "local(DejaVu Serif Bold),local(Bitstream Vera Serif Bold)," +
365+ "local(Ubuntu Bold)" ,
366+ style : {
367+ style : "normal" ,
368+ weight : "bold" ,
369+ } ,
370+ } )
371+ ) ;
372+ expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) , s e r i f $ / ) ;
373+ } ) ;
374+
375+ it ( "should substitute an unknown serif font but with a standard bold italic font" , ( ) => {
376+ const fontName = "Foo-BoldItalic" ;
377+ const fontSubstitution = getFontSubstitution (
378+ new Map ( ) ,
379+ idFactory ,
380+ localFontPath ,
381+ fontName ,
382+ "Times-BoldItalic" ,
383+ "TrueType"
384+ ) ;
385+ expect ( fontSubstitution ) . toEqual (
386+ jasmine . objectContaining ( {
387+ guessFallback : false ,
388+ baseFontName : "Foo-BoldItalic" ,
389+ src :
390+ "local(Foo-BoldItalic),local(Times New Roman Bold Italic)," +
391+ "local(Times-Roman Bold Italic),local(Times Bold Italic)," +
392+ "local(Liberation Serif Bold Italic),local(Nimbus Roman Bold Italic)," +
393+ "local(Nimbus Roman L Bold Italic),local(Tinos Bold Italic)," +
394+ "local(Thorndale Bold Italic),local(TeX Gyre Termes Bold Italic)," +
395+ "local(FreeSerif Bold Italic),local(Linux Libertine O Bold Italic)," +
396+ "local(Libertinus Serif Bold Italic)," +
397+ "local(PT Astra Serif Bold Italic),local(DejaVu Serif Bold Italic)," +
398+ "local(Bitstream Vera Serif Bold Italic),local(Ubuntu Bold Italic)" ,
399+ style : {
400+ style : "italic" ,
401+ weight : "bold" ,
402+ } ,
403+ } )
404+ ) ;
405+ expect ( fontSubstitution . css ) . toMatch ( / ^ " F o o " , g _ d ( \d + ) _ s f ( \d + ) , s e r i f $ / ) ;
406+ } ) ;
407+
278408 it ( "should substitute Calibri" , ( ) => {
279409 const fontName = "Calibri" ;
280410 const fontSubstitution = getFontSubstitution (
0 commit comments