An open API service indexing awesome lists of open source software.

https://github.com/nilsding/bdf_parser

A quick and dirty parser for the Glyph Bitmap Distribution Format (BDF)
https://github.com/nilsding/bdf_parser

Last synced: over 1 year ago
JSON representation

A quick and dirty parser for the Glyph Bitmap Distribution Format (BDF)

Awesome Lists containing this project

README

          

# bdf_parser

A quick and dirty parser for the Glyph Bitmap Distribution Format (BDF).

## Usage

```ruby
require_relative "./bdf_parser"
require "pp"

font = nil
File.open(File.expand_path("~/unifont.bdf"), "r") do |file|
font = BDF::Parser.new(file).parse
end

p font.name
# "-gnu-Unifont-Medium-R-Normal-Sans-16-160-75-75-c-80-iso10646-1"

pp font.properties
# {:copyright=>
# "Copyright (C) 1998-2019 Roman Czyborra, Paul Hardy, Qianqian Fang, Andrew Miller, Johnnie Weaver, David Corbett, et al. License GPLv2+: GNU GPL version 2 or later with the GNU Font Embedding Exception.",
# :font_version=>"12.1.03",
# :font_type=>"Bitmap",
# :foundry=>"GNU",
# :family_name=>"Unifont",
# :weight_name=>"Medium",
# :slant=>"R",
# :setwidth_name=>"Normal",
# :add_style_name=>"Sans Serif",
# :pixel_size=>16,
# :point_size=>160,
# :resolution_x=>75,
# :resolution_y=>75,
# :spacing=>"C",
# :average_width=>80,
# :charset_registry=>"ISO10646",
# :charset_encoding=>"1",
# :underline_position=>-2,
# :underline_thickness=>1,
# :cap_height=>10,
# :x_height=>8,
# :font_ascent=>14,
# :font_descent=>2,
# :default_char=>65533}

pp font.chars["U+0045"]
# #,
# dwidth=#,
# bbx=#,
# bitmap=[0, 0, 0, 0, 126, 64, 64, 64, 124, 64, 64, 64, 64, 126, 0, 0]>
```