PfConvertFontID(), PfConvertFontIDCx()

Convert a font ID to a font name for backwards compatibility

Synopsis:

#include <photon/Pf.h>
char *PfConvertFontID( FontID *ptsID );

#include <font_api.h>
char* PfConvertFontIDCx( struct _Pf_ctrl * context,
                         FontID * ptsID,
                         char * szTag );

Arguments:

context
(PfConvertFontIDCx() only) A pointer to the font context to use, returned by PfAttachCx() or PfAttachDllCx().
ptsID
A pointer to a FontID structure, returned by PfDecomposeStemToIDCx() or PfDecomposeStemToID().
szTag
(PfConvertFontIDCx() only) A pointer to a location where the function can store the font stem.

Library:

PfConvertFontID()
ph
PfConvertFontIDCx()
font

Description:

These functions convert the font ID pointed to by ptsID into a font name. This function can be used for backwards compatibility with the older font API.


Note: These functions don't check to see if ptsID is NULL, due to the way this routine is used.

Returns:

A version of the font identifier that the older font API can understand.


Note: The return type/value could change in future releases of Photon.

Examples:

PfConvertFontID(): See PfFindFont().

PfConvertFontIDCx():

/* A FontID example.  Demonstrates aspects of how to process
 * FontIDs and legacy font stem names.
 */
#include <font_api.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

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

   fprintf(stderr, "POINT : FontID.\n");

   if((pf = PfAttachCx(NULL, 0)) != NULL)
   {   FontID * id;

       if((id = PfFindFontCx(pf, "TextFont", 0L, 9)) != NULL)
       {  FontName tag;

          if(PfConvertFontIDCx(pf, id, tag) != NULL)
          {  FontName tag2;

             if(PfGenerateFontNameCx(pf, "TextFont", 0L, 9, tag2) != NULL)
             {  if(!strcmp(tag, tag2))
                {  char const * p;

                   if((p = PfFontBaseStemCx(pf, id)) != NULL)
                   {  fprintf(stderr, "NOTE : base stem is %s.\n", p);

                      if((p = PfFontDescriptionCx(pf, id)) != NULL)
                      {  uint32_t flags, size;

                         fprintf(stderr, "NOTE : descriptive foundry is %s.\n", p);

                         flags = PfFontFlagsCx(pf, id);
                         fprintf(stderr, "NOTE : flags are %x.\n", flags);

                         size = PfFontSizeCx(pf, id);
                         fprintf(stderr, "NOTE : point size is %d.\n", size);

                         fprintf(stderr, "PASS : FontID.\n");
                      }
                      else
                      {  fprintf(stderr,
                            "NOTE : PfFontDescriptionCx failed, errno %d.\n",
                            errno);
                         fprintf(stderr, "FAIL : FontID.\n");
                      }
                   }
                   else
                   {  fprintf(stderr, "NOTE : PfFontBaseStemCx failed, errno %d.\n",
                         errno);
                      fprintf(stderr, "FAIL : FontID.\n");
                   }
                }
                else
                {  fprintf(stderr, "NOTE : tags are not equivalent.\n");
                   fprintf(stderr, "FAIL : FontID.\n");
                }
             }
             else
             {  fprintf(stderr, "NOTE : PfGenerateFontNameCx failed, errno %d.\n",
                   errno);
                fprintf(stderr, "FAIL : FontID.\n");
             }
          }
          else
          {  fprintf(stderr, "NOTE : PfConvertFontIDCx failed, errno %d.\n", errno);
             fprintf(stderr, "FAIL : FontID.\n");
          }

          if(PfFreeFontCx(pf, id) == -1L)
          {  fprintf(stderr, "NOTE : PfFreeFontCx failed, errno %d.\n", errno);
          }
       }
       else
       {  fprintf(stderr, "NOTE : PfFindFontCx failed to create font id, errno %d.\n",
             errno);
          fprintf(stderr, "FAIL : FontID.\n");
       }

       PfDetachCx(pf);
   }
   else
   {  fprintf(stderr, "UNRES : Unable to attach to fontserver, errno %d.\n", errno);
      fprintf(stderr, "FAIL : FontID.\n");
   }

   return(0);
}

Classification:

Photon

PfConvertFontID()

Safety:
Interrupt handler No
Signal handler No
Thread No

PfConvertFontIDCx()

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

PfAttach(), PfAttachCx(), PfAttachDllCx(), PfDecomposeStemToID(), PfDecomposeStemToIDCx(), PfFindFont(), PfFindFontCx(), PfFontDescription(), PfFontDescriptionCx(), PfFontFlags(), PfFontFlagsCx(), PfFontSize(), PfFontSizeCx(), PfFreeFont(), PfFreeFontCx(), PfGenerateFontName(), PfGenerateFontNameCx()

Fonts chapter of the Photon Programmer's Guide