Scaling Text to a Given Area

  1. If I have a known area how can I draw text in that area and have the text
    scale to fit in that area? 2) I think PfRenderFractionalText might do it but
    I am having trouble calling that function (it returns “invalid argument”).

Does anybody have any suggestions on how to accompilish (1)? or any sample
code that might show the proper usage of (2).

Thanks,

Brown, Richard brownr_aecl_ca@127.0.0.1 wrote:

  1. If I have a known area how can I draw text in that area and have the text
    scale to fit in that area? 2) I think PfRenderFractionalText might do it but
    I am having trouble calling that function (it returns “invalid argument”).

Does anybody have any suggestions on how to accompilish (1)? or any sample
code that might show the proper usage of (2).

Thanks,

Look in the helpviewer for PfRenderCx, use it instead.
Call PfAttach and retrieve the font context, passing
is a positive value for a buffer. Use that context
when calling PfRenderCx. To use PfRenderCx in fractional
mode, pass the PF_FRACTIONAL flag, and set the adata and
bdata values to the desired horizontal, and vertical fractional
point sizes respectively.

Regards.

Look in the helpviewer for PfRenderCx, use it instead.
Call PfAttach and retrieve the font context, passing
is a positive value for a buffer. Use that context
when calling PfRenderCx. To use PfRenderCx in fractional
mode, pass the PF_FRACTIONAL flag, and set the adata and
bdata values to the desired horizontal, and vertical fractional
point sizes respectively.

Regards.

Ok I tried the code snippet from the PfRenderCx post and whenever
I set PF_FRACTIONAL the sizes become h=2, w=1. I am calling the
function as follows:

// ourDoubleHWFont = cour30b
char textValue = ‘A’;
if( -1 == PfRenderCx( ourFontContext, &color, ourDoubleHWFont, 20, 40,
&textValue, 1, PF_FRACTIONAL, &textCoordinates, NULL, render_cb ) )
{
cout << "PfRenderCx() - failed, " << strerror( errno ) << endl;
}

If I replace PF_FRACTIONAL with 0 I see the character (although a little
offset but that’s a different issue). Any ideas what I may be doing wrong?

Here is the section of render_cb that is handling the character:
if(render->bpp == 1)
{
cout << “bpp=1” << endl;
PgColor_t palette[2] = { Pg_BLACK, *((PgColor_t ) ctx) };
PhImage_t tsImage;
memset(&tsImage, 0x00, sizeof(PhImage_t));
tsImage.size.w = render->size.x;
tsImage.size.h = render->size.y;
// if PF_FRACTIONAL is set then h=2, w=1 meaning ???
cout << “ImageSize( h=” << tsImage.size.h << “, w=” << tsImage.size.w <<
" )" << endl;
tsImage.bpl = render->bpl;
tsImage.image = (char
) render->bmptr;
tsImage.palette = palette;
tsImage.colors = 2;
tsImage.type = Pg_BITMAP_TRANSPARENT;

if(PgDrawPhImagemx(pos, &tsImage, 0x00) == -1)
{
cout << “render_cb() - PgDrawPhImagemx() failed” << endl;
}
else
{
PgFlush();
}
}

Brown, Richard wrote:

Look in the helpviewer for PfRenderCx, use it instead.
Call PfAttach and retrieve the font context, passing
is a positive value for a buffer. Use that context
when calling PfRenderCx. To use PfRenderCx in fractional
mode, pass the PF_FRACTIONAL flag, and set the adata and
bdata values to the desired horizontal, and vertical fractional
point sizes respectively.

Regards.


Ok I tried the code snippet from the PfRenderCx post and whenever
I set PF_FRACTIONAL the sizes become h=2, w=1. I am calling the
function as follows:

// ourDoubleHWFont = cour30b
char textValue = ‘A’;
if( -1 == PfRenderCx( ourFontContext, &color, ourDoubleHWFont, 20, 40,
&textValue, 1, PF_FRACTIONAL, &textCoordinates, NULL, render_cb ) )
{
cout << "PfRenderCx() - failed, " << strerror( errno ) << endl;
}

If I replace PF_FRACTIONAL with 0 I see the character (although a little
offset but that’s a different issue). Any ideas what I may be doing wrong?

Here is the section of render_cb that is handling the character:
if(render->bpp == 1)
{
cout << “bpp=1” << endl;
PgColor_t palette[2] = { Pg_BLACK, *((PgColor_t ) ctx) };
PhImage_t tsImage;
memset(&tsImage, 0x00, sizeof(PhImage_t));
tsImage.size.w = render->size.x;
tsImage.size.h = render->size.y;
// if PF_FRACTIONAL is set then h=2, w=1 meaning ???
cout << “ImageSize( h=” << tsImage.size.h << “, w=” << tsImage.size.w
" )" << endl;
tsImage.bpl = render->bpl;
tsImage.image = (char
) render->bmptr;
tsImage.palette = palette;
tsImage.colors = 2;
tsImage.type = Pg_BITMAP_TRANSPARENT;

if(PgDrawPhImagemx(pos, &tsImage, 0x00) == -1)
{
cout << “render_cb() - PgDrawPhImagemx() failed” << endl;
}
else
{
PgFlush();
}
}
\

Hi Richard

The scale factors are in 16.16 format, so you’d have convert your values
I’m using
#define DOUBLE_TO_FIXED(x) ((long)(x * 65536.0 + 0.5))
in my code to convert a double to a 16.16 long.

Goodluck!

/Johan Björk

“Johan Björk” <phearbear@home.se> wrote in message
news:b42jik$aui$1@inn.qnx.com

Brown, Richard wrote:
Look in the helpviewer for PfRenderCx, use it instead.
Call PfAttach and retrieve the font context, passing
is a positive value for a buffer. Use that context
when calling PfRenderCx. To use PfRenderCx in fractional
mode, pass the PF_FRACTIONAL flag, and set the adata and
bdata values to the desired horizontal, and vertical fractional
point sizes respectively.

Regards.


Ok I tried the code snippet from the PfRenderCx post and whenever
I set PF_FRACTIONAL the sizes become h=2, w=1. I am calling the
function as follows:

// ourDoubleHWFont = cour30b
char textValue = ‘A’;
if( -1 == PfRenderCx( ourFontContext, &color, ourDoubleHWFont, 20, 40,
&textValue, 1, PF_FRACTIONAL, &textCoordinates, NULL, render_cb ) )
{
cout << "PfRenderCx() - failed, " << strerror( errno ) << endl;
}

If I replace PF_FRACTIONAL with 0 I see the character (although a little
offset but that’s a different issue). Any ideas what I may be doing
wrong?

Here is the section of render_cb that is handling the character:
if(render->bpp == 1)
{
cout << “bpp=1” << endl;
PgColor_t palette[2] = { Pg_BLACK, *((PgColor_t ) ctx) };
PhImage_t tsImage;
memset(&tsImage, 0x00, sizeof(PhImage_t));
tsImage.size.w = render->size.x;
tsImage.size.h = render->size.y;
// if PF_FRACTIONAL is set then h=2, w=1 meaning ???
cout << “ImageSize( h=” << tsImage.size.h << “, w=”
tsImage.size.w
" )" << endl;
tsImage.bpl = render->bpl;
tsImage.image = (char
) render->bmptr;
tsImage.palette = palette;
tsImage.colors = 2;
tsImage.type = Pg_BITMAP_TRANSPARENT;

if(PgDrawPhImagemx(pos, &tsImage, 0x00) == -1)
{
cout << “render_cb() - PgDrawPhImagemx() failed” << endl;
}
else
{
PgFlush();
}
}




Hi Richard

The scale factors are in 16.16 format, so you’d have convert your values
I’m using
#define DOUBLE_TO_FIXED(x) ((long)(x * 65536.0 + 0.5))
in my code to convert a double to a 16.16 long.

Goodluck!

/Johan Björk

That did it for me.

Thanks Johan

Brown, Richard brownr_aecl_ca@127.0.0.1 wrote:

“Johan Bjork” <> phearbear@home.se> > wrote in message
news:b42jik$aui$> 1@inn.qnx.com> …
Brown, Richard wrote:
[snip]
Hi Richard

The scale factors are in 16.16 format, so you’d have convert your values
I’m using
#define DOUBLE_TO_FIXED(x) ((long)(x * 65536.0 + 0.5))
in my code to convert a double to a 16.16 long.

Goodluck!

/Johan Bjork

That did it for me.

Thanks Johan

Or (whole_size << 16) is close enough, if you do not want floating point.
Of course, to get semi point sizes, you would need to add 655x
a number of times.

6553 * 5 + 6554 * 5 = 0xFFFF

Regards.