Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/vtfontcvt/vtfontcvt.c
Show First 20 Lines • Show All 329 Lines • ▼ Show 20 Lines | if (strncmp(ln, "FONT ", 5) == 0) { | ||||
while ((p = strchr(p, '-')) != NULL) { | while ((p = strchr(p, '-')) != NULL) { | ||||
p++; | p++; | ||||
i++; | i++; | ||||
if (i == 11) { | if (i == 11) { | ||||
spc = *p; | spc = *p; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} else if (strncmp(ln, "FONTBOUNDINGBOX ", 16) == 0) { | } else if (strncmp(ln, "FONTBOUNDINGBOX ", 16) == 0 && | ||||
if (sscanf(ln + 16, "%d %d %d %d", &fbbw, &fbbh, &fbbox, | sscanf(ln + 16, "%d %d %d %d", &fbbw, &fbbh, &fbbox, | ||||
&fbboy) != 4) | &fbboy) == 4) { | ||||
errx(1, "invalid FONTBOUNDINGBOX at line %u", | |||||
linenum); | |||||
set_width(fbbw); | set_width(fbbw); | ||||
set_height(fbbh); | set_height(fbbh); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (fbbw == 0) | if (fbbw == 0) | ||||
errx(1, "broken font header"); | errx(1, "broken font header"); | ||||
if (spc != 'c' && spc != 'C') | if (spc != 'c' && spc != 'C') | ||||
errx(1, "font spacing \"C\" (character cell) required"); | errx(1, "font spacing \"C\" (character cell) required"); | ||||
/* Step 2: Validate DWIDTH (Device Width) of all glyphs. */ | /* Step 2: Validate DWIDTH (Device Width) of all glyphs. */ | ||||
while ((ln = fgetln(fp, &length)) != NULL) { | while ((ln = fgetln(fp, &length)) != NULL) { | ||||
linenum++; | linenum++; | ||||
ln[length - 1] = '\0'; | ln[length - 1] = '\0'; | ||||
if (strncmp(ln, "DWIDTH ", 7) == 0) { | if (strncmp(ln, "DWIDTH ", 7) == 0 && | ||||
if (sscanf(ln + 7, "%d %d", &dwidth, &dwy) != 2) | sscanf(ln + 7, "%d %d", &dwidth, &dwy) == 2) { | ||||
errx(1, "invalid DWIDTH at line %u", linenum); | |||||
if (dwy != 0 || (dwidth != fbbw && dwidth * 2 != fbbw)) | if (dwy != 0 || (dwidth != fbbw && dwidth * 2 != fbbw)) | ||||
errx(1, "bitmap with unsupported DWIDTH %d %d at line %u", | errx(1, "bitmap with unsupported DWIDTH %d %d at line %u", | ||||
dwidth, dwy, linenum); | dwidth, dwy, linenum); | ||||
if (dwidth < fbbw) | if (dwidth < fbbw) | ||||
set_width(dwidth); | set_width(dwidth); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 395 Lines • Show Last 20 Lines |