Skip to content

Commit

Permalink
Add the font Linux Libertine as a possible substitution for Times New…
Browse files Browse the repository at this point in the history
… Roman
  • Loading branch information
calixteman committed Jan 14, 2024
1 parent dc92ab8 commit da62e52
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
8 changes: 6 additions & 2 deletions src/core/font_substitutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const substitutionMap = new Map([
"Thorndale",
"TeX Gyre Termes",
"FreeSerif",
"Linux Libertine O",
"Libertinus Serif",
"DejaVu Serif",
"Bitstream Vera Serif",
"Ubuntu",
Expand Down Expand Up @@ -148,6 +150,8 @@ const substitutionMap = new Map([
"Cumberland",
"TeX Gyre Cursor",
"FreeMono",
"Linux Libertine Mono O",
"Libertinus Mono",
],
style: NORMAL,
ultimate: "monospace",
Expand Down Expand Up @@ -470,7 +474,7 @@ function getFontSubstitution(
(italic && ITALIC) ||
NORMAL;
substitutionInfo = {
css: loadedName,
css: `"${baseFontName}",${loadedName}`,
guessFallback: true,
loadedName,
baseFontName,
Expand All @@ -492,7 +496,7 @@ function getFontSubstitution(
const fallback = guessFallback ? "" : `,${ultimate}`;

substitutionInfo = {
css: `${loadedName}${fallback}`,
css: `"${baseFontName}",${loadedName}${fallback}`,
guessFallback,
loadedName,
baseFontName,
Expand Down
38 changes: 26 additions & 12 deletions test/unit/font_substitutions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+)$/);
expect(fontSubstitution.css).toMatch(/^"Foo",g_d(\d+)_sf(\d+)$/);
});

it("should substitute an unknown bold font", () => {
Expand All @@ -63,7 +63,7 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+)$/);
expect(fontSubstitution.css).toMatch(/^"Foo-Bold",g_d(\d+)_sf(\d+)$/);
});

it("should substitute an unknown italic font", () => {
Expand All @@ -86,7 +86,7 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+)$/);
expect(fontSubstitution.css).toMatch(/^"Foo-Italic",g_d(\d+)_sf(\d+)$/);
});

it("should substitute an unknown bold italic font", () => {
Expand All @@ -109,7 +109,7 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+)$/);
expect(fontSubstitution.css).toMatch(/^"Foo-BoldItalic",g_d(\d+)_sf(\d+)$/);
});

it("should substitute an unknown font but with a standard font", () => {
Expand Down Expand Up @@ -140,7 +140,7 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
expect(fontSubstitution.css).toMatch(/^"Foo",g_d(\d+)_sf(\d+),sans-serif$/);
});

it("should substitute an unknown font but with a standard italic font", () => {
Expand Down Expand Up @@ -173,7 +173,9 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
expect(fontSubstitution.css).toMatch(
/^"Foo-Italic",g_d(\d+)_sf(\d+),sans-serif$/
);
});

it("should substitute an unknown font but with a standard bold font", () => {
Expand Down Expand Up @@ -205,7 +207,9 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
expect(fontSubstitution.css).toMatch(
/^"Foo-Bold",g_d(\d+)_sf(\d+),sans-serif$/
);
});

it("should substitute an unknown font but with a standard bold italic font", () => {
Expand Down Expand Up @@ -240,7 +244,9 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
expect(fontSubstitution.css).toMatch(
/^"Foo-BoldItalic",g_d(\d+)_sf(\d+),sans-serif$/
);
});

it("should substitute Calibri", () => {
Expand Down Expand Up @@ -271,7 +277,9 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
expect(fontSubstitution.css).toMatch(
/^"Calibri",g_d(\d+)_sf(\d+),sans-serif$/
);
});

it("should substitute Calibri-Bold", () => {
Expand Down Expand Up @@ -304,7 +312,9 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
expect(fontSubstitution.css).toMatch(
/^"Calibri-Bold",g_d(\d+)_sf(\d+),sans-serif$/
);
});

it("should substitute Arial Black", () => {
Expand Down Expand Up @@ -337,7 +347,9 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
expect(fontSubstitution.css).toMatch(
/^"ArialBlack",g_d(\d+)_sf(\d+),sans-serif$/
);
});

it("should substitute Arial Black Bold", () => {
Expand Down Expand Up @@ -370,6 +382,8 @@ describe("getFontSubstitution", function () {
},
})
);
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
expect(fontSubstitution.css).toMatch(
/^"ArialBlack-Bold",g_d(\d+)_sf(\d+),sans-serif$/
);
});
});

0 comments on commit da62e52

Please sign in to comment.