Check-in [5d5253b6c6]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Work in progress on a 5x7 dot matrix font with nearly circular dots. Covers codes 0x21 thru 0x47. Plan is to complete the 96 printable ASCII slots. Modeled after the character generator ROM in the popular HD44780 LCD controller chip.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5d5253b6c644c9aa92a3479a42f30316f24435af
User & Date: Ross 2016-03-10 01:02:42
Context
2016-03-10
21:06
Punched paper tape font, fed starting from left, with bit 0 at the top edge. Set at 72 point for approximately 100% scale of real paper tape. check-in: 3eea976223 user: Ross tags: trunk
01:02
Work in progress on a 5x7 dot matrix font with nearly circular dots. Covers codes 0x21 thru 0x47. Plan is to complete the 96 printable ASCII slots. Modeled after the character generator ROM in the popular HD44780 LCD controller chip. check-in: 5d5253b6c6 user: Ross tags: trunk
2015-12-31
01:52
Add a demostration of how to make kerning pairs. check-in: fd4cf2422a user: Ross tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/Makefile.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
all: dots.ttf dots.pdf



%.ttf: %.ttx
	ttx -f -o $@ $^

%.pdf: %.tex
	lualatex --interaction=nonstopmode $*.tex 
	lualatex --interaction=batchmode $*.tex

%.pdf: %.ttf
	fret -g -o $@ $^


testdots.pdf: testdots.tex dots.ttf
testdots.tex: testdots.txt
	pandoc --standalone --smart -f markdown --to latex -o $@ $*.txt












|





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
all: dots.ttf dots.pdf



%.ttf: %.ttx
	ttx -f -o $@ $^

%.pdf: %.tex
	lualatex --interaction=nonstopmode $*.tex 
	lualatex --interaction=batchmode $*.tex

%.pdf: %.ttf
	fret -s letter -g -oi $^ $@


testdots.pdf: testdots.tex dots.ttf
testdots.tex: testdots.txt
	pandoc --standalone --smart -f markdown --to latex -o $@ $*.txt

Changes to src/dotfonter.lua.

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local ok, dotfont = pcall(dofile, args.basename .. ".dotfont")
if not ok then 
    print(args.basename, ':', dotfont)
    os.exit(1)
end
V('loaded: ', args.basename, '.dotfont')

-- Run through the caracters in the rom and assemble a glyph for each
-- one and map in in the font.
local n = 0
for _,glyph in ipairs(dotfont.Glyphs) do
    ttfont.PlaceGlyph(glyph)
    ttfont.MapGlyph("unicode", glyph.unicode, glyph.name)
    if glyph.mac then
        ttfont.MapGlyph("mac", glyph.mac, glyph.name)







|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local ok, dotfont = pcall(dofile, args.basename .. ".dotfont")
if not ok then 
    print(args.basename, ':', dotfont)
    os.exit(1)
end
V('loaded: ', args.basename, '.dotfont')

-- Run through the characters in the rom and assemble a glyph for each
-- one and map in in the font.
local n = 0
for _,glyph in ipairs(dotfont.Glyphs) do
    ttfont.PlaceGlyph(glyph)
    ttfont.MapGlyph("unicode", glyph.unicode, glyph.name)
    if glyph.mac then
        ttfont.MapGlyph("mac", glyph.mac, glyph.name)

Added src/fivebyseven.dotfont.







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
--[[ 
#Five by Seven Dot Matrix for dotfonter
--]]

--[[
#License
Copyright (C) 2015 Cheshire Engineering Corp.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--]]


--[[
##Dot Matrix display contours

These are drawn on a design grid with 1024 units per em. Assuming a
dot pitch of 128 units, the 5x7 dot bounding box is 640x896 units.

We'll draw a dot as a nearly circular blob filling a little less 
than 60% of the available area, or fitting in a 110 units square. 
That will leave about 18 units between dots.

]]
local dot = {
    {  9,  64, 1},
    { 13,  13, 0},
    { 64,   9, 1},
    {115,  13, 0},
    {119,  64, 1},
    {115, 115, 0},
    { 64, 119, 1},
    { 13, 115, 0},
}
local function dotat(r,c)
    local t={}
    for i=1,#dot do
        t[i] = { dot[i][1]+c*128, dot[i][2]+r*128, dot[i][3] }
    end
    return t
end
local function patdot(pat,r,c)
    local row = pat[r+1] or '.....'
    local dot = row:sub(c+1,c+1) 
    return dot == '#' or dot == 'X' or dot == '*'
end

-- Normalize a a glyph in the character ROM. 
-- Create an array of countours from its pat entry and provide defaults 
-- for metrics, name, and character codes.
local function Glyph(t)
    assert(type(t)=='table')
    local pat = assert(t.pat)
    
    -- default metrics
    t.width = t.width or 1024
    t.lsb = t.lsb or 9
    t.a, t.d = t.a or 896, t.d or 0
    
    -- default mapping
    assert(t.name)
    if not t.unicode then t.unicode = t.name:byte() end
    if not t.mac and t.unicode < 127 then t.mac = t.unicode end
    if not t.win then t.win = t.unicode end
    
    -- fill out array of contours
    local lc = 7
    for r=6,-1,-1 do
        for c=0,4,1 do
            if patdot(pat,6-r,c) then
                t[#t+1] = dotat(r,c)
                if c < lc then lc = c end
            end
        end
    end
    t.lsb = 9 + lc*128
    return t
end

--[[ 
##Dot matrix character generator ROM

Each character is a table, passed through the Glyph function above.
The table has the pattern at pat, and optionally includes fields named
n for name, lsb for left side bearing, a for ascent, d for descent, 
width for width, and more.

To make these easy to draw and edit, the character pattern itself will 
be represented as an array of strings, one string for each row. Cells 
containing '#' are lit. Other cells (by convention containing '.' ) are not 
lit.

--]]
return {
    Glyphs = {
--[[
        Glyph{unicode=0x20, name='space', pat={
                '.....',
                '.....',
                '.....',
                '.....',
                '.....',
                '.....',
                '.....',
            }
        },
--]]
        Glyph{unicode=0x21, name='exclam', pat={
                '..#..',
                '..#..',
                '..#..',
                '..#..',
                '.....',
                '.....',
                '..#..',
            }
        },
        Glyph{unicode=0x22, name='quotdbl', pat={
                '.#.#.',
                '.#.#.',
                '.#.#.',
                '.....',
                '.....',
                '.....',
                '.....',
            }
        },
        Glyph{unicode=0x23, name='numbersign', pat={
                '.#.#.',
                '.#.#.',
                '#####',
                '.#.#.',
                '#####',
                '.#.#.',
                '.#.#.',
            }
        },
        Glyph{unicode=0x24, name='dollar', pat={
                '..#..',
                '.####',
                '#.#..',
                '.###.',
                '..#.#',
                '####.',
                '..#..',
            }
        },
        Glyph{unicode=0x25, name='percent', pat={
                '##...',
                '##..#',
                '...#.',
                '..#..',
                '.#...',
                '#..##',
                '...##',
            }
        },
        Glyph{unicode=0x26, name='ampersand', pat={
                '.##..',
                '#..#.',
                '#.#..',
                '.#...',
                '#.#.#',
                '#..#.',
                '.##.#',
            }
        },
        Glyph{unicode=0x27, name='quotesingle', pat={
                '.##..',
                '..#..',
                '.#...',
                '.....',
                '.....',
                '.....',
                '.....',
            }
        },
        Glyph{unicode=0x28, name='parenleft', pat={
                '...#.',
                '..#..',
                '.#...',
                '.#...',
                '.#...',
                '..#..',
                '...#.',
            }
        },
        Glyph{unicode=0x29, name='parenright', pat={
                '.#...',
                '..#..',
                '...#.',
                '...#.',
                '...#.',
                '..#..',
                '.#...',
            }
        },
        Glyph{unicode=0x2a, name='astrisk', pat={
                '.....',
                '..#..',
                '#.#.#',
                '.###.',
                '#.#.#',
                '..#..',
                '.....',
            }
        },
        Glyph{unicode=0x2b, name='plus', pat={
                '.....',
                '..#..',
                '..#..',
                '#####',
                '..#..',
                '..#..',
                '.....',
            }
        },
        Glyph{unicode=0x2c, name='comma', pat={
                '.....',
                '.....',
                '.....',
                '.....',
                '.##..',
                '..#..',
                '.#...',
            }
        },
        Glyph{unicode=0x2d, name='hyphen', pat={
                '.....',
                '.....',
                '.....',
                '#####',
                '.....',
                '.....',
                '.....',
            }
        },
        Glyph{unicode=0x2e, name='period', pat={
                '.....',
                '.....',
                '.....',
                '.....',
                '.....',
                '.##..',
                '.##..',
            }
        },
        Glyph{unicode=0x2f, name='slash', pat={
                '.....',
                '....#',
                '...#.',
                '..#..',
                '.#...',
                '#....',
                '.....',
            }
        },
        
        Glyph{unicode=0x30, name='zero', pat={
                '.###.',
                '#...#',
                '#..##',
                '#.#.#',
                '##..#',
                '#...#',
                '.###.',
            }
        },
        Glyph{unicode=0x31, name='one', pat={
                '..#..',
                '.##..',
                '..#..',
                '..#..',
                '..#..',
                '..#..',
                '.###.',
            }
        },
        Glyph{unicode=0x32, name='two', pat={
                '.###.',
                '#...#',
                '....#',
                '...#.',
                '..#..',
                '.#...',
                '#####',
            }
        },
        Glyph{unicode=0x33, name='three', pat={
                '#####',
                '...#.',
                '..#..',
                '...#.',
                '....#',
                '#...#',
                '.###.',
            }
        },
        Glyph{unicode=0x34, name='four', pat={
                '...#.',
                '..##.',
                '.#.#.',
                '#..#.',
                '#####',
                '...#.',
                '...#.',
            }
        },
        Glyph{unicode=0x35, name='five', pat={
                '#####',
                '#....',
                '####.',
                '....#',
                '....#',
                '#...#',
                '.###.',
            }
        },
        Glyph{unicode=0x36, name='six', pat={
                '...##',
                '..#..',
                '.#...',
                '####.',
                '#...#',
                '#...#',
                '.###.',
            }
        }, 
        Glyph{unicode=0x37, name='seven', pat={
                '#####',
                '#...#',
                '....#',
                '...#.',
                '..#..',
                '..#..',
                '..#..',
            }
        },
        Glyph{unicode=0x38, name='eight', pat={
                '.###.',
                '#...#',
                '#...#',
                '.###.',
                '#...#',
                '#...#',
                '.###.',
            }
        },
        Glyph{unicode=0x39, name='nine', pat={
                '.###.',
                '#...#',
                '#...#',
                '.####',
                '....#',
                '...#.',
                '.##..',
            }
        },
        Glyph{unicode=0x3a, name='colon', pat={
                '.....',
                '.##..',
                '.##..',
                '.....',
                '.##..',
                '.##..',
                '.....',
            }
        },
        Glyph{unicode=0x3b, name='semicolon', pat={
                '.....',
                '.##..',
                '.##..',
                '.....',
                '.##..',
                '..#..',
                '.#...',
            }
        },
        Glyph{unicode=0x3c, name='less', pat={
                '...#.',
                '..#..',
                '.#...',
                '#....',
                '.#...',
                '..#..',
                '...#.',
            }
        },
        Glyph{unicode=0x3d, name='equal', pat={
                '.....',
                '.....',
                '#####',
                '.....',
                '#####',
                '.....',
                '.....',
            }
        },
        Glyph{unicode=0x3e, name='greater', pat={
                '.#...',
                '..#..',
                '...#.',
                '....#',
                '...#.',
                '..#..',
                '.#...',
            }
        },
        Glyph{unicode=0x3f, name='question', pat={
                '.###.',
                '#...#',
                '....#',
                '...#.',
                '..#..',
                '.....',
                '..#..',
            }
        },
        Glyph{unicode=0x40, name='at', pat={
                '.###.',
                '#...#',
                '....#',
                '.##.#',
                '#.#.#',
                '#.#.#',
                '.###.',
            }
        },
        Glyph{unicode=0x41, name='A', pat={
                '.###.',
                '#...#',
                '#...#',
                '#...#',
                '#####',
                '#...#',
                '#...#',
            }
        },
        Glyph{unicode=0x42, name='B', pat={
                '####.',
                '#...#',
                '#...#',
                '####.',
                '#...#',
                '#...#',
                '####.',
            }
        },
        Glyph{unicode=0x43, name='C', pat={
                '.###.',
                '#...#',
                '#....',
                '#....',
                '#....',
                '#...#',
                '.###.',
            }
        },
        Glyph{unicode=0x44, name='D', pat={
                '###..',
                '#..#.',
                '#...#',
                '#...#',
                '#...#',
                '#..#.',
                '###..',
            }
        },
        Glyph{unicode=0x45, name='E', pat={
                '#####',
                '#....',
                '#....',
                '####.',
                '#....',
                '#....',
                '#####',
            }
        },
        Glyph{unicode=0x46, name='F', pat={
                '#####',
                '#....',
                '#....',
                '####.',
                '#....',
                '#....',
                '#....',
            }
        },
        Glyph{unicode=0x47, name='G', pat={
                '.###.',
                '#...#',
                '#....',
                '#.###',
                '#...#',
                '#...#',
                '.####',
            }
        },
        
        
        
        
        Glyph{unicode=0xff, name='BLOCK', pat={
                '#####',
                '#####',
                '#####',
                '#####',
                '#####',
                '#####',
                '#####',
            }
        },

    },

    --[[ Set the strings. 

    Note that ffam, fsub, ufid, name, vers, and PSnm are required by Windows.
    Of those, fsub defaults to 'Regular' and name gets a sensible defaults based
    on ffam and fsub.

    --]]
    Names = {
        copy='Copyright Ross Berteig 2016.',
        ffam='Upright Five by Seven Dot Matrix',
        PSnm='UprightFiveSevenDots-Regular',
        ufid='Upright 5x7 Dot Matrix '.. os.date"%Y-%m-%d" ,
        vers='Version 001.000',
        demo='0123456789',
    }
}