skrift-boxdrawing
A Skrift plugin that renders Unicode box-drawing characters (U+2500–U+257F) as crisp alpha buffers for a given cell size, independent of any font. Fonts vary wildly in how (and whether) they draw the box-drawing block; rendering it geometrically gives pixel-accurate, seam-free boxes at any size — useful for terminals, TUIs and bars.
It has no X11 (or any platform) dependency: it produces Skrift::Image alpha
buffers, which you composite however you like.
Usage
Wire it into a Skrift::GlyphCache through the special: hook, so box-drawing
codepoints are drawn geometrically and everything else falls through to the
font:
require "skrift"
require "skrift/boxdrawing"
boxes = nil
cache = Skrift::GlyphCache.new("DejaVuSansMono.ttf", x_scale: 16, y_scale: 16,
special: ->(cp) { boxes.glyph(cp) })
boxes = Skrift::BoxDrawing.new(cache.cell_width, cache.cell_height)
cache.glyph(0x2500) # => a horizontal-line RenderedGlyph, not the font's glyph
Or use it directly:
boxes = Skrift::BoxDrawing.new(cell_width, cell_height)
img = boxes.glyph(0x250C) # => Skrift::Image (alpha), or nil if cp isn't a box char
License
ISC. See LICENSE.txt.