⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wfnttest.c

📁 2410/vxworks/tornado下的基本实验包括 serial,ramdrv,interrupt,multi-FTP,TCP,UDP-Under the basic experimental
💻 C
📖 第 1 页 / 共 2 页
字号:
/* wfnttest.c  Font test application for WindML *//* Copyright 2000 - 2003 Wind River Systems, Inc. All Rights Reserved *//*modification history--------------------01j,08may03,jlb  Remove UGL_LOCAL on function prototype01i,16apr03,jlb  Improved comments and program documentation01h,01apr03,sts  [SPR 86504] Use uglRegistryFind() safely.01g,22feb02,msr  Backward compatibility for input API.01f,29jan02,rbp  Addition of support for Native Unix.01e,28aug01,rbp  Fix for __unix__ macro.01h,05nov01,gav  Fixed misnamed devIds01g,05nov01,gav  Change to new registry01f,05nov01,gav  Change to new registry01e,09oct01,msr  Ported to new UGL_Q_EVENT architecture.01d,19dec00,gav  Entry point identical to filename w/o extension.01c,28nov00,gav  Conditional compilation around metric discrepancy flagging.01b,14nov00,gav  Fixed font line display clearing.01a,24oct00,gav  Miscellaneous clean-up.*//*DESCRIPTIONThis application opens all of the fonts available and displays themone at a time.  The user change the font displayed by using the arrowand page keys.  For fonts that are multibyte/Unicode, the arrow keys,home, and end keys can be used to display different pages.Glyphs that may have a metric error are displayed on a colored background. To start the example: -> ld < wfnttest_ugl.o -> wfnttest To stop the example: -> wfnttestStop*/#include <stdio.h>#include <taskLib.h>#include <ugl/ugl.h>#include <ugl/uglos.h>#include <ugl/uglinput.h>#include <ugl/uglMsg.h>#include <ugl/uglfont.h>#include <ugl/uglucode.h>#include <ioLib.h>/* #include <ugl/driver/graphics/generic/udgen.h> */int windMLTestFont (void);UGL_LOCAL volatile UGL_BOOL stopTest;UGL_LOCAL int displayHeight, displayWidth;UGL_LOCAL int bannerHeight;UGL_LOCAL int x,y;UGL_LOCAL UGL_DEVICE_ID devId;UGL_LOCAL UGL_GC_ID gc;UGL_LOCAL UGL_FONT_ID fontBanner;UGL_LOCAL UGL_FONT_ID *glyphFontId;UGL_LOCAL UGL_FONT_METRICS metric;UGL_LOCAL UGL_INT16 page, maxPage = 255;UGL_FONT_DRIVER_ID fontDrvId;UGL_INT16 fontNum, fontCount;UGL_INPUT_SERVICE_ID inputServiceId;int fd;/** The color table is where we define the colors we want* to have available.  The format is an array of* ARGB values paired with their allocated uglColor.  As* of this writing, we don't need to worry about Alpha* ("A") values unless we are using video.*/UGL_LOCAL struct _colorStruct    {    UGL_ARGB rgbColor;    UGL_COLOR uglColor;    }colorTable[] =    {    { UGL_MAKE_RGB(0, 0, 0), 0},     /* Black */    { UGL_MAKE_RGB(0, 0, 168), 0},   /* Blue  */    { UGL_MAKE_RGB(0, 168, 0), 0},   /* Green */    { UGL_MAKE_RGB(255, 255, 84), 0}, /* Yellow */    { UGL_MAKE_RGB(255, 255, 255), 0} /* White  */    };#define BLACK			(0)#define BLUE			(1)#define GREEN			(2)#define YELLOW			(3)#define WHITE			(4)/**************************************************************************** acquireFonts - find installed fonts** This function finds all of the installed fonts and makes them available* for use by the program.** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/UGL_LOCAL void acquireFonts (void)    {    UGL_STATUS status;    UGL_FONT_DESC fontDesc;    UGL_SEARCH_ID fontSrchId;    UGL_FONT_DEF fontDef;    /* If these are don't cares, the same font is always returned. */    UGL_FONT_DESC_PRIORITY fdPriority = {1,2,3,4,5,6};    /* Find how many fonts we need to track so we can allocate memory. */    fontCount = 0;    fontSrchId = uglFontFindFirst(fontDrvId, &fontDesc);    if (fontSrchId == 0)        {        glyphFontId = UGL_NULL;        return;        }    fontCount++;    for(;;)        {        if ((status = uglFontFindNext(fontDrvId, &fontDesc, fontSrchId)) == UGL_STATUS_ERROR)            {            printf("The iterating font finder broke.\n");            return;                   }        if (status == UGL_STATUS_FINISHED)            break;        fontCount++;        }    uglFontFindClose(fontDrvId,fontSrchId);    /* Allocate an Id array to hold all of the fonts to be created. */    if ((glyphFontId = (UGL_FONT_ID *)UGL_MALLOC(fontCount * sizeof(UGL_FONT_ID))) == 0)        {        printf("Couldn't allocate the memory for the font ID array.\n");        return;        }    /*    * At one time we couldn't call uglFontFind from within a First-Next    * construct, so we did this...    */    /* For each font... */    printf("\n %d fonts found.\n",fontCount);    for (fontNum = 0; fontNum < fontCount; fontNum++)        {        UGL_INT16 i;        /* Walk the list as far as we need. */        fontSrchId = uglFontFindFirst(fontDrvId, &fontDesc);        if (fontSrchId == 0)            {            UGL_FREE(glyphFontId);            glyphFontId = UGL_NULL;            return;            }        i = 0;        while(i < fontNum)            {            if ((status = uglFontFindNext(fontDrvId, &fontDesc, fontSrchId)) == UGL_STATUS_ERROR)                {                UGL_FREE(glyphFontId);                glyphFontId = UGL_NULL;                printf("The iterating font finder broke.\n");                return;                       }            i++;            }        uglFontFindClose(fontDrvId,fontSrchId);        if (uglFontFind(fontDrvId, &fontDesc, &fdPriority, &fontDef) == UGL_STATUS_ERROR)             {            UGL_FREE(glyphFontId);            glyphFontId = UGL_NULL;            printf("The font finder broke.\n");            printf("fontNum = %d\n",fontNum);            return;            }        if ((glyphFontId[fontNum] = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL)            {            UGL_FREE(glyphFontId);            glyphFontId = UGL_NULL;            printf("The font maker broke.\n");            return;            }        }    }/**************************************************************************** pagePaint - display page of fonts** This routine displays a font page** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/UGL_LOCAL void pagePaint (void)    {    UGL_SIZE textWidth, textHeight;    UGL_SIZE fontWidth, fontHeight, cellWidth, cellHeight;    UGL_WCHAR output[] = { 0, 0 };    UGL_SIZE ix, iy;    UGL_BOOL wide;    char snum[80];    uglBackgroundColorSet(gc, colorTable[BLACK].uglColor);    uglForegroundColorSet(gc, colorTable[BLACK].uglColor);    uglRectangle(gc,0,bannerHeight, displayWidth - 1, displayHeight - 1);    /* The 'metric' of a font includes its height, width, name, etc. */    uglFontSet(gc, glyphFontId[fontNum]);    if (uglFontMetricsGet(glyphFontId[fontNum], &metric) != 0)        {        printf("uglFontMetricsGet failed.\n");        return;        }    /* Use the font's information for formating the display of glyphs. */    fontWidth  = metric.maxAdvance;    fontHeight = metric.maxAscent + metric.maxDescent;    cellWidth  = fontWidth + 4;    cellHeight = fontHeight + 4;    /* Test to see if the driver supports wide character sets. */    output[0] = 'M';    if (uglTextSizeGetW(glyphFontId[fontNum], &textWidth, &textHeight, 1, output) == UGL_STATUS_ERROR)        {        wide = UGL_FALSE;        output[0] = 0;        }    else        {        wide = UGL_TRUE;        /*        * If the driver and the font support wide character sets, then use        * page value.        */        output[0] = 0;        output[0] |= page << 8;        }    uglForegroundColorSet(gc, colorTable[GREEN].uglColor);    /* Draw the grid to contain the glyphs. */    for (iy = 0; iy <= 16; iy++)        uglLine(gc, 0,iy * cellHeight + (bannerHeight << 1) + 3, 16 * cellWidth, iy * cellHeight + (bannerHeight << 1) + 3);    for (ix = 0; ix <= 16; ix++)        uglLine(gc, ix * cellWidth, (bannerHeight << 1) + 3, ix * cellWidth, 16 * cellHeight + (bannerHeight << 1) + 3);    uglForegroundColorSet(gc, colorTable[WHITE].uglColor);    /* Draw the glyphs */    for (iy = 0; iy < 16; iy++)        for (ix = 0; ix < 16; ix++)            {            /* Check the font itself for any metric errors. */            if (wide)                uglTextSizeGetW(glyphFontId[fontNum], &textWidth, &textHeight, 1, output);            else                 uglTextSizeGet(glyphFontId[fontNum], &textWidth, &textHeight, 1, (char *) output);#if defined(GLYPH_METRIC_FLAGGING)            if (textWidth > fontWidth || textHeight > fontHeight ||                textHeight < 0 || textWidth < 0)                {                uglForegroundColorSet(gc, colorTable[GREEN].uglColor);                uglBackgroundColorSet(gc, colorTable[YELLOW].uglColor);                uglRectangle(gc, ix * cellWidth, iy * cellHeight + (bannerHeight << 1) + 3,                                 (ix + 1) * cellWidth, (iy + 1) * cellHeight + (bannerHeight << 1) + 3);                uglForegroundColorSet(gc, colorTable[BLACK].uglColor);                if (wide)                    uglTextDrawW(gc, ix * cellWidth + 2, iy * cellHeight + (bannerHeight << 1) + 5, 1, output);                else                     uglTextDraw(gc, ix * cellWidth + 2, iy * cellHeight + (bannerHeight << 1) + 5, 1, (char *) output);                uglBackgroundColorSet(gc, colorTable[BLACK].uglColor);                uglForegroundColorSet(gc, colorTable[WHITE].uglColor);                }            else#endif                {                if (wide)                    uglTextDrawW(gc, ix * cellWidth + 2, iy * cellHeight + (bannerHeight << 1) + 5, 1, output);                else                     uglTextDraw(gc, ix * cellWidth + 2, iy * cellHeight + (bannerHeight << 1) + 5, 1, (char *) output);                }            if (wide)                output[0]++;            else                ((char *)output)[0]++;            }    /* Print the font number and page number on the banner. */    uglFontSet(gc, fontBanner);    uglForegroundColorSet(gc, colorTable[YELLOW].uglColor);    sprintf(snum, "%s", metric.faceName);    uglTextDraw(gc, 0, bannerHeight, -1, snum);    if (wide)        sprintf(snum, "Font # %5d     Page %5d", fontNum, page);    else        sprintf(snum, "Font # %5d", fontNum);    uglTextDraw(gc, displayWidth >> 1, bannerHeight, -1, snum);    /* Post banner notice that driver is not supporting wide characters. */    if (!wide)        {        sprintf(snum, "Wide character support unavailable");        uglTextDraw(gc, displayWidth >> 1, 0, -1, snum);        }    }/**************************************************************************** NextPopulatedPage - go to next font page ** This routine goes to the next populated font page** RETURNS:  UGL_TRUE if not at the maximum page; otherwise UGL_FALSE** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/UGL_LOCAL UGL_BOOL NextPopulatedPage (void)    {    if (page == maxPage)      return UGL_FALSE;    page += 10;    if (page > maxPage)        page = maxPage;    return UGL_TRUE;    }/**************************************************************************** PrevPopulatedPage - go to previous font page ** This routine goes to the previous populated font page** RETURNS:  UGL_TRUE if not at the page 0; otherwise UGL_FALSE** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/UGL_LOCAL UGL_BOOL PrevPopulatedPage (void)    {    if (page == 0)        return UGL_FALSE;    page -= 10;    if (page < 0)        page = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -