-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
override
font-family-modern
font weight
- Loading branch information
1 parent
66da7ca
commit d301067
Showing
6 changed files
with
206 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import fs from 'node:fs/promises'; | ||
import cssParser from 'css'; | ||
|
||
try { | ||
const fontWeight350Rules = []; | ||
|
||
const sw = await fetch('https://www.tumblr.com/sw.js').then((result) => result.text()); | ||
const urls = sw.match(/https:\/\/assets\.tumblr\.com\/pop\/[a-z0-9-]+\.css/g); | ||
for (const url of urls) { | ||
console.log('downloading', url); | ||
|
||
const [cssText] = await Promise.all([ | ||
fetch(url).then((response) => response.text()), | ||
new Promise((resolve) => setTimeout(resolve, 500)) | ||
]); | ||
|
||
const ast = cssParser.parse(cssText); | ||
const rules = ast.stylesheet.rules | ||
.flatMap((rule) => rule.rules ?? [rule]) | ||
.filter((rule) => rule.type === 'rule'); | ||
|
||
fontWeight350Rules.push(...rules.filter( | ||
({ declarations }) => | ||
declarations.find(({ property, value }) => property === 'font-family' && value === 'var(--font-family-modern)') && | ||
declarations.find(({ property, value }) => property === 'font-weight' && value === '350') | ||
)); | ||
} | ||
|
||
const selectorSets = [...new Set(fontWeight350Rules.map(({ selectors }) => selectors.join(', ')))]; | ||
|
||
const override = `/* | ||
Tumblr uses an unusual font weight of 350 on most --font-family-modern (Favorit Modern) | ||
text, which may result in thin text when overriding the --font-family-modern variable. | ||
This file is automatically generated by dev/update-font-weight-override.js and contains | ||
the selectors of all native Tumblr rules which set font-family: var(--font-family-modern) | ||
and font-weight: 350. | ||
*/ | ||
${selectorSets.join(',\n')} { | ||
font-weight: normal; | ||
}\n`; | ||
|
||
await fs.writeFile('src/fontWeightOverride.css', override, { encoding: 'utf8', flag: 'w+' }); | ||
console.log(`wrote ${selectorSets.length} selector sets`); | ||
} catch (e) { | ||
console.log(e); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
Tumblr uses an unusual font weight of 350 on most --font-family-modern (Favorit Modern) | ||
text, which may result in thin text when overriding the --font-family-modern variable. | ||
This file is automatically generated by dev/update-font-weight-override.js and contains | ||
the selectors of all native Tumblr rules which set font-family: var(--font-family-modern) | ||
and font-weight: 350. | ||
*/ | ||
.vgL3J, | ||
.TZgeO, | ||
.Gt2Q9, | ||
.n63mn, | ||
.OmZD7, .RSZnt, | ||
.gAJ73, | ||
.AiALR .enHco .fgOG_, | ||
.j8Eiw, | ||
.h7IR_, | ||
.ctBr6, | ||
.CsHnt, | ||
.fBQsy, | ||
.h6QpP, | ||
.zFlRa, | ||
.R4hFV, | ||
.gty8w, | ||
.sG03a, | ||
.EKpJR, | ||
.y0RtB, | ||
.R8_EV, | ||
.deHVW .x66yu, .cJ1ik .x66yu, .PCzZt .x66yu, .deHVW .pLL0g, .cJ1ik .pLL0g, .PCzZt .pLL0g, | ||
.L2HBn .x66yu, .n_fvx .x66yu, .L2HBn .pLL0g, .n_fvx .pLL0g, | ||
.Pl0ah, | ||
.NjLa2, | ||
.KVX8S, | ||
.ZRkRa, | ||
.F0gXR, | ||
.q9P6T, | ||
.u8J1W .wVZAK .M523y, | ||
.Hzn1C, | ||
.YmIEY, | ||
.wjhBM, | ||
.GutOb .BV4gt, | ||
.tSUo6, | ||
.zGDfg, | ||
.QKm6q .BnVIB .mV8AT, | ||
.Ks9nn .ZR5vI, | ||
.FzBTa .GpO9n, | ||
.c1xDI, | ||
.xPEP2, | ||
.rB7hU, | ||
.RPMuM, | ||
.KPqE4 p.zDaqs, | ||
.Sft1t, | ||
.a0QuG, | ||
.dJl65, | ||
.YmlZc, | ||
.KaTRm, | ||
.qyc0j, | ||
.YMD5o, | ||
.pYQdH .uHcx_, | ||
.Nq9JP, | ||
.amytk, | ||
.Z7ew7, | ||
.srYxv, | ||
.OfCo4, | ||
.WiceP, | ||
.f8LOG, | ||
.uaMQw, | ||
.Jo8I3, | ||
._ilsA, | ||
.kbuhn, | ||
.Isbe9, | ||
.SuDWJ, | ||
.nhqrO.ldaI8, | ||
.I3pYl, | ||
.YVaw6 .uJ0hL, | ||
.F3D5L, | ||
.R4UJx, | ||
.XADCw, | ||
.PpzPj, | ||
.L3C_C, | ||
.iWoxw, | ||
.iLTKv, | ||
.YtLa6 .aPaHS, | ||
.YtLa6 .G6FrY, | ||
.mhABv, | ||
.Z_cvW, | ||
.kjdMf .Shb25, | ||
.vgRpB, | ||
.Vt7qF .wL4YA.jk3gM .UEULa { | ||
font-weight: normal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters