pax_global_header00006660000000000000000000000064127757676670014550gustar00rootroot0000000000000052 comment=14b2b1a2a5dd23adac04950267225fad4ecc223f braillefont-1.0/000077500000000000000000000000001277576766700137115ustar00rootroot00000000000000braillefont-1.0/.gitignore000066400000000000000000000000351277576766700156770ustar00rootroot00000000000000*~ *.o braillefont 6x8font.h braillefont-1.0/6x8.png000066400000000000000000000017601277576766700150500ustar00rootroot00000000000000PNG  IHDRPLTEU~IDAT8˽oE߮7,eZQ5޺TrSv8@B_ ;\jqo\2^Wr"r\D "Ki/Y $ FWogM|Q^x2@ V͆'wx۾=HD;\mF`N_3ٳy1%[ "d qrluLPj)]DĄ)~`_1t׭j&O|-uu`^c]rcr Z jQ B]zL[&%pJќh?%2$V;{oxYxUwNjfQLK Xjٲ#d"+fS]n)}?/60`Cš`*༽9$l&C 9:/4إ i6j`=v#3hǬt+vC 7h>5n̊QZf%FWyCdq 򲚁`w56B _,[kd4IENDB`braillefont-1.0/LICENSE000066400000000000000000000002161277576766700147150ustar00rootroot00000000000000CC0 I hereby disclaim all copyright and related rights on this work, dedicating it to the Public Domain. Adam Borowski braillefont-1.0/Makefile000066400000000000000000000003661277576766700153560ustar00rootroot00000000000000all: braillefont clean: rm -f braillefont braillefont.o 6x8font.h braillefont: braillefont.o $(CC) -std=c99 -Wall $^ -o $@ braillefont.o: braillefont.c 6x8font.h $(CC) -std=c99 -Wall -c $< 6x8font.h: png2font 6x8.png ./png2font >6x8font.h braillefont-1.0/README.md000066400000000000000000000020451277576766700151710ustar00rootroot00000000000000# braillefont This hack will convert a given text to a bitmapped version using the Braille range of Unicode. Individual characters use a grid of 6x8 (5x7 usable) "pixels" which are rendered by 3x2 blocks of Unicode characters. The result: ⡇⠀⠀⡠⠤⡀⣄⠤⡀⡠⠤⡀⡠⡠⡀⠀⠀⠀⠠⡅⠀⡤⠤⡀⡠⠤⠄⡄⠀⡄⡠⡠⡀ ⠧⠤⠄⠣⠤⠃⠇⠀⠀⠫⠭⠁⠇⠁⠇⠀⠀⠀⠀⠣⠀⡗⠒⠁⠬⠭⠂⠣⠤⠃⠇⠁⠇ Whether it is readable strongly depends on font used by your reader. Most fonts produce a nice well-aligned grid, some introduce unsightly gaps at character boundaries, unfortunately one (FreeFont Mono) follows the Unicode specification by rendering "off" pixels, which makes it completely unreadable at font sizes usually used for terminals. This applies to legitimate uses of Braille, not just this abuse. A fix for FreeFont is available but hasn't been released yet. The problem is, Freefont is installed by default on most distributions, and in many cases it gets chosen as fallback for Braille glyphs. braillefont-1.0/braillefont.c000066400000000000000000000033731277576766700163640ustar00rootroot00000000000000#include #include #include const char *font = #include "6x8font.h" ; #define L (8*6) #define R (L*8) static void phalf(unsigned char c, int offset) { for (int x = 0; x < 3; x++) { int o = c%8*6 + x*2 + (int)(c/8-4)*R + offset; int g = 0; if (font[o + 0 + 0*L] == '*') g+=1; if (font[o + 1 + 0*L] == '*') g+=8; if (font[o + 0 + 1*L] == '*') g+=2; if (font[o + 1 + 1*L] == '*') g+=16; if (font[o + 0 + 2*L] == '*') g+=4; if (font[o + 1 + 2*L] == '*') g+=32; if (font[o + 0 + 3*L] == '*') g+=64; // irregular if (font[o + 1 + 3*L] == '*') g+=128; // print Unicode codepoint 0x2800+g, as UTF-8. printf("%c%c%c", 0xe2, 0xa0+g/64, 0x80+g%64); } } static short win1252[32]= { 0x20ac, -1, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, -1, 0x017d, -1, -1, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, -1, 0x017e, 0x0178, }; static wchar_t map_character(wchar_t c) { if (c < 256) return c; for (int i=0; i<32; i++) if (c==win1252[i]) return 128+i; return 127; } int main() { wchar_t buf[1024]; setlocale(LC_CTYPE, ""); while (fgetws(buf, sizeof(buf), stdin)) { const wchar_t *b; for (b=buf; *b; b++) { if (*b < 32) printf("%c", *b); else phalf(map_character(*b), 0); } for (b=buf; *b; b++) { if (*b < 32) printf("%c", *b); else phalf(map_character(*b), 4*L); } } return 0; } braillefont-1.0/png2font000077500000000000000000000006251277576766700153770ustar00rootroot00000000000000#!/usr/bin/perl -w use GD; my $img = new GD::Image("6x8.png") or die; for my $cy (4..31) { for my $y (0..7) { for my $cx (0..7) { print ' "'; my $c = $cy*8+$cx; for my $x (0..5) { print $img->getPixel($c*6+$x, $y) ? "*":"."; } print '"'; } print "\n"; } print "\n"; }