int main (int argc, char *argv[])
{
PtArg_t args[10];
PhArea_t windowArea;
PhDim_t windowDim;
PhPoint_t pntTextLoc;
short nArgs = 0;
// Set base pwndMain parameters.
nArgs = 0;
windowArea.pos.y = 10;
windowArea.pos.x = 10;
windowArea.size.w = 500;
windowArea.size.h = 500;
windowDim.w = 500;
windowDim.h = 500;
//PtSetArg(&args[nArgs++], Pt_ARG_AREA, &windowArea, 0);
PtSetArg(&args[nArgs++], Pt_ARG_DIM, &windowDim, 0);
PtSetArg(&args[nArgs++], Pt_ARG_FILL_COLOR, Pg_GRAY, 0);
PtSetArg(&args[nArgs++], Pt_ARG_WINDOW_TITLE, “PfExtentTextToRect”, 0);
PtSetArg(&args[nArgs++], Pt_ARG_WINDOW_RENDER_FLAGS, 0,
Ph_WM_APP_DEF_RENDER);
pwndMain = PtAppInit (NULL, 0, NULL, nArgs, args);
pntTextLoc.x = 300;
pntTextLoc.y = 300;
DisplayText(pwndMain, “Helvetica 12 Bold”, pntTextLoc, Pg_BLUE, Pg_WHITE,
0, 0, 0, TA_CENTER | TA_MIDDLE, “Helvetica”, 12, PF_STYLE_BOLD);
pntTextLoc.x = 300;
pntTextLoc.y = 350;
DisplayText(pwndMain, “Swiss 12 Bold”, pntTextLoc, Pg_BLUE, Pg_WHITE, 0, 0,
0, TA_CENTER | TA_MIDDLE, “Swiss721 BT”, 12, PF_STYLE_BOLD);
PtRealizeWidget(pwndMain);
PtMainLoop ();
return(0);
}
#define TA_LEFT 0x00
#define TA_RIGHT 0x01
#define TA_CENTER 0x02
#define TA_HORIZ_MASK 0x03
#define TA_TOP 0x00
#define TA_BOTTOM 0x04
#define TA_MIDDLE 0x08
#define TA_VERT_MASK 0x0c
void GetTextSize(char* text, char *font, int *length, int *height)
{
PhRect_t extent;
if(NULL == PgExtentText(&extent, NULL, font, text, 0))
printf(“PgExtentText error\n”);
*length = extent.lr.x - extent.ul.x;
*height = extent.lr.y - extent.ul.y;
}
void DisplayText(PtWidget_t* _win, const char* _text, PhPoint_t _loc,
PgColor_t _fc, PgColor_t _bc, int back_filled, int _id,
int _len, int _alignment, uchar_t * _font, int _font_size,
int _font_style)
{
char *fnName = “DisplayText”;
PtArg_t args[15];
PhArea_t area;
PtWidget_t *label = NULL;
int nArgs = 0;
char font[MAX_FONT_TAG];
char text[256];
int length = 0;
int height = 0;
memset(font,0x00,MAX_FONT_TAG);
memset(text,0x00,256);
if(PfGenerateFontName(_font , _font_style, _font_size, (uchar_t *)font) ==
NULL)
perror(“Unable to find font name”);
strcpy(text, _text);
GetTextSize(text, font, &length, &height);
switch(_alignment & TA_HORIZ_MASK)
{
case TA_LEFT:
break;
case TA_RIGHT:
area.pos.x -= length;
break;
case TA_CENTER:
area.pos.x -= (length >> 1);
break;
}
switch(_alignment & TA_VERT_MASK)
{
case TA_TOP:
break;
case TA_BOTTOM:
area.pos.y -= height;
break;
case TA_MIDDLE:
area.pos.y -= (height >> 1);
break;
}
area.pos = _loc;
area.size.h = (unsigned short)height;
area.size.w = (unsigned short)length;
nArgs = 0;
PtSetArg(&args[nArgs++], Pt_ARG_LABEL_TYPE, Pt_Z_STRING, 0);
PtSetArg(&args[nArgs++], Pt_ARG_TEXT_STRING, text, 0);
PtSetArg(&args[nArgs++], Pt_ARG_TEXT_FONT, font, 0);
PtSetArg(&args[nArgs++], Pt_ARG_COLOR, _fc, 0);
if(back_filled)
PtSetArg(&args[nArgs++], Pt_ARG_FILL_COLOR, _bc, 0);
else
PtSetArg(&args[nArgs++], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0);
PtSetArg(&args[nArgs++], Pt_ARG_AREA, &area, 0);
label = PtCreateWidget(PtLabel, _win, nArgs, args);
if(NULL == label)
printf("%s: Error creating label\n",fnName);
if(-1 == PtRealizeWidget(label))
printf("%s: Error realizing label widget text=%s\n", fnName, text);
}
–
Jeffrey B. Holtz
Software Engineering
Electro Scientific Industries, Inc.
Ph: 734-332-7054
Fax: 734-332-7077
email: > holtzj@esi.com
“Derek Leach” <> dleach@qnx.com> > wrote in message
news:aomena$7n8$> 1@inn.qnx.com> …
Jeff Holtz <> holtzj@esi.com> > wrote:
All-
I’m working on an embedded system and have created the
font_repository
with the old helv* Legacy Fonts. The BOLD ones for “helv” that are
available are:
helv08b.phf
helv10b.phf
helv12b.phf
helv14b.phf
helv18b.phf
helv24b.phf
I created a quick program:
for (nloop=12; nloop<25; nloop=nloop+1)
{
PfGenerateFontName(“Helvetica”, PF_STYLE_BOLD, nloop, fontName)
PtMessageBox(parent,NULL,fontName,fontName,“OK”);
}
What I see in QNX6.1A is that the following font Sizes are equal:
helv24b.phf: 24, 23, 22
helv18b.phf: 21, 20, 19, 18, 17
helv14b.phf: 16, 15, 14
helv12b.phf: 13, 12
Yet under QNX4 I see a flooring of the size. In otherwords:
helv24b.phf: 24
helv18b.phf: 23, 22, 21, 20, 19, 18
helv14b.phf: 17, 16, 15, 14, 13
helv12b.phf: 12, 11,
Does anyone know how to achieve the same results on QNX6? I’m trying to
migrate a program and our customer is banking on backward compatibility.
Thanks.
Jeff
Jeffrey B. Holtz
Software Engineering
Electro Scientific Industries, Inc.
Ph: 734-332-7054
Fax: 734-332-7077
email: > holtzj@esi.com
Jeff,
This looks bizarre. There was some changes made to the font engine
under QNX6, because of “dancing” point sizes. When a point size
did not exists, sometimes the font manager would pick a size higher,
and sometimes it would pick a size lower. I will have to investigate
it at some point (no time soon). One question:
Does the same behaviour happen with the plain fonts, i.e. helv24, helv18,
etc?
Some suggestions to get you by:
- Use Swiss721 scalable.
- Create a cover routine that you pass in the desired font, and
it remaps it to either the QNX4 or QNX6 size, which ever you
decide.
- Use only the available point sizes.
Back to the issues at hand, upon investigation, it is very unlikely
this behaviour can be change under QNX6, since it would break QNX6
backward compatibility.
Regards.