#include <zvCommon.h>
#include <2d.h>
enum
{
TEXT0,
TEXT1
};
ZV_TEXT_MODIFIER_DESC _text_modifier_descs[] =
{
{ZV_TEXT_ENG, 18, 24, "./font/ERASBD.TTF"},
{ZV_TEXT_CHS, 18, 24, "./font/SIMKAI.TTF"}
};
#if 0
uint16 _text0_eng[] = {0x004d,0x0061,0x0067,0x006e,0x0075,0x006d,0x0020,0x0053,0x0065,0x006d,0x0069,0x0063,0x006f,0x006e,0x0064,0x0075,0x0063,0x0074,0x006f,0x0072,0x0020,0x0028,0x0053,0x0068,0x0061,0x006e,0x0067,0x0068,0x0061,0x0069,0x0029, 0}; //"Magnum Semiconductor (Shanghai)"
uint16 _text0_chs[] = {0x4e0a, 0x6d77, 0x8fc8, 0x56fe, 0x534a, 0x5bfc, 0x4f53, 0}; // 上海迈图半导体
uint16 *_text0[] =
{
_text0_eng,
_text0_chs
};
uint16 _text1_eng[] = {0x0049,0x0020,0x006c,0x006f,0x0076,0x0065,0x0020,0x0043,0x0061,0x006e,0x0064,0x0079,0x0066,0x006c,0x006f,0x0073,0x0073,0x0021,0}; //"I love Candyfloss!"
uint16 _text1_chs[] = {0x6211, 0x7231, 0x5c0f, 0x767d, 0xff01, 0}; // 我爱小白
uint16 *_text1[] =
{
_text1_eng,
_text1_chs
};
uint16 **_texts[] =
{
_text0,
_text1
};
#endif
int main()
{
errCode ec;
zv_handle gui_texture = NULL;
zv_handle objects = NULL;
char *str0;
uint16 *ucsStr0 = NULL;
uint16 ucsStr1[] = {0x4e0a, 0x6d77, 0x8fc8, 0x56fe, 0x534a, 0x5bfc, 0x4f53, 0x000d, 0x000a, 0};
zv_handle font0, font1;
ec = zvRenderer3D_Create();
ec = zvRenderer3D_Start();
ec = Init_2d(NULL);
ec = Display_RenderBitmap(g_pDisplay, 0, 0, -2.0f, 1.0, "./bmp/bg01.bmp", &gui_texture, &objects);
ec = zvInitFontLibrary();
ec = zvCreateFont(&font0, "./font/ERASBD.TTF");
ec = zvSetFontPixelSize(font0, 48, 64);
str0 = "Magnum LZPF";
ucsStr0 = (uint16 *)ZV_MALLOC(ZV_STRLEN(str0) * 2 + 2);
ec = zvUTF8ToUnicode(str0, ucsStr0);
ec = zvRenderText(gui_texture, 10, 10, ucsStr0, Z_MAKE_COLOR_ABGR1555(0, 64, 64, 255), font0);
ec = zvCreateFont(&font1, "./font/SIMKAI.TTF");
ec = zvSetFontPixelSize(font1, 36, 48);
ec = zvRenderText(gui_texture, 10, 100, ucsStr1, Z_MAKE_COLOR_ABGR1555(0, 64, 255, 255), font1);
{
Z_RECT rect = {400, 150, 799, 449};
ec = zvRenderTextAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_LEFT | ZV_TEXT_ALIGN_Y_CENTER, 0, 17, ucsStr1, Z_MAKE_COLOR_ABGR1555(0, 180, 180, 180), font1);
}
ec = zvDestroyFont(font1);
ec = zvDestroyFont(font0);
#if 1
{
zv_handle ml_text_modifier;
uint16 x, width;
Z_RECT rect = {0, 300, 799, 599};
//uint32 id0;
//uint32 id1;
ec = zvCreateMlTextModifier(_text_modifier_descs, LENGTH_OF(_text_modifier_descs), &ml_text_modifier);
//ec = zvCreateMlText(_text0, LENGTH_OF(_text0), ml_text_modifier, &id0);
//ec = zvCreateMlText(_text1, LENGTH_OF(_text1), ml_text_modifier, &id1);
ec = zvLoadMlText("./text/text.txt", ml_text_modifier);
x = 10;
ec = zvSetMlTextCurrentLanguage(ZV_TEXT_CHS);
ec = zvMlTextOut(gui_texture, x, 200, 0, Z_MAKE_COLOR_ABGR1555(0, 128, 0, 0));
ec = zvGetMlTextWidth(0, &width);
x += width + 10;
ec = zvSetMlTextCurrentLanguage(ZV_TEXT_ENG);
ec = zvMlTextOut(gui_texture, x, 200, 0, Z_MAKE_COLOR_ABGR1555(0, 0, 128, 0));
x = 10;
ec = zvSetMlTextCurrentLanguage(ZV_TEXT_CHS);
ec = zvMlTextOut(gui_texture, x, 250, 1, Z_MAKE_COLOR_ABGR1555(0, 128, 0, 0));
ec = zvGetMlTextWidth(1, &width);
x += width + 10;
ec = zvSetMlTextCurrentLanguage(ZV_TEXT_ENG);
ec = zvMlTextOut(gui_texture, x, 250, 1, Z_MAKE_COLOR_ABGR1555(0, 0, 128, 0));
// test aligned textout
ec = zvSetMlTextCurrentLanguage(ZV_TEXT_CHS);
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_LEFT | ZV_TEXT_ALIGN_Y_TOP, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 128, 0, 0));
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_CENTER | ZV_TEXT_ALIGN_Y_TOP, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 128, 0, 0));
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_RIGHT | ZV_TEXT_ALIGN_Y_TOP, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 128, 0, 0));
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_LEFT | ZV_TEXT_ALIGN_Y_CENTER, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 0, 128, 0));
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_CENTER | ZV_TEXT_ALIGN_Y_CENTER, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 0, 128, 0));
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_RIGHT | ZV_TEXT_ALIGN_Y_CENTER, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 0, 128, 0));
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_LEFT | ZV_TEXT_ALIGN_Y_BOTTOM, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 0, 0, 128));
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_CENTER | ZV_TEXT_ALIGN_Y_BOTTOM, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 0, 0, 128));
ec = zvMlTextOutAligned(gui_texture, &rect, ZV_TEXT_ALIGN_X_RIGHT | ZV_TEXT_ALIGN_Y_BOTTOM, 0, 0, 0, Z_MAKE_COLOR_ABGR1555(0, 0, 0, 128));
zvDestroyMlTextModifier(ml_text_modifier);
}
//zvDestrotyText();
#endif
zvDeinitFontLibrary();
Deinit_2d();
ThreadSleep(2000);
ec = zvRenderer3D_Destory();
return 0;
}