CSS-Tricks / coding-fonts

https://coding-fonts.css-tricks.com/
MIT License
464 stars 66 forks source link
coding-fonts font

Coding Fonts

A microsite that shows off fonts designed for writing code.

https://coding-fonts.css-tricks.com/

Running this site.

Adding a font

Taking Screenshots

You can take screenshots using the included takeScreenshots.js file. The options are listed in the help screen below.

Options:
  --version    Show version number
  -f, --font   Font to use for screenshots
  -l, --lang   Code sample to use for screenshot
  -t, --theme  Theme to use for screenshots
  --parallel   Run the screenshots in parallel
  -h, --help   Show help

--font, --lang, and --theme all accept the 'all' keyword to handle taking screenshots of all of their respective data points.

The --parallel flag allows the running of Puppeteer in parallel which is useful if you need to repeatedly take screenshots of a font. Do note that this will spawn as many Puppeteer instances as you have the total permutations you request. Take the following command for example.

node takeScreenshots.js -f source-code-pro -l all -t all

It will spawn 8 Puppeteer instances (1 font 4 languages 2 themes = 8 instances) all at once to take the screenshots. This is usually fine and doesn't result in any issues but in the event you were to do this for all fonts as well, you'd spawn hundreds of instances which will almost always in a failure.

Additional Examples

# Take a screenshot of the Source Code Pro font, using the JavaScript code sample, and the dark theme.
node takeScreenshots.js -f source-code-pro -l js -t dark

# Take a screenshot of the Menlo font, using all of the code samples, and the light theme.
node takeScreenshots.js -f menlo -l all -t light

# Take a screenshot of all of the fonts, using all of the code samples, and all of the themes.
node takeScreenshots.js -f all -l all -t all

# Take a screenshot of the Input font, using all of the code samples, all of the themes, and do so in parallel
node takeScreenshots.js -f input -l all -t all --parallel