📄 chinesefont.c
字号:
/* vxworks 汉字显示演示
*
* zjx at evoc 2007.5.10
*
*/
#include <stdio.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>
#define BLACK (0)
#define BLUE (1)
#define GREEN (2)
#define YELLOW (3)
#define WHITE (4)
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 */
};
void showchinese(void)
{
UGL_FONT_DRIVER_ID fontDrvId;
UGL_FONT_DEF fontDef;
UGL_FONT_ID fontBanner;
UGL_DEVICE_ID devId;
UGL_GC_ID gc;
/*
UGL_WCHAR *text0 = "上李邕\0";
UGL_WCHAR *text1 = "作者李白";
UGL_WCHAR *text2 = "大鹏一日同风起,扶摇直上九万里。";
UGL_WCHAR *text3 = "假令风歇时下来,犹能簸却沧溟水。";
UGL_WCHAR *text4 = "时人见我恒殊调,闻余大言皆冷笑。";
UGL_WCHAR *text5 = "宣父犹能畏后生,丈夫未可轻年少。";
*/
UGL_WCHAR *text0 = "evoc";
UGL_WCHAR *text1 = "kuangyaowen";
UGL_WCHAR *text2 = "kuangyaowen";
UGL_WCHAR *text3 = "kuangyaowen";
UGL_WCHAR *text4 = "vxworks";
UGL_WCHAR *text5 = "vxworks";
if (uglInitialize() == UGL_STATUS_ERROR)
{
return;
}
uglDriverFind(UGL_DISPLAY_TYPE,0,(UGL_UINT32*)&devId);
uglDriverFind(UGL_FONT_ENGINE_TYPE, 0, (UGL_UINT32*)&fontDrvId);
gc = uglGcCreate(devId);
if(uglFontFindString(fontDrvId, "familyName=Song", &fontDef) == UGL_STATUS_ERROR)
{
printf("\nBanner's uglFontFindString failed.\n");
}
if ((fontBanner = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL)
{
printf("Font not found. Exiting.\n");
exit (1);
}
uglColorAlloc (devId, &colorTable[BLACK].rgbColor, UGL_NULL,
&colorTable[BLACK].uglColor, 1);
uglColorAlloc(devId, &colorTable[BLUE].rgbColor, UGL_NULL,
&colorTable[BLUE].uglColor, 1);
uglColorAlloc(devId, &colorTable[YELLOW].rgbColor, UGL_NULL,
&colorTable[YELLOW].uglColor, 1);
uglColorAlloc(devId, &colorTable[WHITE].rgbColor, UGL_NULL,
&colorTable[WHITE].uglColor, 1);
uglBatchStart(gc);
uglBackgroundColorSet(gc, colorTable [YELLOW].uglColor);
uglForegroundColorSet(gc, colorTable [BLUE].uglColor);
uglBatchEnd(gc);
uglFontSet(gc, fontBanner);
uglBatchStart(gc);
uglTextDrawW(gc, 250, 100, strlen(text0), (UGL_WCHAR *)text0);
uglTextDrawW(gc, 300, 150, strlen(text1), (UGL_WCHAR *)text1);
uglTextDrawW(gc, 150, 200, strlen(text2), (UGL_WCHAR *)text2);
uglTextDrawW(gc, 150, 250, strlen(text3), (UGL_WCHAR *)text3);
uglTextDrawW(gc, 150, 300, strlen(text4), (UGL_WCHAR *)text4);
uglTextDrawW(gc, 150, 350, strlen(text5), (UGL_WCHAR *)text5);
uglBatchEnd(gc);
printf("after textdraw!\n");
#if 1
uglDeinitialize();
#endif
/*复位VGA*/
/*vgaInit();
vgaHrdInit();*/
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -