Code Monkey home page Code Monkey logo

font-patcher's Introduction

Font Patcher Thing

Script to increase the line height of a font

Screen Shot 2020-01-05 at 1 59 58 PM

Intro

This script shouldn't really exist, and patching fonts in this way isn't really such a good idea. However, Emacs currently doesn't have proper support for adjusting line height, as summarized in this stack overflow question. The only workaround that I have found to work reliably, is to patch the font itself to include the proper spacing. So, here is a script that at least makes the process easy.

Examples

The easiest way to run the script is to build a docker image via the Dockerfile provided.

# build the image (only required once)
docker build -t font-patcher .

If you are using the examples below as is, make sure to copy your original font into the fonts directory of this project so the files will be mapped into the container.

Patch a single font file

docker run --rm -v $(pwd):/home font-patcher \
    /usr/bin/python /home/src/main.py \
    --factor=1.3 \ # increase the line height by 30%
    --input=/home/fonts/Operator\ Mono.otf \ # mounted path to the original font file
    --outputDir=/home/fonts/patched # directory to save the new font file

Patch multiple font files at once

This is really just the repetition of patching a single font file, but since it's so common, here is an example:

for x in $(/bin/ls fonts/OperatorMono); do
    docker run --rm -v $(pwd):/home font-patcher \
        /usr/bin/python /home/src/main.py \
        --factor=1.3 \ # increase the line height by 30%
        --input=/home/fonts/OperatorMono/$x \ # mounted path to the original font file
        --outputDir=/home/fonts/patched # directory to save the new font file
done

Once your fonts are patched, you can install them on your machine for future use.

font-patcher's People

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.