Derek Leach <dleach@qnx.com> wrote:
Here is documentation. There is no supported editor for fonts.
This documentation covers QNX4 PHF (PHFv1) bitmap fonts only.
Great! PHF format is opened!
To Ron: see interval in fontdir for helvetica. It is 0020-00FF.
So in the font you have only characters with the UTF8 codes from
0020-00FF. If a character is outside the interval, it is substituted
by one from another font according to mapping, normaly I think it is
dutchs font 0020-20AC. Your characters probably are under 0020
(control characters). Check their UTF8 codes in PkKeyDef.h
Prinicipaly you can extent available fonts. Here is example
for extension from 0020-00FF to 0020-017F based on Derek’s
documentation.
Andy
/* edit2.c */
#include <fcntl.h>
#include <stdio.h>
#include <sys/qnxterm.h>
#include <unistd.h>
#include <photon/PhInternal.h>
#include <photon/Pf.h>
#include “__g_fontfile.h”
#define INDENT 2
_FontStruct hdr, hdr2;
short * width = NULL, * ix = NULL;
_FontMetricStruct * metric = NULL;
char bitmap[1024];
int fd = -1, fo = -1, posx = 0, posy = 0, szx = 0, szy = 0, bitmaplen = 0, bitmapbpl = 0;
int bitmapext, metricext;
int baselin;
typedef struct {
int pridat;
int povod;
} PRIDAT;
#define PRICNT 22
PRIDAT pridanie[PRICNT] = {
{ 268 , 67 },
{ 269 , 99 },
{ 270 , 68 },
{ 271 , 100 },
{ 313 , 76 },
{ 314 , 108 },
{ 317 , 76 },
{ 318 , 108 },
{ 327 , 78 },
{ 328 , 110 },
{ 340 , 82 },
{ 341 , 114 },
{ 352 , 83 },
{ 353 , 115 },
{ 356 , 84 },
{ 357 , 116 },
{ 381 , 90 },
{ 382 , 122 },
{ 344 , 82 },
{ 345 , 114 },
{ 282 , 69 },
{ 283 , 101 },
};
#define DEF_POVOD 128
int inccnt = 352; // z 224
int Nahradnik (int k)
{
int j;
for (j=0; j<PRICNT; j++) {
if (pridanie[j].pridat == k)
return(pridanie[j].povod);
}
return(DEF_POVOD);
}
void LoadImage(int ch)
{ int i = 0, x = 0, y = 0;
if(hdr.Flags & _FONT_WidthPerChar)
{ szx = width[ch], szy = hdr.Size.y;
}
else if(hdr.Flags & _FONT_MetricPerChar)
{ szx = metric[ch].Size.x, szy = metric[ch].Size.y;
}
else
{ /* should never happen at this point */
}
lseek(fd, ix[ch], SEEK_SET);
read(fd, bitmap, bitmaplen = (bitmapbpl = ((szx + 7) >> 3)) * szy);
}
void main(int argc, char *argv[])
{ int ch = 0, bit = 0, quit = 0, edit = 0, dirty = 0;
unsigned char byte;
char balast[256];
int i, j, lastix;
char fil[128];
sprintf(fil,“sk%s”,argv[1]);
if((fd = open(argv[1], O_RDWR)) == -1)
return;
if((fo = creat(fil, O_RDWR)) == -1)
return;
read(fd, &hdr, sizeof(_FontStruct));
baselin = hdr.BaseLinePos;
memcpy(&hdr2, &hdr, sizeof(_FontStruct));
// zmeny hlavicky
hdr2.AsciiLength = inccnt;
write(fo, &hdr2, sizeof(_FontStruct));
if(hdr.Flags & _FONT_IndexPerChar)
{ if((ix = malloc(hdr2.AsciiLength * sizeof(short))) == NULL)
return;
lseek(fd, hdr.ImageOffset, SEEK_SET);
read(fd, ix, hdr.AsciiLength * sizeof(short));
// balast
lseek(fd, sizeof(_FontStruct), SEEK_SET);
read(fd, balast, ix[0]-sizeof(_FontStruct));
write(fo, balast, ix[0]-sizeof(_FontStruct));
}
if(hdr.Flags & _FONT_WidthPerChar)
{ if((width = malloc(hdr2.AsciiLength * sizeof(short))) == NULL)
return;
lseek(fd, hdr.WidthTabOffset, SEEK_SET);
read(fd, width, hdr.AsciiLength * sizeof(short));
}
else if(hdr.Flags & _FONT_MetricPerChar)
{ if((metric = malloc(hdr2.AsciiLength * sizeof(_FontMetricStruct))) == NULL)
return;
lseek(fd, hdr.WidthTabOffset, SEEK_SET);
read(fd, metric, hdr.AsciiLength * sizeof(_FontMetricStruct));
}
else
{ return;
}
// bitmapy
bitmapext = 0;
metricext = 0;
lastix = 0;
for (i=0; i<hdr2.AsciiLength; i++) {
if (i<hdr.AsciiLength) LoadImage(i);
else {
int j = Nahradnik(i+hdr.AsciiOffset)-hdr.AsciiOffset;
LoadImage(j);
ix _= lastix;
if(hdr.Flags & _FONT_WidthPerChar) {
memcpy(&(width), &(width[j]), sizeof(short));
metricext += sizeof(short);
}
else if(hdr.Flags & _FONT_MetricPerChar) {
memcpy(&(metric),&(metric[j]),sizeof(_FontMetricStruct));
metricext += sizeof(_FontMetricStruct);
if (j != DEF_POVOD-hdr.AsciiOffset && metric.BaseLinePos < baselin) {
int addrows = baselin - metric.BaseLinePos;
metric.BaseLinePos += addrows;
metric.Size.y += addrows;
memmove(bitmap+addrowsbitmapbpl,bitmap,bitmaplen);
memset(bitmap,0,addrowsbitmapbpl);
bitmaplen += addrows*bitmapbpl;
}
}
else return;
bitmapext += bitmaplen;
}
write(fo,bitmap,bitmaplen);
lastix = ix+bitmaplen;
}
// metriky
if(hdr2.Flags & _FONT_WidthPerChar)
{
write(fo, width, hdr2.AsciiLength * sizeof(short));
}
else if(hdr2.Flags & _FONT_MetricPerChar)
{
write(fo, metric, hdr2.AsciiLength * sizeof(_FontMetricStruct));
}
else
{ return;
}
// indexy
if(hdr2.Flags & _FONT_IndexPerChar)
{
write(fo, ix, hdr2.AsciiLength * sizeof(short));
}
// uprava hlavicky
hdr2.WidthTabOffset += bitmapext;
hdr2.ImageOffset += bitmapext;
hdr2.ImageOffset += metricext;
lseek(fo, 0, SEEK_SET);
write(fo, &hdr2, sizeof(FontStruct));
close(fd);
close(fo);
}