summaryrefslogtreecommitdiff
path: root/src/rufl_substitution_table.c
blob: 51c5b7a2cb06befda0b87dc717cb257a5684247b (plain)
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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
/*
 * This file is part of RUfl
 * Licensed under the MIT License,
 *                http://www.opensource.org/licenses/mit-license
 * Copyright 2006 James Bursa <james@semichrome.net>
 */

#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "rufl_internal.h"

#undef RUFL_SUBSTITUTION_TABLE_DEBUG

/**
 * A perfect hash constructed at library initialisation time using the
 * CHD algorithm. Hash entries are found via a two-step process:
 *
 *   1. apply a first-stage hash to the key to find the bucket
 *      in which the corresponding entry should be found.
 *   2. apply a second-stage hash to the key and the stored
 *      displacement value for the bucket to find the index
 *      into the substitution table.
 */
struct rufl_substitution_table {
	uint32_t num_buckets; /**< Number of buckets in the hash */
	uint32_t num_slots; /**< Number of slots in the table */
	/** Substitution table.
	 *
	 * Fields in the substitution table have the following format:
	 *
	 *    3                   2                   1                   0
	 *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	 * |      Reserved       |            Unicode codepoint            |
	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	 * |            Reserved           |        Font identifier        |
	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	 *
	 * where:
	 *
	 *   reserved: 11 bits/16 bits
	 *     These bits are currently unused and must be set to 0.
	 *
	 *   unicode codepoint: 21 bits
	 *     The Unicode codepoint value.
	 *
	 *   font identifier: 16 bits
	 *     The index into rufl_font_list of a font providing a
	 *     substitution glyph for this codepoint or NOT_AVAILABLE.
	 *
	 * Note that, as the substitution table is sparse and may not be
	 * fully populated, it is necessary to verify that the Unicode
	 * codepoint matches the key being hashed and that the font
	 * identifier is not NOT_AVAILABLE. If either of these tests
	 * fail, no font provides a suitable glyph and the not available
	 * path should be taken.
	 */
	uint64_t *table;
	uint8_t bits_per_entry; /**< Bits per displacement bitmap entry */
	/** Displacement bitmap.
	 *
	 * The displacement values are stored in a bitmap of num_buckets
	 * fields each being bits_per_entry wide. Both values are computed
	 * at runtime.
	 */
	uint8_t displacement_map[];
};
/** Font substitution table */
static struct rufl_substitution_table *rufl_substitution_table;

/**
 * Round an unsigned 32bit value up to the next power of 2
 */
static uint32_t ceil2(uint32_t val)
{
	val--;
	val |= (val >> 1);
	val |= (val >> 2);
	val |= (val >> 4);
	val |= (val >> 8);
	val |= (val >> 16);
	val++;
	val += (val == 0);
	return val;
}

/**
 * Compute the number of bits needed to store a value
 */
static uint32_t bits_needed(uint32_t val)
{
	int32_t result = 0;

	if (val == 0)
		return 1;

	if ((val & (val - 1))) {
		/* Not a power of 2: round up */
		val = ceil2(val);
		/* Will need one fewer bit than we're about to count */
		result = -1;
	}

	while (val > 0) {
		result += 1;
		val >>= 1;
	}

	return (uint32_t) result;
}

/**
 * Perform one round of MurmurHash2
 */
static uint32_t mround(uint32_t val, uint32_t s)
{
	val *= 0x5db1e995;
	val ^= (val >> 24);
	val *= 0x5db1e995;
	val ^= (s * 0x5db1e995);

	return val;
}

/**
 * Perform the MurmurHash2 mixing step
 */
static uint32_t mmix(uint32_t val)
{
	val ^= (val >> 13);
	val *= 0x5db1e995;
	val ^= (val >> 15);

	return val;
}

/**
 * First-stage hash (i.e. g(x)) for substitution table.
 *
 * As we know that the input values are Unicode codepoints,
 * do some trivial bit manipulation, which has reasonable
 * distribution properties.
 */
static uint32_t hash1(uint32_t val)
{
	val ^= (val >> 7);
	val ^= (val << 3);
	val ^= (val >> 4);
	return val;
}

/**
 * Second-stage hash (i.e. f(d, x)) for substitution table.
 *
 * Apply MurmurHash2 to the value and displacement
 */
static uint32_t hash2(uint32_t val, uint32_t d)
{
	return mmix(mround(val, mround(d, 4)));
}

/**
 * Comparison function for table entries.
 *
 * We use this when sorting the intermediate table for CHD.
 */
static int table_chd_cmp(const void *a, const void *b)
{
	/* We're only interested in the CHD metadata here.
	 * (i.e. the computed value of g(x) and the bucket size) */
	const uint64_t aa = (*(const uint64_t *) a) & 0x3fe00000ffff0000llu;
	const uint64_t bb = (*(const uint64_t *) b) & 0x3fe00000ffff0000llu;

	if (aa > bb)
		return -1;
	else if (aa < bb)
		return 1;
	return 0;
}

/**
 * Test that all specified bits in a bit map are clear and set them if so.
 *
 * \param bitmap Bit map to inspect
 * \param idx    Table of indices to inspect
 * \param len    Number of entries in index table
 * \return True if all bits were clear. False otherwise.
 */
static bool test_and_set_bits(uint8_t *bitmap, const uint32_t *idx, size_t len)
{
	unsigned int i;
	bool result = true;

	/* Test if all specified bits are clear */
	for (i = 0; i != len; i++) {
		const uint32_t byte = (idx[i] >> 3);
		const uint32_t bit = (idx[i] & 0x7);

		result &= ((bitmap[byte] & (1 << bit)) == 0);
	}

	if (result) {
		/* They are, so set them */
		for (i = 0; i != len; i++) {
			const uint32_t byte = (idx[i] >> 3);
			const uint32_t bit = (idx[i] & 0x7);

			bitmap[byte] |= (1 << bit);
		}
	}

	return result;
}

/**
 * Create the final substitution table from the intermediate parts
 *
 * \param table               Substitution table
 * \param table_entries       Number of entries in table
 * \param buckets             Number of CHD buckets
 * \param range               Number of slots in final table
 * \param max_displacement    max(displacements)
 * \param displacements       Table of displacement values. One per bucket.
 * \param substitution_table  Location to receive result.
 */
static rufl_code create_substitution_table(uint64_t *table,
		size_t table_entries, uint32_t buckets, uint32_t range,
		uint32_t max_displacement, uint32_t *displacements,
		struct rufl_substitution_table **substitution_table)
{
	struct rufl_substitution_table *subst_table;
	size_t subst_table_size;
	unsigned int i;

#ifdef RUFL_SUBSTITUTION_TABLE_DEBUG
	LOG("max displacement of %u requires %u bits",
			max_displacement, bits_needed(max_displacement));
#endif

	subst_table_size = offsetof(struct rufl_substitution_table,
			displacement_map) +
			((buckets * bits_needed(max_displacement) + 7) >> 3);

	subst_table = calloc(subst_table_size, 1);
	if (!subst_table)
		return rufl_OUT_OF_MEMORY;

	/* We know there are at least table_entries in the table, but
	 * we should now resize it to the size of the target hashtable */
	subst_table->table = realloc(table, range * sizeof(*table));
	if (!subst_table->table) {
		free(subst_table);
		return rufl_OUT_OF_MEMORY;
	}
	/* Initialise unused slots */
	for (i = table_entries; i < range; i++) {
		subst_table->table[i] = NOT_AVAILABLE;
	}

	subst_table->num_buckets = buckets;
	subst_table->num_slots = range;
	subst_table->bits_per_entry = bits_needed(max_displacement);

	/* Fill in displacement map */
	//XXX: compress map using Fredriksson-Nikitin encoding?
	for (i = 0; i < buckets; i++) {
		uint32_t offset_bits = i * subst_table->bits_per_entry;
		uint32_t bits_to_write = subst_table->bits_per_entry;
		uint8_t *pwrite =
			&subst_table->displacement_map[offset_bits >> 3];

		offset_bits &= 7;

		while (bits_to_write > 0) {
			uint32_t space_available = (8 - offset_bits);
			uint32_t mask = 0, mask_idx;

			if (space_available > bits_to_write)
				space_available = bits_to_write;

			for (mask_idx = 0; mask_idx != space_available;
					mask_idx++) {
				mask <<= 1;
				mask |= 1;
			}

			*pwrite |= ((displacements[i] >>
				 (bits_to_write - space_available)) & mask) <<
				(8 - offset_bits - space_available);
			pwrite++;
			offset_bits = 0;
			bits_to_write -= space_available;
		}
	}

	/* Shuffle table data so the indices match the hash values */
	for (i = 0; i < table_entries; ) {
		uint32_t f, g;
		uint64_t tmp;

		if (subst_table->table[i] == NOT_AVAILABLE) {
			i++;
			continue;
		}

		g = ((subst_table->table[i] >> 53) & 0x1f0000) |
				((subst_table->table[i] >> 16) & 0xffff);
		f = hash2((subst_table->table[i] >> 32) & 0x1fffff,
				displacements[g]) & (range - 1);

		/* Exchange this entry with the one in the slot at f.*/
		if (f != i) {
			tmp = subst_table->table[f];
			subst_table->table[f] = subst_table->table[i];
			subst_table->table[i] = tmp;
		} else {
			/* Reconsider this slot unless it already
			 * had the correct entry */
			i++;
		}
	}
	/* Strip all the CHD metadata out of the final table */
	for (i = 0; i < range; i++)
		subst_table->table[i] &= 0x001fffff0000ffffllu;

	*substitution_table = subst_table;

	return rufl_OK;
}

/**
 * Compute a perfect hash to address the substitution table.
 *
 * We use the CHD algorithm to do this.
 * (https://doi.org/10.1007/978-3-642-04128-0_61 ;
 *  http://cmph.sourceforge.net/papers/esa09.pdf)
 *
 * A more recent alternative might be RecSplit
 * (https://arxiv.org/abs/1910.06416v2).
 *
 * \param table               Pre-filled table of raw substitution data
 * \param table_entries       Number of entries in the table
 * \param substitution_table  Location to receive result
 */
static rufl_code chd(uint64_t *table, size_t table_entries,
		struct rufl_substitution_table **substitution_table)
{
	/** Number of buckets assuming an average bucket size of 4 */
	const uint32_t buckets = ceil2((table_entries + 3) & ~3);
	/** Number of output hash slots assuming a load factor of 0.95 */
	const uint32_t range = ceil2((table_entries * 100)/95);
	uint32_t bucket_size, max_displacement = 0;
	unsigned int i;
	uint8_t *entries_per_bucket, *bitmap;
	uint32_t *displacements;
	rufl_code result = rufl_OK;

#ifdef RUFL_SUBSTITUTION_TABLE_DEBUG
	LOG("hashing %zu entries into %u buckets with range %u",
			table_entries, buckets, range);
#endif

	entries_per_bucket = calloc(buckets, sizeof(*entries_per_bucket));
	if (!entries_per_bucket)
		return rufl_OUT_OF_MEMORY;

	bitmap = calloc(range >> 3, 1);
	if (!bitmap) {
		free(entries_per_bucket);
		return rufl_OUT_OF_MEMORY;
	}

	displacements = calloc(buckets, sizeof(*displacements));
	if (!displacements) {
		free(bitmap);
		free(entries_per_bucket);
		return rufl_OUT_OF_MEMORY;
	}

	/* Compute g(x) for each entry, placing them into buckets */
	for (i = 0; i < table_entries; i++) {
		uint32_t g = hash1((table[i] >> 32) & 0x1fffff) & (buckets - 1);

		/* Insert hash into entry (it's 21 bits at most, so
		 * needs splitting between bits 16-31 and 53-57 of
		 * the entry) */
		table[i] |= ((g & 0xffff) << 16);
		table[i] |= ((uint64_t)(g & 0x1f0000) << 53);

		entries_per_bucket[g]++;
	}

	/* Inject bucket size into entries */
	for (i = 0; i < table_entries; i++) {
		uint32_t g = ((table[i] >> 53) & 0x1f0000) |
			((table[i] >> 16) & 0xffff);

		/* With a target bucket size of 4, do not expect
		 * >= twice that number of entries in the largest
		 * bucket. If there are, the hash function needs
		 * work (we allocate 4 bits for the bucket size,
		 * so should have sufficient headroom). */
		if (entries_per_bucket[g] >= 8)
			LOG("unexpectedly large bucket %u",
					entries_per_bucket[g]);

		/* Stash bucket size into bits 58-61 of the entry */
		table[i] |= ((uint64_t)entries_per_bucket[g] << 58);
	}

	/* Bits 62-63 of table entries are currently unused */

	free(entries_per_bucket);

	/* Sort entries in descending bucket size order */
	qsort(table, table_entries, sizeof(*table), table_chd_cmp);

	/* Compute f(x) for each bucket, finding a unique mapping */
	for (i = 0; i < table_entries; i += bucket_size) {
		const uint32_t g = ((table[i] >> 53) & 0x1f0000) |
			((table[i] >> 16) & 0xffff);
		uint32_t hashes[8], num_hashes;
		uint32_t d = 0;

		bucket_size = ((table[i] >> 58) & 0xf);

		do {
			uint32_t j, k;

			d++;
			num_hashes = 0;

			for (j = 0; j != bucket_size; j++) {
				uint32_t f = hash2(
					(table[i+j] >> 32) & 0x1fffff, d) &
					(range - 1);
				for (k = 0; k < num_hashes; k++) {
					if (f == hashes[k])
						break;
				}
				if (k == num_hashes) {
					hashes[num_hashes] = f;
					num_hashes++;
				}
			}
		} while (num_hashes != bucket_size || !test_and_set_bits(
				bitmap, hashes, num_hashes));

		displacements[g] = d;
		if (d > max_displacement)
			max_displacement = d;
	}

	free(bitmap);

	result = create_substitution_table(table, table_entries,
			buckets, range, max_displacement, displacements,
			substitution_table);
	free(displacements);

	return result;
}

/**
 * Populate the substitution map for a given block
 */
static void fill_map_for_block(const struct rufl_character_set **charsets,
		uint32_t block, uint16_t map_for_block[256])
{
	unsigned int i, u;

	for (i = 0; i != rufl_font_list_entries; i++) {
		if (!charsets[i])
			continue;

		if (charsets[i]->index[block] == BLOCK_FULL) {
			for (u = 0; u != 256; u++)
				if (map_for_block[u] == NOT_AVAILABLE)
					map_for_block[u] = i;
		} else if (charsets[i]->index[block] != BLOCK_EMPTY) {
			const uint8_t *blk = charsets[i]->block[
					charsets[i]->index[block]];
			for (u = 0; u != 256; u++) {
				if (map_for_block[u] == NOT_AVAILABLE &&
						(blk[(u>>3)] & (1 << (u&7)))) {
					map_for_block[u] = i;
				}
			}
		}
	}
}


/**
 * Construct the font substitution table.
 */

rufl_code rufl_substitution_table_init(void)
{
	unsigned int i;
	unsigned int plane, block;
	unsigned int u;
	const struct rufl_character_set **charsets;
	uint64_t *table;
	size_t table_size;
	size_t table_entries;
	rufl_code result;

	charsets = malloc(rufl_font_list_entries * sizeof(*charsets));
	if (!charsets) {
		LOG("malloc(%zu) failed",
				rufl_font_list_entries * sizeof(*charsets));
		return rufl_OUT_OF_MEMORY;
	}

	table = malloc(1024 * sizeof(*table));
	if (!table) {
		LOG("malloc(%zu) failed", 1024 * sizeof(*table));
		free(charsets);
		return rufl_OUT_OF_MEMORY;
	}
	table_size = 1024;
	table_entries = 0;

	for (plane = 0; plane < 17; plane++) {
		const struct rufl_character_set *charset;
		unsigned int num_charsets = 0;

		/* Find fonts that have charsets for this plane */
		for (i = 0; i != rufl_font_list_entries; i++) {
			charset = rufl_font_list[i].charset;
			if (!charset) {
				charsets[i] = NULL;
				continue;
			}

			while (PLANE_ID(charset->metadata) != plane &&
					EXTENSION_FOLLOWS(charset->metadata)) {
				charset = (void *)(((uint8_t *)charset) +
						PLANE_SIZE(charset->metadata));
			}
			if (PLANE_ID(charset->metadata) != plane)
				charset = NULL;
			charsets[i] = charset;
			num_charsets++;
		}
		if (num_charsets == 0)
			continue;

		/* Process each block, finding fonts that have glyphs */
		for (block = 0; block != 256; block++) {
			uint16_t map_for_block[256];
			memset(map_for_block, 0xff, 512);

			fill_map_for_block(charsets, block, map_for_block);

			/* Merge block map into table */
			for (i = 0; i != 256; i++) {
				if (map_for_block[i] == NOT_AVAILABLE)
					continue;

				u = (plane << 16) | (block << 8) | i;
				table[table_entries] = ((uint64_t) u << 32) |
							map_for_block[i];
				if (++table_entries == table_size) {
					uint64_t *tmp = realloc(table,
							2 * table_size *
							sizeof(*table));
					if (!tmp) {
						LOG("realloc(%zu) failed",
								2 * table_size *
								sizeof(*table));
						free(table);
						return rufl_OUT_OF_MEMORY;
					}

					table = tmp;
					table_size *= 2;
				}
			}
		}
	}

	/* Build hash from table */
	result = chd(table, table_entries, &rufl_substitution_table);

#ifdef RUFL_SUBSTITUTION_TABLE_DEBUG
	LOG("table size(%zu) entries %zu buckets(%u@%ubpe => %u)",
			rufl_substitution_table->num_slots * sizeof(*table),
			table_entries,
			rufl_substitution_table->num_buckets,
			rufl_substitution_table->bits_per_entry,
			(rufl_substitution_table->num_buckets *
			 rufl_substitution_table->bits_per_entry + 7) >> 3);
#endif

	free(charsets);

	return result;
}

/**
 * Destroy the substitution table and clean up its resources
 */

void rufl_substitution_table_fini(void)
{
	free(rufl_substitution_table->table);
	free(rufl_substitution_table);
	rufl_substitution_table = NULL;
}

/**
 * Look up a Unicode codepoint in the substitution table
 */

unsigned int rufl_substitution_table_lookup(uint32_t u)
{
	uint32_t displacement = 0;
	uint32_t f, g = hash1(u & 0x1ffffff) &
			(rufl_substitution_table->num_buckets - 1);
	uint32_t bits_to_read = rufl_substitution_table->bits_per_entry;
	uint32_t offset_bits = g * bits_to_read;
	const uint8_t *pread =
		&rufl_substitution_table->displacement_map[offset_bits >> 3];

	offset_bits &= 7;

	while (bits_to_read > 0) {
		uint32_t space_available = (8 - offset_bits);
		if (space_available > bits_to_read)
			space_available = bits_to_read;

		displacement <<= space_available;
		displacement |= (*pread & (0xff >> offset_bits)) >>
				(8 - space_available - offset_bits);

		offset_bits += space_available;
		if (offset_bits >= 8) {
			pread++;
			offset_bits = 0;
		}
		bits_to_read -= space_available;
	}

	f = hash2((u & 0x1fffff), displacement) &
			(rufl_substitution_table->num_slots - 1);

	if ((rufl_substitution_table->table[f] & 0xffff) != NOT_AVAILABLE &&
		((rufl_substitution_table->table[f] >> 32) & 0x1fffff) == u)
		return rufl_substitution_table->table[f] & 0xffff;

	return NOT_AVAILABLE;
}

static int table_dump_cmp(const void *a, const void *b)
{
	const uint64_t aa = (*(const uint64_t *) a) & 0x001fffff00000000llu;
	const uint64_t bb = (*(const uint64_t *) b) & 0x001fffff00000000llu;

	if (aa > bb)
		return 1;
	else if (aa < bb)
		return -1;
	return 0;
}

/**
 * Dump a representation of the substitution table to stdout.
 */

void rufl_substitution_table_dump(void)
{
	unsigned int font;
	unsigned int u, t;
	uint64_t *table;

	table = malloc(rufl_substitution_table->num_slots * sizeof(*table));
	if (table == NULL)
		return;

	memcpy(table, rufl_substitution_table->table,
			rufl_substitution_table->num_slots * sizeof(*table));

	qsort(table, rufl_substitution_table->num_slots, sizeof(*table),
			table_dump_cmp);

	u = 0;
	while (u < rufl_substitution_table->num_slots) {
		t = u;
		font = table[t] & 0xffff;
		while (u < rufl_substitution_table->num_slots &&
				font == (table[u] & 0xffff) &&
				((u == t) ||
				 (((table[u - 1] >> 32) & 0x1fffff) ==
				  (((table[u] >> 32) & 0x1fffff) - 1))))
			u++;
		if (font != NOT_AVAILABLE)
			printf("  %llx-%llx => %u \"%s\"\n",
					(table[t] >> 32) & 0x1fffff,
					(table[u - 1] >> 32) & 0x1fffff,
					font, rufl_font_list[font].identifier);
	}

	free(table);
}