Skip to content

Commit

Permalink
fix: use fallback font, not rendered name
Browse files Browse the repository at this point in the history
resolves #8
  • Loading branch information
danielroe committed Feb 22, 2024
1 parent b707f62 commit 0c32d01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/css/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function generateFontFallbacks (family: string, data: NormalizedFon
for (const fallback of fallbacks) {
css.push(generateFallbackFontFace(metrics, {
...fallback,
metrics: await getMetricsForFamily(fallback.name) || undefined
metrics: await getMetricsForFamily(fallback.font) || undefined
}))
}
return css
Expand Down
24 changes: 12 additions & 12 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ describe('features', () => {
"@font-face {
font-family: "Lato Fallback: Arial";
src: local("Arial");
size-adjust: 100%;
ascent-override: 98.7%;
descent-override: 21.3%;
size-adjust: 97.4159%;
ascent-override: 101.3181%;
descent-override: 21.865%;
line-gap-override: 0%;
}",
]
Expand All @@ -132,9 +132,9 @@ describe('features', () => {
"@font-face {
font-family: "Nunito Fallback: Arial";
src: local("Arial");
size-adjust: 100%;
ascent-override: 101.1%;
descent-override: 35.3%;
size-adjust: 101.7204%;
ascent-override: 99.3901%;
descent-override: 34.703%;
line-gap-override: 0%;
}",
]
Expand All @@ -148,9 +148,9 @@ describe('features', () => {
"@font-face {
font-family: "Oswald Fallback: Times New Roman";
src: local("Times New Roman");
size-adjust: 100%;
ascent-override: 119.3%;
descent-override: 28.9%;
size-adjust: 90.5221%;
ascent-override: 131.791%;
descent-override: 31.9259%;
line-gap-override: 0%;
}",
]
Expand All @@ -160,9 +160,9 @@ describe('features', () => {
"@font-face {
font-family: "Fredoka Fallback: Tahoma";
src: local("Tahoma");
size-adjust: 100%;
ascent-override: 97.4%;
descent-override: 23.6%;
size-adjust: 101.2772%;
ascent-override: 96.1717%;
descent-override: 23.3024%;
line-gap-override: 0%;
}",
]
Expand Down
22 changes: 11 additions & 11 deletions test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('parsing', () => {
"@font-face {
font-family: "Open Sans Fallback: Times New Roman";
src: local("Times New Roman");
size-adjust: 100%;
ascent-override: 106.8848%;
descent-override: 29.2969%;
size-adjust: 116.6056%;
ascent-override: 91.6635%;
descent-override: 25.1248%;
line-gap-override: 0%;
}
Expand Down Expand Up @@ -82,19 +82,19 @@ describe('parsing', () => {
"@font-face {
font-family: "Poppins Fallback: Arial";
src: local("Arial");
size-adjust: 100%;
ascent-override: 105%;
descent-override: 35%;
line-gap-override: 10%;
size-adjust: 113.7274%;
ascent-override: 92.326%;
descent-override: 30.7753%;
line-gap-override: 8.793%;
}
@font-face {
font-family: "Poppins Fallback: Times New Roman";
src: local("Times New Roman");
size-adjust: 100%;
ascent-override: 105%;
descent-override: 35%;
line-gap-override: 10%;
size-adjust: 125.5306%;
ascent-override: 83.6449%;
descent-override: 27.8816%;
line-gap-override: 7.9662%;
}
@font-face {
Expand Down

0 comments on commit 0c32d01

Please sign in to comment.