Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

PfConvertPixelsToPointSizeCx()

Convert pixel height to point size

Synopsis:

#include <font_api.h>
FontID*
PfConvertPixelsToPointSizeCx( struct _Pf_ctrl * context,
                              char const * description,
                              int flags,
                              uint32_t pixel_height );

Arguments:

context
A pointer to the font context to use, returned by PfAttachCx() or PfAttachDllCx().
description
A foundry face, such as Swis721 BT or PrimaSans BT.
flags
Flags that identify the requested font type. The following can be ORed together:
pixel_height
The height in pixels that the ascender and descender of the resultant font must fit within.

Library:

font

Description:

This function locates a point size for the provided foundry face (description) that has an ascender and descender that fit within the provided pixel height. If the provided foundry face represents a bitmap font, then the ID for the closest point size available that fits within the pixel height is returned. You must release the returned FontID.

Returns:

A FontID
Success
NULL
Failure (errno is set).

Errors:

ESRCH
Unable to match a point size to the provided pixel height.

Examples:

#include <font_api.h>
#include <stdio.h>

#define PIXEL_HEIGHT 33

int main(int argc, char *argv[])
{  struct _Pf_ctrl * pf;

   if((pf = PfAttachCx(NULL, 0)) != NULL)
   {  FontName font;

      if(PfGenerateFontNameCx(pf, "PrimaSans BT", 0, 9, font) != NULL)
      {  if(PfLoadMetricsCx(pf, font) == 0)
         {  FontID * id;

            if((id = PfConvertPixelsToPointSizeCx(pf, "PrimaSans BT", 0,
                                                  PIXEL_HEIGHT))
                != NULL)
            {  FontName font2;

               printf("Font stem %s fits in a height of %d pixels.\n",
                       PfConvertFontIDCx(pf, id, font2), PIXEL_HEIGHT);
               PfFreeFontCx(pf, id);
            }

            PfUnloadMetricsCx(pf, font);
         }
      }

      PfDetachCx(pf);
   }

   return(0);
}

Classification:

Photon

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

PfAttachCx(), PfAttachDllCx().

Fonts chapter of the Photon Programmer's Guide