pzula / tales-of-notdef

!!con presentation: example script to find support for a given character in a group of fonts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tales of ⌧!

A presentation at !!con 2018 - Watch it on YouTube

The script.rb file is a basic script to illustrate how to find a character within a folder of font files. This script is intended for learning a discovery, and as such contains no tests or class structure.

Requirements

  • Ruby 2.4.0 or higher
  • Bundler to install gems

Installation

  1. Clone this repo locally
  2. run bundle install in the main folder of the repo

Usage

  1. Find the Unicode codepoint for the character for which you would like to find a supporting font. You can use FileFormat.info, a search engine, or use Appendix A below for instructions on how to do it programatically.
  2. Collect your font files into a folder
  3. Execute the script like so: ruby script.rb /your/font/folder/path/ 308D

Example output

For a folder containing the font files SourceHansSerif-Bold.otf, SourceSerifPro-Bold.otf and SourceCodePro-Regular.otf:

$ ruby script.rb /Users/pzula/bangbangcon/Fonts/ 308D
----------------
SourceHanSerif-Bold.otf contains 308D!
----------------

Appendix A

If you already have the character in your pasteboard, here's a quick way to find the Unicode hex representation of the codepoint using the Ruby REPL, irb.

irb(main):001:0> character = "a"
=> "a"
irb(main):002:0> character_code = character.unpack('U*').first
=> 97
irb(main):003:0> hex_unicode = "U+" << character_code.to_s(16).upcase.rjust(4, '0')
=> "U+0061"

Appendix B: Fun resources

Glyph 0, The Notdef Glyph: The OpenType recommendation

A discussion of "tofu" in the english language

Tofu, or Not Tofu

The Actual Unicode Standard

Unicode Code Charts

Unicode Fonts for Kindle 2 v0.1 Hack

Graceful degradation for ebook characters

TTFunk

Josh Cheek's Gist on Parsing Fonts in Ruby

Someone built something for this that is more robust in Python

About

!!con presentation: example script to find support for a given character in a group of fonts


Languages

Language:Ruby 100.0%