https://github.com/stumpycr/pcf-parser
Parser for the pcf bitmap font format
https://github.com/stumpycr/pcf-parser
Last synced: about 1 year ago
JSON representation
Parser for the pcf bitmap font format
- Host: GitHub
- URL: https://github.com/stumpycr/pcf-parser
- Owner: stumpycr
- License: mit
- Created: 2017-05-04T21:35:17.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-09-18T07:14:25.000Z (over 5 years ago)
- Last Synced: 2025-01-22T23:28:02.368Z (about 1 year ago)
- Language: Crystal
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PCF Parser
A parser for `.pcf` bitmap fonts
## Usage
### Install the `pcf-parser` shard
1. `shards init`
2. Add the dependency to the `shard.yml` file
``` yaml
...
dependencies:
pcf-parser:
github: stumpycr/pcf-parser
...
```
3. `shards install`
### Read a font file
``` crystal
require "pcf-parser"
font = PCFParser::Font.from_file("./font.pcf")
# look up chars by their "name" (e.g. 'A', 'B') or their "number" (e.g. 65)
#
# font.lookup("test") returns an array of characters
char = font.lookup('A')
height = char.ascent + char.descent
width = char.width
(0...height).each do |y|
(0...width).each do |x|
print char.get(x, y) ? "#" : " "
end
print "\n"
end
```
__Output:__
```
##
####
## ##
## ##
## ##
## ##
## ##
########
## ##
## ##
## ##
## ##
## ##
```
## TODO
* Implement support for reverse bit order
* Documentation
* Add a collection of `.pcf` fonts