Skip to content

Instantly share code, notes, and snippets.

View chearon's full-sized avatar

Caleb Hearon chearon

View GitHub Profile
@chearon
chearon / png_to_svg.sh
Last active June 16, 2017 15:37
Easy script to convert a folder of PNGs to same-sized SVGs using potrace
#!/bin/bash
# Run this in a directory of PNGs (or change *.png to *.jpg, *.gif, etc)
# It will make SVGs with the same name, at the same size as the PNGs
#
# DEPENDENCIES: imagemagick, potrace, mkbitmap (included in potrace)
# Adjust the following settings to get better results:
OPTTOLERANCE=.2 # 0 for angular images
CURVETHRESHOLD=1 # larger for less segments
@chearon
chearon / describe_font.c
Created April 4, 2016 15:03
Print the family name, weight, style, and width of a specification string given to Pango
#include <pango/pango.h>
#include <glib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char*
get_arg_string(int argc, char** argv)
{
size_t total_len = 0;
@chearon
chearon / test_prefer_pango.sh
Last active May 5, 2016 14:12
Test node-canvas#prefer-pango w google fonts
G_FONTS_DIR=gfonts
NODE_CANVAS_DIR="./node-canvas"
mkdir -p pngs
find $G_FONTS_DIR -name '*.ttf' | while read i; do
echo $i;
cat <<EOT | node
var path = require('path'),
@chearon
chearon / whatsthefont.c
Last active December 23, 2016 21:19
Compare FT and OSX font weights for a font
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <CoreText/CoreText.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TRUETYPE_TABLES_H
#include FT_SFNT_NAMES_H
#include FT_TRUETYPE_IDS_H
#ifndef FT_SFNT_OS2
#define FT_SFNT_OS2 ft_sfnt_os2
@chearon
chearon / init.vim
Last active September 6, 2022 07:09
The best possible neovim configuration
" Neovim-only, use in true color terminal
" Vundle config
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Vundle vundles
Plugin 'VundleVim/Vundle.vim'
Plugin 'ap/vim-css-color'
Plugin 'hail2u/vim-css3-syntax'
@chearon
chearon / scroll.fish
Last active January 10, 2018 20:22
Place in your ~/.config/fish/functions folder. The "scroll" command will then toggle macOS/classic style scrollbars to help test websites.
function scroll
set state (defaults read NSGlobalDomain AppleShowScrollBars)
if [ $state = "Automatic" ]
set state "Always"
echo "Scrollbars set to classic (always visible)"
else
set state "Automatic"
echo "Scrollbars set to normal macOS (autohide, zero width)"
end
#include <pango/pangocairo.h>
int
main(int argc, char **argv)
{
cairo_t *cr;
char *filename;
cairo_status_t status;
cairo_surface_t *surface;
From 95101a024258be3b058763fa00b526168e21df28 Mon Sep 17 00:00:00 2001
From: Caleb Hearon <caleb@chearon.net>
Date: Wed, 11 Oct 2017 14:24:49 -0400
Subject: [PATCH] fix bug #762873 - commas in family names for ct
---
pango/pangocoretext-fontmap.c | 58 +++++++++++++++++++++++++++----------------
1 file changed, 36 insertions(+), 22 deletions(-)
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
@chearon
chearon / config.fish
Created December 2, 2017 21:53
Fish config file
bass source $HOME/.cargo/env
function fish_prompt --description 'Write out the prompt'
set -l color_cwd
set -l suffix
switch $USER
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end