View | Details | Raw Unified | Return to bug 205707 | Differences between
and this patch

Collapse All | Expand All

(-)vtfontcvt.c (-7 / +34 lines)
Lines 217-229 Link Here
217
	uint8_t *p;
217
	uint8_t *p;
218
	unsigned int i, subline;
218
	unsigned int i, subline;
219
219
220
	if (dwidth != width && dwidth != width * 2)
220
	if (dwidth > width * 2)
221
		errx(1, "Bitmap with unsupported width %u!", dwidth);
221
		errx(1, "Character too wide %u!", dwidth);
222
222
223
	/* Move pixel data right to simplify splitting double characters. */
223
	/* Move pixel data right to simplify splitting double characters. */
224
	line >>= (howmany(dwidth, 8) * 8) - dwidth;
224
	line >>= (howmany(dwidth, 8) * 8) - dwidth;
225
225
226
	for (i = dwidth / width; i > 0; i--) {
226
	for (i = howmany(dwidth, width); i > 0; i--) {
227
		p = (i == 2) ? right : left;
227
		p = (i == 2) ? right : left;
228
228
229
		subline = line & ((1 << width) - 1);
229
		subline = line & ((1 << width) - 1);
Lines 251-260 Link Here
251
	size_t length;
251
	size_t length;
252
	uint8_t bytes[wbytes * height], bytes_r[wbytes * height];
252
	uint8_t bytes[wbytes * height], bytes_r[wbytes * height];
253
	unsigned int curchar = 0, dwidth = 0, i, line;
253
	unsigned int curchar = 0, dwidth = 0, i, line;
254
	int bb_x = 0, bb_y = 0, bb_w = width, bb_h = height, line_y;
255
	int font_w = width, font_h = height, font_x = 0, font_y = 0;
254
256
255
	while ((ln = fgetln(fp, &length)) != NULL) {
257
	while ((ln = fgetln(fp, &length)) != NULL) {
256
		ln[length - 1] = '\0';
258
		ln[length - 1] = '\0';
257
259
260
		if (strncmp(ln, "FONTBOUNDINGBOX ", 16) == 0) {
261
			sscanf(ln + 16, "%d %d %d %d", &font_w, &font_h, &font_x, &font_y);
262
		}
263
258
		if (strncmp(ln, "ENCODING ", 9) == 0) {
264
		if (strncmp(ln, "ENCODING ", 9) == 0) {
259
			curchar = atoi(ln + 9);
265
			curchar = atoi(ln + 9);
260
		}
266
		}
Lines 263-282 Link Here
263
			dwidth = atoi(ln + 7);
269
			dwidth = atoi(ln + 7);
264
		}
270
		}
265
271
272
		if (strncmp(ln, "BBX ", 4) == 0) {
273
			sscanf(ln + 4, "%d %d %d %d", &bb_w, &bb_h, &bb_x, &bb_y);
274
		}
275
266
		if (strncmp(ln, "BITMAP", 6) == 0 &&
276
		if (strncmp(ln, "BITMAP", 6) == 0 &&
267
		    (ln[6] == ' ' || ln[6] == '\0')) {
277
		    (ln[6] == ' ' || ln[6] == '\0')) {
268
			for (i = 0; i < height; i++) {
278
			bzero(bytes, sizeof(bytes));
279
			bzero(bytes_r, sizeof(bytes_r));
280
281
			for (i = 0; ; i++) {
269
				if ((ln = fgetln(fp, &length)) == NULL)
282
				if ((ln = fgetln(fp, &length)) == NULL)
270
					errx(1, "Unexpected EOF!");
283
					errx(1, "Unexpected EOF!");
284
				if (strncmp(ln, "ENDCHAR", 7) == 0) {
285
					break;
286
				}
287
				line_y = height + font_y - bb_h - bb_y + i;
288
				if ((line_y < 0) || ((unsigned int)line_y >= height)) {
289
					continue;
290
				}
291
292
				if (bb_x > 0) {
293
					line >>= bb_x;
294
				} else {
295
					line <<= -bb_x;
296
				}
297
271
				ln[length - 1] = '\0';
298
				ln[length - 1] = '\0';
272
				sscanf(ln, "%x", &line);
299
				sscanf(ln, "%x", &line);
273
				if (parse_bitmap_line(bytes + i * wbytes,
300
				if (parse_bitmap_line(bytes + line_y * wbytes,
274
				     bytes_r + i * wbytes, line, dwidth) != 0)
301
				     bytes_r + line_y * wbytes, line, dwidth) != 0)
275
					return (1);
302
					return (1);
276
			}
303
			}
277
304
278
			if (add_char(curchar, map_idx, bytes,
305
			if (add_char(curchar, map_idx, bytes,
279
			    dwidth == width * 2 ? bytes_r : NULL) != 0)
306
			    dwidth > width ? bytes_r : NULL) != 0)
280
				return (1);
307
				return (1);
281
		}
308
		}
282
	}
309
	}

Return to bug 205707