Add support for arbitrary font widths. Only multiples of 8 were supported.
Since the font format is undocumented, it is unclear how non-multiples of 8 should be padded to bytes in the font file. Use the same representation as bdf text format (big- endian, with padding in the lower bits).
This commit is contained in:
parent
9ceb90b2b6
commit
dd38752cb9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345483
@ -66,7 +66,7 @@ FILE *fd;
|
|||||||
VGLTextFont->BitmapArray =
|
VGLTextFont->BitmapArray =
|
||||||
(byte*)malloc(256*((VGLTextFont->Width + 7)/8)*VGLTextFont->Height);
|
(byte*)malloc(256*((VGLTextFont->Width + 7)/8)*VGLTextFont->Height);
|
||||||
fread(VGLTextFont->BitmapArray, 1,
|
fread(VGLTextFont->BitmapArray, 1,
|
||||||
(256*VGLTextFont->Width* VGLTextFont->Height), fd);
|
(256*((VGLTextFont->Width + 7)/8)*VGLTextFont->Height), fd);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -76,44 +76,48 @@ void
|
|||||||
VGLBitmapPutChar(VGLBitmap *Object, int x, int y, byte ch,
|
VGLBitmapPutChar(VGLBitmap *Object, int x, int y, byte ch,
|
||||||
byte fgcol, byte bgcol, int fill, int dir)
|
byte fgcol, byte bgcol, int fill, int dir)
|
||||||
{
|
{
|
||||||
int lin, bit;
|
int b, Bpc, Bpl, lin, bit, topbit;
|
||||||
|
|
||||||
|
Bpl = (VGLTextFont->Width + 7) / 8;
|
||||||
|
Bpc = Bpl * VGLTextFont->Height;
|
||||||
|
topbit = VGLTextFont->Width - 1;
|
||||||
for(lin = 0; lin < VGLTextFont->Height; lin++) {
|
for(lin = 0; lin < VGLTextFont->Height; lin++) {
|
||||||
for(bit = 0; bit < VGLTextFont->Width; bit++) {
|
for(bit = 0; bit < VGLTextFont->Width; bit++) {
|
||||||
if (VGLTextFont->BitmapArray[((ch*VGLTextFont->Height)+lin)]&(1<<bit))
|
b = bit + (-VGLTextFont->Width & 7);
|
||||||
|
if (VGLTextFont->BitmapArray[(ch*Bpc)+(lin*Bpl)+(b/8)]&(1<<(b%8)))
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
case 0:
|
case 0:
|
||||||
VGLSetXY(Object, (x+7-bit), (y+lin), fgcol);
|
VGLSetXY(Object, (x+topbit-bit), (y+lin), fgcol);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
VGLSetXY(Object, (x+lin), (y-7+bit), fgcol);
|
VGLSetXY(Object, (x+lin), (y-topbit+bit), fgcol);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
VGLSetXY(Object, (x-7+bit), (y-lin), fgcol);
|
VGLSetXY(Object, (x-topbit+bit), (y-lin), fgcol);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
VGLSetXY(Object, (x-lin), (y+7-bit), fgcol);
|
VGLSetXY(Object, (x-lin), (y+topbit-bit), fgcol);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
VGLSetXY(Object, (x+lin+7-bit), (y+lin+bit), fgcol);
|
VGLSetXY(Object, (x+lin+topbit-bit), (y+lin+bit), fgcol);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (fill)
|
else if (fill)
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
case 0:
|
case 0:
|
||||||
VGLSetXY(Object, (x+7-bit), (y+lin), bgcol);
|
VGLSetXY(Object, (x+topbit-bit), (y+lin), bgcol);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
VGLSetXY(Object, (x+lin), (y-7+bit), bgcol);
|
VGLSetXY(Object, (x+lin), (y-topbit+bit), bgcol);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
VGLSetXY(Object, (x-7+bit), (y-lin), bgcol);
|
VGLSetXY(Object, (x-topbit+bit), (y-lin), bgcol);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
VGLSetXY(Object, (x-lin), (y+7-bit), bgcol);
|
VGLSetXY(Object, (x-lin), (y+topbit-bit), bgcol);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
VGLSetXY(Object, (x+lin+7-bit), (y+lin+bit), bgcol);
|
VGLSetXY(Object, (x+lin+topbit-bit), (y+lin+bit), bgcol);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user