David,

I don't know what results you're seeing and how they compare to what you expect
to see (these are important pieces of information to include when you're
reporting a problem). However, the following shows that FntSetFont does have an
effect on the results of FntCharWidth.

DWord PilotMain( Word cmd, Ptr cmdPBP, Word launchFlags)
{
     int       ch;
     char widths1[256];
     char widths2[256];

     if (cmd == sysAppLaunchCmdNormalLaunch)
     {
          FntSetFont(stdFont);
          for (ch = 0; ch < 256; ch++)
          {
               widths1[ch] = FntCharWidth(ch);
          }

          FntSetFont(largeBoldFont);
          for (ch = 0; ch < 256; ch++)
          {
               widths2[ch] = FntCharWidth(ch);
          }
     }
     return 0;
}

After running this, widths1 and widths2 contains similar but different values.

-- Keith






"David A. Desrosiers" <[EMAIL PROTECTED]> on 08/18/99 05:25:35 PM

Please respond to [EMAIL PROTECTED]

Sent by:  "David A. Desrosiers" <[EMAIL PROTECTED]>


To:   "Palm Developer's Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/HQ/3Com)
Subject:  CopyFontWidths





        What is the best process to change and use new fonts in my
application? I have the following, but it doesn't appear to change any of
the fonts in my forms when used. Any help is greatly appreciated.


--

        CopyFontWidths(event->data.frmLoad.formID - frmMain);


void CopyFontWidths(int i)
{
    int ch;
    char *pch;
    char *rgb;


    if (i > largeBoldFont)
        return;
    FntSetFont(i);
    rgb = MemPtrNew(3*256+1+128);
    if (rgb == NULL)
        return;
    pch = rgb;
    for (ch = 0; ch < 256; ch++)
    {
        SWord dx;

        dx = FntCharWidth(ch);
        StrIToA(pch, dx);
        pch += StrLen(pch);
        *pch++ = ',';
        if ((ch+1)%8 == 0)
            *pch++ = '\n';
    }
    *pch = 0;
    ClipboardAddItem(clipboardText, rgb, pch-rgb);
    MemPtrFree(rgb);
}








Reply via email to