Fira Code

repository·master·Indexed 13 days ago

https://github.com/tonsky/firacode

A free monospaced font designed for programming, featuring extensive support for programming ligatures and stylistic sets. Version 6.2.0 includes installation guides for Windows, macOS, Linux, and FreeBSD, as well as configuration instructions for VS Code, IntelliJ, Sublime Text, Emacs, and Visual Studio.

Tokens
16.3K
Snippets
25
Records
67
Agent score
96%

What's inside Fira Code

  1. What is Fira Code?

    master
    Fira Code is a free monospaced font designed for programmers. It features programming ligatures, which combine common multi-character sequences (like ->, <=, :=, ..., or //) into single, visually distinct logical tokens. This is achieved through font rendering while keeping the underlying code ASCII-compatible, allowing for faster reading and comprehension without changing the actual source code.
  2. Performance impact of different `calt` implementation strategies

    master

    The performance of Fira Code's programming ligatures (driven by the calt OpenType feature) varies significantly depending on how the substitution rules are structured in the font source. When benchmarking with HarfBuzz, the following implementation patterns were observed:

    1. Baseline: Direct substitutions (e.g., sub 1 2 3 4 by 1_2_3_4.liga;). This is the fastest method.
    2. Spacers: Using spacer characters to manage glyph positioning. This is slower than the baseline.
    3. Lookups: Wrapping substitutions in a named lookup block. This increases processing time.
    4. Ignores: Using ignore statements within a lookup block to prevent certain substitutions. This is the slowest method due to the additional logic required to skip rules.

    Use these insights if you are modifying the font source or optimizing OpenType feature performance.

    Benchmark Results (HarfBuzz 2.6.4):
    - Baseline: 0.407s
    - Spacers:  1.415s
    - Lookups:  2.080s
    - Ignores:  2.656s
  3. Configure Fira Code features and variants

    master
    Fira Code supports various character variants (cv01, cv02, etc.), stylistic sets (ss01, ss02, etc.), and other font features (zero, onum, calt). These can be enabled via your editor's font settings or by building a custom version of the font using the build script.
  4. Understand Fontbakery report results for Fira Code

    master

    The Fontbakery report provides automated quality checks for font files. Results are categorized into several statuses:

    • 🍞 PASS: The check passed successfully.
    • WARN: A warning was issued (e.g., missing kerning information in the GPOS table).
    • INFO: Informational data provided (e.g., hinting filesize impact, version strings, or table presence).
    • 💤 SKIP: The check was skipped because certain conditions were not met (e.g., the check only applies to variable fonts or italic fonts).

    This report is used to validate the technical integrity and metadata compliance of the Fira Code font files.

  5. Install Fira Code on Linux

    master

    Fira Code is available in the package managers of most major Linux distributions:

    • Ubuntu/Debian: Ensure universe (Ubuntu) or contrib (Debian) repositories are enabled, then run sudo apt install fonts-firacode.
    • Arch Linux: Available in official repositories (ttf-fira-code) or AUR (otf-fira-code-git).
    • Fedora: dnf install fira-code-fonts
    • Gentoo: emerge -av media-fonts/fira-code
    • Solus: sudo eopkg install font-firacode-ttf font-firacode-otf
    • Void Linux: xbps-install font-firacode

    Manual Linux Installation: If your distribution doesn't support the above, you can manually install the TTF files into ~/.local/share/fonts and run fc-cache -f to update the font cache.

  6. Compile Fira Code using Docker

    master

    You can also compile Fira Code using Docker to avoid local dependency issues. This will install dependencies in a container, compile the font files, and package them into a ZIP file.

    # install dependencies in a container and compile the font files
    make
    
    # compress the font files in dist/ into a zip
    make package
  7. Build Fira Code locally from source

    master

    If you want to modify FiraCode.glyphs and build your own OTF/TTF/WOFF files, you can use the provided build scripts on macOS or via Docker.

    macOS Build

    1. Install build tools: ./script/bootstrap_macos.sh
    2. Build fonts: ./script/build.sh
    3. Install OTF files to ~/Library/Fonts.

    Docker Build

    Use make to install dependencies and build, or make package to bundle the dist/ files into a zip.

    Customizing the Build

    You can pass flags to ./script/build.sh to permanently bake specific features into your custom font files:

    • -f, --features: A comma-separated list of features (e.g., ss02,cv03).
    • -n, --family-name: The desired font family name. Using features as the name appends the enabled features to the family name.
    • -w, --weights: Limit the generated font weights (e.g., Regular,Bold).
    # Example: Build a custom version with specific features and a custom name
    ./script/build.sh --features "ss02,ss08,ss10,cv03,cv07,cv14" --family-name "Fira Code straight" --weights "Regular,Bold"
    
    # Example: Using Docker to create a family name that includes feature names
    docker run --rm -v "${PWD}":/opt tonsky/firacode:latest ./script/build.sh -f "cv01,cv02,cv06,ss01,zero,onum,ss03,ss04,cv31" -n "features"
  8. Enable Fira Code ligatures in IntelliJ products

    master

    To enable Fira Code and ligatures in IntelliJ IDEA and other JetBrains IDEs:

    1. Go to Settings $\rightarrow$ Editor $\rightarrow$ Font.
    2. Check Enable Font Ligatures.
    3. Select Fira Code as the Primary font.

    If you are using a specific Color Scheme, you must also apply these settings under: Settings $\rightarrow$ Editor $\rightarrow$ Color Scheme $\rightarrow$ Color Scheme Font $\rightarrow$ Enable Font Ligatures and select Fira Code as the Primary font.

  9. Enable Fira Code ligatures in Sublime Text

    master

    To configure Fira Code in Sublime Text, add the following to your settings file (before the ignored_packages key):

    "font_face": "Fira Code",
    "font_options": ["subpixel_antialias"],

    To use gray_antialias instead, update the font_options array accordingly.

  10. Compile Fira Code locally on macOS

    master

    If you wish to modify the glyphs in FiraCode.glyphs and compile your own OTF/TTF/WOFF files, follow these steps on macOS:

    1. Install required build tools using the bootstrap script.
    2. Run the build script to generate font files.
    3. Copy the generated OTF files to your system font directory.
    # install required tools for compilation
    ./script/bootstrap_macos.sh
    
    # compile the font files
    ./script/build.sh
    
    # install the OTFs in ~/Library/Fonts
    cp distr/otf/*.otf ~/Library/Fonts