Git Product home page Git Product logo

coding-fonts's Introduction

Coding Fonts

A microsite that shows off fonts designed for writing code.

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

Running this site.

  • Install dependencies: npm install
  • Start server: npm run dev

Adding a font

  • Start server (see above)
  • If the font is open source, put a copy of the font in the fonts folder. At the very least a .woff2 file in a folder of the fonts name. e.g. /src/assets/fonts/NewFont/NewFont.woff2
  • Make a stylesheet that gets that font ready to use in that font folder. e.g. /src/assets/fonts/NewFont/NewFont.css
  • Add a file like new-font.md to /src/fonts. Add the font's information. Mark the URL of the stylesheet from the previous step in the stylesheet_url field, relative to /src/assets/fonts/. If the URL is absolute, i.e. not added to the repo, add a stylesheet_absolute: true field. See this one as an example.
  • To preview what will be screenshot, the URL structure is like: http://localhost:8080/code_samples/html/?font=anonymous-pro&theme=dark where font matches the kebab-case Title of the Markdown file that you created.
  • Take screenshots! This is a local-only process. Follow the taking screenshots instructions in the command line.
  • Make a Pull Request for it. You should be able to see a built preview on Netlify as part of the PR.

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

coding-fonts's People

Contributors

8mpt avatar akashdsouza avatar aljedaxi avatar armno avatar bateleurx avatar calebnance avatar chriscoyier avatar davidleininger avatar eeeps avatar elfsternberg avatar fbuys avatar iainsimmons avatar jacobbednarz avatar jaravad avatar jeyaeswari avatar kasimahmic avatar landjonathan avatar mattfrankjames avatar maxbeier avatar orsdev avatar quirico avatar reubenlillie avatar styleshit avatar this-fifo avatar tskarhed avatar wopian avatar yenly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coding-fonts's Issues

Fonts with Ligatures Not Working

  • Hasklig
  • FiraFlott
  • Iosevka
  • JuliaMono

Not sure if it's a font-feature-settings thing or if we just need to re-make the WOFFs properly or what.

Screenshots for special characters.

I wonder if we could add like a "Special" page in addition to HTML, CSS, and JavaScript.

Based on some feedback:

find some way to show zeros vs. O’s, l’s 1's, =>. To me these are some of the key things I want my font to distinguish.

So this bit of code could have that, and other special typographic situations that are worth highlighting.

This could be the place to draw attention to having or not-having ligatures as well.

CMS strategy

There is a whole big list of fonts (see current README). Each font has a variety of metadata:

  • Name
  • Designer(s)
  • URL to some kind of homepage for it
  • Some kind of description maybe?

Then of course the screenshots of the samples.

Seems like a job for Markdown files with Frontmatter and Eleventy to me.

Handle Cloudinary url failing

It seems Cloudinary takes a bit to process new screenshots. It took about 7 minutes after merging Cartograph for the URL https://res.cloudinary.com/css-tricks/image/fetch/w_1600,q_auto,f_auto/https://coding-fonts.css-tricks.com/screenshots/cartograph-cf/css-light.png to stop returning a 404.
The simple https://coding-fonts.css-tricks.com/screenshots/cartograph-cf/css-light.png was fine.

This makes me think there should be a fallback for Cloudinary erroring out. Since we already host the originals as part of the site, it makes sense to add a bit of robustness.

Can srcset do this natively? Maybe we need to complicate the onerror listener?

image-rendering may improve image quality on Chromium Browsers

I'm viewing the site from my Windows desktop from Brave Browser (Chromium).
The images appear slightly blurry.

code-snippet-default-rendering

When the following CSS is applied, the image quality is greatly improved.

.screenshot img {
    image-rendering: -webkit-optimize-contrast;
}

code-snippet-optimize-contrast

In Google Chrome, Microsoft Edge, and Brave Browser (all Chromium), applying that CSS greatly improved the quality of the image. In Firefox, the image displayed at a high-quality without any image-rendering changes needed.

Screen/scrollbar flickering

On my screen (browser window: 1864x981px), the app is flickering because the content fits the window perfectly (no scrollbar) only when there is no animation running:
Peek 2020-11-02 15-31

This should be easy to solve by forcing the scrollbar to appear by applying overflow-y: scroll

Support lowering the font size

The font size being larger than what I typically use in IDEs, it makes it harder for me to project what in practice would be most comfortable. I tried using the browser zoom but it doesn't behave as expected on Firefox.

A simple control to change the font size would be great :)

Other than that nice job with the website!

Drastically lower image quality on iPad Safari

If you visit the site on an iPad, the image quality is much lower. It looks very low-res and pixelated. If I visit on my Mac, it looks normal. I haven’t tested on other machines.

I assume this has something to do with the way Cloudinary is serving different sizes and formats to different browsers?

I attached a screenshot. You can see how the image text looks compared to the actual text on the page.
PNG image

Go live list?

Any words from folks on things they'd want to see before this goes live?

Working on adding the last few fonts from the main list.

Add 0 (zero) character to HTML tab

First, thanks for this great cheatsheet.

I think it will be a great addition to include 0 (zero) character inside the HTML tab (maybe inside header tags) while I'm aware there is one in the Characters tab. I saw in the past that some fonts difficult to distinct between 0 (zero) with O (capital O).

Thank you.

Finish Adding Fonts / Data

The process of adding a font is in the README:
https://github.com/chriscoyier/coding-fonts#adding-a-font

The list so far...

Serve responsive images

We need to figure out how best to serve the images.
Netlify LFS looks nice, but would only cover sizes, not formats (which we could also do manually during build). Also, it would require every contributor to install git-lfs, which could be a barrier.
I'm guessing hosted solutions would require a build step to send new images.
Maybe we need to try this newfangled edge-handler fanciness?

Recursive is screnshotted with cursive on but upright

Recursive is screnshotted with cursive on but upright. This is from your webpage's recursive section, look at the r and l:
image

This is not the default way which mono is written using recursive, which is this:
image

The screenshotted variant on your page is actually this:
image

If you look at recursive's webpage their intent is that the cursive font is only used for italics, for example here:
image
https://www.recursive.design/process/

Character comparison change?

I usually use the string L|l1iI0Oo when checking out fonts.

The idea is there at the bottom of the character's tab, but separating the 1/l/O/0 doesn't provide a great comparison when "the whole point" is to see if you can tell the difference between those characters - ie, if the characters are 'well designed', the differences should be apparent/easy-to-spot. Since it is all done with screen shots, not the easiest\quickest PR, and this is basically a question of the core design of that tab, but perhaps food for thought? (Also, of course, regardless of format, I'd like to see my letter-I, |, and i comparisons along the 1s and ls)

addendum: (If not obvious, my suggested test string is capL, pipe-symbol, lowerL, 1, lowerI, capI, 0, capO, lowerO)

Open for contribution

👋

I have a particular interest in this project as it feels like I get the urge to "change up my dev font" every few months and I'm never quite satisfied.

I'd love to contribute by collecting some of the screenshots and/or the micro site. Are you open to contributions? Would you consider doing so for Hacktober?

take_screenshots.js not using the specified font when the font isn't lowercase

Issue

When using the take_screenshots.js file, lines 7-10 read the .md files in the fonts directory and store their names in whatever case the name of the file is in, i.e. if the file is Menlo.md, it's read as Menlo. This is then passed in the URL when navigating to the code sample page with Puppeteer where it proceeds to not render the sample in the specified font if the font isn't in all lowercase. I've attached some screenshots below that show this.

Solutions

One solution is to is to rename all the font directories so that they're all in lowercase and continue to maintain this style moving forward.

Another solution is to simply add a toLowerCase() method call when declaring the allFonts variable. This has the benefit of not concerning itself with the case of the font files themselves. Example below.

const allFonts = fs
  .readdirSync('./src/fonts')
  .filter((file) => file.endsWith('.md'))
  .map((file) => file.replace('.md', '').toLowerCase());

Personally I think the second solution is better though I'll leave it up to you. Let me know which solution is more preferable and I'll make a pull request.

image
image

Add Comic Neue

I would create a PR for Comic Neue, but it is highly debatable as a coding font. I just need to hear an "OK" before I do anything 😃 I've used it for more than a year. As the font is related to Comic Sans, people have on several occasions questioned my sanity.

We need a little bit more insanity in this world.

Here is a screenshot. I used the bold version, as it works best for coding.
Screenshot from 2020-10-19 20-09-01

Screenshot resolution

Suggestion: if you are going to go with screenshots for the font samples, double the resolution (or come up with some other trick), so they can stay sharp on high-dpi displays.

Underscores

I haven’t tried all of the fonts, but the fonts which most interested me have the normal width underscore. Originally, of course, this character was used to produce a single underline, while in coding, it’s used as a special character.

Source Code Pro is unusual in that it has a shorter underline character. This way it is easy to read the SQL pattern

LIKE 'a____'

and count the number of underscores without fiddling with the cursor.

Would it be possible to include a similar string with the other tricky characters?

Faux italics

Thanks for featuring Victor Mono! 🙂👍🏻

I couldn't help but noticing that true italics (one single instance in the single comment in the JavaScript screenshot?) aren't used. I think not using italics at all would be better than faux italics.

Broken preview on website

Many preview images (such as Consolas, FiraFlott, Hack and more) on the website are broken. Hope they will get fixed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.