| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888 |
- #include <common.h>
- #include <asm/arch/ark-common.h>
- #include "URBprobar.h"
- static void Memcpy(void * dest, const void *src, int n)
- {
- char * d = (char *)dest;
- const char * s = (const char *)src;
- while (n--)
- *d++ = *s++;
- }
- typedef unsigned short GlyphScatter;
- typedef struct {
- unsigned short ucs2Start;
- unsigned short ucs2End;
- }GlyphRange;
- //
- // 字体文件布局
- // ----------------
- // | 文件头 | // FontFileHead
- // ---------------|
- // | 区间信息数组 | // 连续区间数据 GlyphRange[]
- // ----------------
- // | 离散信息数组 | // 离散点数据 GlyphScatter[] 已经排序
- // ---------------|
- // | missing点阵 | // missing glyph 点阵,额外的一个点阵用于显示无法找到的字符
- // ----------------
- // | 区间1点阵 | // 连续区间点阵数据
- // | 区间2点阵 | // 连续区间点阵数据
- // | 区间... | // 连续区间点阵数据
- // ----------------
- // | 离散1点阵 | // 离散的点阵
- // | 离散2点阵 | // 离散的点阵
- // | 离散... | // 离散的点阵
- // ----------------
- static __attribute__ ((aligned (4))) const unsigned char s_fontData[]=
- {
- 0x46,0x54,0x02,0x10,0x46,0x6F,0x6E,0x74,0x20,0x38,0x78,0x31,0x36,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x08,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,
- 0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x38,0x7C,0x7C,0x7C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xFE,0xFE,0xFE,0xFE,0xC6,0x82,0x82,0x82,0xC6,0xFE,0xFE,0xFE,0xFE,0xFE,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x1E,0x06,0x0A,0x0A,0x10,0x10,0x30,0x48,0x48,0x30,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x38,0x44,0x44,0x38,0x10,0x7C,0x10,0x10,0x10,0x10,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x06,0x3A,0x26,0x3A,0x22,0x22,0x22,0x26,0x66,0x60,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x54,0x54,0x28,0x28,0x6C,0x28,0x28,0x54,0x54,0x00,0x00,0x00,0x00,
- 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- 0x00,0x00,0x02,0x06,0x0E,0x1E,0x3E,0x7E,0x3E,0x1E,0x0E,0x06,0x02,0x00,0x00,0x00,
- 0x00,0x10,0x38,0x54,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x54,0x38,0x10,0x00,0x00,
- 0x00,0x00,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x00,0x00,0x24,0x24,0x00,0x00,
- 0x00,0x00,0x34,0x54,0x54,0x54,0x54,0x54,0x34,0x14,0x14,0x14,0x14,0x14,0x00,0x00,
- 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- 0x00,0x00,0x10,0x38,0x54,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
- 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x04,0x7E,0x04,0x08,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x20,0x7E,0x20,0x10,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x18,0x18,0x00,0x00,
- 0x00,0x12,0x36,0x24,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x24,0x24,0x24,0xFE,0x48,0x48,0x48,0xFE,0x48,0x48,0x48,0x00,0x00,
- 0x00,0x00,0x10,0x38,0x54,0x54,0x50,0x30,0x18,0x14,0x14,0x54,0x54,0x38,0x10,0x10,
- 0x00,0x00,0x00,0x44,0xA4,0xA8,0xA8,0xA8,0x54,0x1A,0x2A,0x2A,0x2A,0x44,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00,
- 0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00,
- 0x00,0x00,0x00,0x00,0x10,0x10,0xD6,0x38,0x38,0xD6,0x10,0x10,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0x10,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x20,0xC0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,
- 0x00,0x00,0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00,
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
- 0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00,
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00,
- 0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00,
- 0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00,
- 0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
- 0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x20,
- 0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00,
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x62,0x02,0x04,0x08,0x08,0x00,0x18,0x18,0x00,0x00,
- 0x00,0x00,0x00,0x38,0x44,0x5A,0xAA,0xAA,0xAA,0xAA,0xB4,0x42,0x44,0x38,0x00,0x00,
- 0x00,0x00,0x00,0x10,0x10,0x18,0x28,0x28,0x24,0x3C,0x44,0x42,0x42,0xE7,0x00,0x00,
- 0x00,0x00,0x00,0xF8,0x44,0x44,0x44,0x78,0x44,0x42,0x42,0x42,0x44,0xF8,0x00,0x00,
- 0x00,0x00,0x00,0x3E,0x42,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x44,0x38,0x00,0x00,
- 0x00,0x00,0x00,0xF8,0x44,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x44,0xF8,0x00,0x00,
- 0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x42,0x42,0xFC,0x00,0x00,
- 0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x40,0x40,0xE0,0x00,0x00,
- 0x00,0x00,0x00,0x3C,0x44,0x44,0x80,0x80,0x80,0x8E,0x84,0x44,0x44,0x38,0x00,0x00,
- 0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
- 0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,
- 0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x88,0xF0,
- 0x00,0x00,0x00,0xEE,0x44,0x48,0x50,0x70,0x50,0x48,0x48,0x44,0x44,0xEE,0x00,0x00,
- 0x00,0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x42,0xFE,0x00,0x00,
- 0x00,0x00,0x00,0xEE,0x6C,0x6C,0x6C,0x6C,0x54,0x54,0x54,0x54,0x54,0xD6,0x00,0x00,
- 0x00,0x00,0x00,0xC7,0x62,0x62,0x52,0x52,0x4A,0x4A,0x4A,0x46,0x46,0xE2,0x00,0x00,
- 0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
- 0x00,0x00,0x00,0xFC,0x42,0x42,0x42,0x42,0x7C,0x40,0x40,0x40,0x40,0xE0,0x00,0x00,
- 0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0xB2,0xCA,0x4C,0x38,0x06,0x00,
- 0x00,0x00,0x00,0xFC,0x42,0x42,0x42,0x7C,0x48,0x48,0x44,0x44,0x42,0xE3,0x00,0x00,
- 0x00,0x00,0x00,0x3E,0x42,0x42,0x40,0x20,0x18,0x04,0x02,0x42,0x42,0x7C,0x00,0x00,
- 0x00,0x00,0x00,0xFE,0x92,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,
- 0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,
- 0x00,0x00,0x00,0xE7,0x42,0x42,0x44,0x24,0x24,0x28,0x28,0x18,0x10,0x10,0x00,0x00,
- 0x00,0x00,0x00,0xD6,0x92,0x92,0x92,0x92,0xAA,0xAA,0x6C,0x44,0x44,0x44,0x00,0x00,
- 0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00,
- 0x00,0x00,0x00,0xEE,0x44,0x44,0x28,0x28,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,
- 0x00,0x00,0x00,0x7E,0x84,0x04,0x08,0x08,0x10,0x20,0x20,0x42,0x42,0xFC,0x00,0x00,
- 0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00,
- 0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x08,0x04,0x04,0x04,0x02,0x02,
- 0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00,
- 0x00,0x1C,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
- 0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x1E,0x22,0x42,0x42,0x3F,0x00,0x00,
- 0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x64,0x58,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00,
- 0x00,0x00,0x00,0x06,0x02,0x02,0x02,0x1E,0x22,0x42,0x42,0x42,0x26,0x1B,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x40,0x40,0x42,0x3C,0x00,0x00,
- 0x00,0x00,0x00,0x0F,0x11,0x10,0x10,0x7E,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x44,0x44,0x38,0x40,0x3C,0x42,0x42,0x3C,
- 0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
- 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,
- 0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x1C,0x04,0x04,0x04,0x04,0x04,0x04,0x44,0x78,
- 0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x4E,0x48,0x50,0x68,0x48,0x44,0xEE,0x00,0x00,
- 0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x49,0x49,0x49,0x49,0x49,0xED,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD8,0x64,0x42,0x42,0x42,0x44,0x78,0x40,0xE0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x22,0x42,0x42,0x42,0x22,0x1E,0x02,0x07,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEE,0x32,0x20,0x20,0x20,0x20,0xF8,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x40,0x3C,0x02,0x42,0x7C,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x10,0x10,0x10,0x0C,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0x42,0x42,0x42,0x42,0x46,0x3B,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x10,0x10,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD7,0x92,0x92,0xAA,0xAA,0x44,0x44,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x24,0x18,0x18,0x18,0x24,0x76,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x18,0x10,0x10,0xE0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x44,0x08,0x10,0x10,0x22,0x7E,0x00,0x00,
- 0x00,0x03,0x04,0x04,0x04,0x04,0x04,0x08,0x04,0x04,0x04,0x04,0x04,0x04,0x03,0x00,
- 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
- 0x00,0x60,0x10,0x10,0x10,0x10,0x10,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x60,0x00,
- 0x30,0x4C,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- /**
- * the VGUI private Font file version 1.0 head struct, internally used only.
- */
- typedef struct {
- char magic[2]; // "FT"
- unsigned short version;// 0x1001 (1.01)
- char name[32];// description
- unsigned char charWidth;
- unsigned char charHeight;
- unsigned short glyphBytes;
- unsigned short rangeCount;
- unsigned short scatterCount;
- }FontFileHeadV1;
- static mv_surface s_primary;
- static unsigned char * m_fileStart =NULL;
- static unsigned char * m_glyphStart=NULL;
- static unsigned int g_bpp;
- FontFileHeadV1 * m_fh=NULL;
- static int setFontFileDat(const unsigned char * dat);
- unsigned int mv_RGB2Color(unsigned char r, unsigned char g, unsigned char b)
- {
- if(g_bpp == 16)
- return ((r >> 3) << 11) |( (g >> 2) << 5) | (b >> 3);
- else if(g_bpp == 32)
- return (r << 16) | (g << 8) | b;
- }
- static mv_color * getXYData(const mv_surface * s,
- int x, int y)
- {
- return(mv_color*)(s->startAddr + x * sizeof(mv_color) + s->lineBytes * y);
- }
- static unsigned short * getXYData16(const mv_surface * s,
- int x, int y)
- {
- return(unsigned short*)(s->startAddr + x * sizeof(unsigned short) + s->lineBytes * y);
- }
- static unsigned int * getXYData32(const mv_surface * s,
- int x, int y)
- {
- return(unsigned int*)(s->startAddr + x * sizeof(unsigned int) + s->lineBytes * y);
- }
- void mv_initPrimary(const mv_surface * s)
- {
- //s_primary = *s;
- Memcpy(&s_primary, s, sizeof(s_primary));
- setFontFileDat(s_fontData); //defined in "fontdata.h"
- g_bpp = s->bpp;
- }
- void mv_putPixel(int x, int y, mv_color color)
- {
- *getXYData(&s_primary, x, y) = color;
- }
- void mv_putPixel16(int x, int y, unsigned short color)
- {
- *getXYData16(&s_primary, x, y) = color;
- }
- void mv_putPixel32(int x, int y, unsigned int color)
- {
- *getXYData32(&s_primary, x, y) = color;
- }
- void mv_drawLine(int x1, int y1, int x2, int y2, mv_color color)
- {
- int i;
- mv_color* p;
- if ( y1 == y2 ) {
- if (x1 > x2) {
- int tmp = x1;
- x1 = x2;
- x2 = tmp;
- }
- // horz line
- p = getXYData(&s_primary, x1, y1);
- for (i = x1; i < x2; ++i)
- *p++ = color;
- }
- else if ( x1 == x2 ) {
- if (y1 > y2) {
- int tmp = y1;
- y1 = y2;
- y2 = tmp;
- }
- // vert line
- p = getXYData(&s_primary, x1,y1);
- for (i = y1; i < y2; ++i) {
- *p = color;
- p = p + s_primary.lineBytes;
- }
- }
- }
- void mv_drawLine16(int x1, int y1, int x2, int y2, unsigned short color)
- {
- int i;
- unsigned short* p;
- if ( y1 == y2 ) {
- if (x1 > x2) {
- int tmp = x1;
- x1 = x2;
- x2 = tmp;
- }
- // horz line
- p = getXYData16(&s_primary, x1, y1);
- for (i = x1; i < x2; ++i)
- *p++ = color;
- }
- else if ( x1 == x2 ) {
- if (y1 > y2) {
- int tmp = y1;
- y1 = y2;
- y2 = tmp;
- }
- // vert line
- p = getXYData16(&s_primary, x1,y1);
- for (i = y1; i < y2; ++i) {
- *p = color;
- p = p + s_primary.lineBytes;
- }
- }
- }
- void mv_drawLine32(int x1, int y1, int x2, int y2, unsigned int color)
- {
- int i;
- unsigned int* p;
- if ( y1 == y2 ) {
- if (x1 > x2) {
- int tmp = x1;
- x1 = x2;
- x2 = tmp;
- }
- // horz line
- p = getXYData32(&s_primary, x1, y1);
- for (i = x1; i < x2; ++i)
- *p++ = color;
- }
- else if ( x1 == x2 ) {
- if (y1 > y2) {
- int tmp = y1;
- y1 = y2;
- y2 = tmp;
- }
- // vert line
- p = getXYData32(&s_primary, x1,y1);
- for (i = y1; i < y2; ++i) {
- *p = color;
- p = p + s_primary.lineBytes;
- }
- }
- }
- void mv_drawRect(const mv_Rect* rect, mv_color color)
- {
- mv_drawLine(rect->left, rect->top, rect->right, rect->top, color);
- mv_drawLine(rect->left, rect->bottom, rect->right, rect->bottom, color);
- mv_drawLine(rect->left, rect->top, rect->left, rect->bottom, color);
- mv_drawLine(rect->right, rect->top, rect->right, rect->bottom, color);
- }
- void mv_drawRect16(const mv_Rect* rect, unsigned short color)
- {
- mv_drawLine16(rect->left, rect->top, rect->right, rect->top, color);
- mv_drawLine16(rect->left, rect->bottom, rect->right, rect->bottom, color);
- mv_drawLine16(rect->left, rect->top, rect->left, rect->bottom, color);
- mv_drawLine16(rect->right, rect->top, rect->right, rect->bottom, color);
- }
- void mv_drawRect32(const mv_Rect* rect, unsigned int color)
- {
- mv_drawLine32(rect->left, rect->top, rect->right, rect->top, color);
- mv_drawLine32(rect->left, rect->bottom, rect->right, rect->bottom, color);
- mv_drawLine32(rect->left, rect->top, rect->left, rect->bottom, color);
- mv_drawLine32(rect->right, rect->top, rect->right, rect->bottom, color);
- }
- void mv_fillRect(const mv_Rect* rect, unsigned int color)
- {
- if(g_bpp == 16)
- mv_fillRect16(rect, color);
- else if(g_bpp == 32)
- mv_fillRect32(rect, color);
- }
- void mv_fillRect16(const mv_Rect* rect, unsigned short color){
- int y;
- for (y = rect->top; y < rect->bottom ; y++)
- mv_drawLine16(rect->left, y, rect->right, y, color);
- }
- void mv_fillRect32(const mv_Rect* rect, unsigned int color){
- int y;
- for (y = rect->top; y < rect->bottom ; y++)
- mv_drawLine32(rect->left, y, rect->right, y, color);
- }
- void mv_drawBitmap(int x, int y,
- const mv_surface* bmp,
- const mv_Rect * bmpRect,
- const mv_color * transColor){
- int width, height;
- int line, i;
- const char* from;
- char* to;
- if ( bmpRect) {
- width = bmpRect->right - bmpRect->left;
- height = bmpRect->bottom - bmpRect->top;
- from = (const char *)getXYData(bmp, bmpRect->left, bmpRect->top);
- }
- else {
- width = bmp->width;
- height = bmp->height;
- from = bmp->startAddr;
- }
- to = (char *)getXYData(&s_primary, x, y);
- if ( !transColor) {
- for (line = 0; line < height; line++) {
- Memcpy(to, from, width * sizeof(mv_color));
- from += bmp->lineBytes;
- to += s_primary.lineBytes;
- }
- }
- else {
- const mv_color* src;
- mv_color * dst;
- for (line = 0; line < height; line++) {
- src = (mv_color*)from;
- dst = (mv_color*)to;
- for (i = 0; i < width; i++) {
- if ( *src != *transColor)
- *dst = *src;
- src++;
- dst++;
- }
- from += bmp->lineBytes;
- to += s_primary.lineBytes;
- }
- }
- }
- void mv_drawBitmap16(int x, int y,
- const mv_surface* bmp,
- const mv_Rect * bmpRect,
- const unsigned short * transColor)
- {
- int width, height;
- int line, i;
- const char* from;
- char* to;
- if ( bmpRect) {
- width = bmpRect->right - bmpRect->left;
- height = bmpRect->bottom - bmpRect->top;
- from = (const char *)getXYData16(bmp, bmpRect->left, bmpRect->top);
- }
- else {
- width = bmp->width;
- height = bmp->height;
- from = bmp->startAddr;
- }
- to = (char *)getXYData16(&s_primary, x, y);
- if ( !transColor) {
- for (line = 0; line < height; line++) {
- Memcpy(to, from, width * sizeof(unsigned short));
- from += bmp->lineBytes;
- to += s_primary.lineBytes;
- }
- }
- else {
- const unsigned short* src;
- unsigned short * dst;
- for (line = 0; line < height; line++) {
- src = (unsigned short*)from;
- dst = (unsigned short*)to;
- for (i = 0; i < width; i++) {
- if ( *src != *transColor)
- *dst = *src;
- src++;
- dst++;
- }
- from += bmp->lineBytes;
- to += s_primary.lineBytes;
- }
- }
- }
- void mv_drawBitmap32(int x, int y,
- const mv_surface* bmp,
- const mv_Rect * bmpRect,
- const unsigned int * transColor)
- {
- int width, height;
- int line, i;
- const char* from;
- char* to;
- if ( bmpRect) {
- width = bmpRect->right - bmpRect->left;
- height = bmpRect->bottom - bmpRect->top;
- from = (const char *)getXYData32(bmp, bmpRect->left, bmpRect->top);
- }
- else {
- width = bmp->width;
- height = bmp->height;
- from = bmp->startAddr;
- }
- to = (char *)getXYData32(&s_primary, x, y);
- if ( !transColor) {
- for (line = 0; line < height; line++) {
- Memcpy(to, from, width * sizeof(unsigned int));
- from += bmp->lineBytes;
- to += s_primary.lineBytes;
- }
- }
- else {
- const unsigned int* src;
- unsigned int * dst;
- for (line = 0; line < height; line++) {
- src = (unsigned int*)from;
- dst = (unsigned int*)to;
- for (i = 0; i < width; i++) {
- if ( *src != *transColor)
- *dst = *src;
- src++;
- dst++;
- }
- from += bmp->lineBytes;
- to += s_primary.lineBytes;
- }
- }
- }
- int mv_loadBmp(const void* bmpData, mv_surface* img)
- {
- unsigned char r,g,b;
- int i, j, bytes;
- int width, height, offset;
- short colorBits;
- unsigned char *colorMap;
- const unsigned char* fileBuffer = (const unsigned char*)bmpData;
- if (*fileBuffer != 'B')
- return -1;
- offset = *(int*)(fileBuffer + 10); //ƫ����, 4Byte
- width = *(int*)(fileBuffer + 18); //����, 4Byte
- height = *(int*)(fileBuffer + 22); //�߶�, 4Byte
- colorBits = *(short*)(fileBuffer + 28); //ɫ��, 2Byte
- colorMap = (unsigned char*)(fileBuffer + 54); //��ɫ����ַ(8bitʱʹ��)
- img->width = width;
- img->height = height;
- img->lineBytes = width * sizeof(mv_color);
- switch (colorBits) {
- case 32: // r,g,b,a
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- b = *(fileBuffer + offset);
- g = *(fileBuffer + offset + 1);
- r = *(fileBuffer + offset + 2);
- // a = *(unsigned char*)(fileBuffer + offset + 3);
- *getXYData(img, j, i) = mv_RGB2Color(r,g,b);
- offset += 4;
- }
- }
- break;
- case 24: // r,g,b
- bytes = 4 - (width * 3) % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- b = *(fileBuffer + offset);
- g = *(fileBuffer + offset + 1);
- r = *(fileBuffer + offset + 2);
- *getXYData(img, j, i) = mv_RGB2Color(r,g,b);
- offset += 3;
- }
- offset += bytes;
- }
- break;
- case 16: //16bit 555
- {
- unsigned short color16;
- bytes = 4 - (width * 2) % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- color16 = *(unsigned short *)(fileBuffer+offset);
- #if ( GUI_RGB_FORMAT == RGB_FORMAT_565)
- *getXYData(img, j, i) = (color16<<1) & 0xFFC0 | (color16 & 0x1F);
- #else
- *getXYData(img, j, i) = mv_RGB2Color((color16 & 0x7C00) >> 7, (color16 & 0x03E0) >> 2, (color16 & 0x001F) << 3);
- #endif
- offset += 2;
- }
- offset += bytes;
- }
- }
- break;
- case 8: //256 colormap
- bytes = 4 - width % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- int offSet = *(fileBuffer + offset) * 4;
- b = colorMap[offSet];
- g = colorMap[offSet + 1];
- r = colorMap[offSet + 2];
- *getXYData(img, j, i) = mv_RGB2Color(r,g,b);
- offset ++;
- }
- offset += bytes;
- }
- break;
- default:
- break;
- }
- return 0;
- }
- int mv_loadBmp16(const void* bmpData, mv_surface* img)
- {
- unsigned char r,g,b;
- int i, j, bytes;
- int width, height, offset;
- short colorBits;
- unsigned char *colorMap;
- const unsigned char* fileBuffer = (const unsigned char*)bmpData;
- if (*fileBuffer != 'B')
- return -1;
- offset = *(int*)(fileBuffer + 10); //ƫ����, 4Byte
- width = *(int*)(fileBuffer + 18); //����, 4Byte
- height = *(int*)(fileBuffer + 22); //�߶�, 4Byte
- colorBits = *(short*)(fileBuffer + 28); //ɫ��, 2Byte
- colorMap = (unsigned char*)(fileBuffer + 54); //��ɫ����ַ(8bitʱʹ��)
- img->width = width;
- img->height = height;
- img->lineBytes = width * sizeof(unsigned short);
- switch (colorBits) {
- case 32: // r,g,b,a
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- b = *(fileBuffer + offset);
- g = *(fileBuffer + offset + 1);
- r = *(fileBuffer + offset + 2);
- // a = *(unsigned char*)(fileBuffer + offset + 3);
- *getXYData16(img, j, i) = mv_RGB2Color(r,g,b);
- offset += 4;
- }
- }
- break;
- case 24: // r,g,b
- bytes = 4 - (width * 3) % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- b = *(fileBuffer + offset);
- g = *(fileBuffer + offset + 1);
- r = *(fileBuffer + offset + 2);
- *getXYData16(img, j, i) = mv_RGB2Color(r,g,b);
- offset += 3;
- }
- offset += bytes;
- }
- break;
- case 16: //16bit 555
- {
- unsigned short color16;
- bytes = 4 - (width * 2) % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- color16 = *(unsigned short *)(fileBuffer+offset);
- #if (GUI_RGB_FORMAT == RGB_FORMAT_565)
- *getXYData16(img, j, i) = (color16<<1) & 0xFFC0 | (color16 & 0x1F);
- #else
- *getXYData16(img, j, i) = mv_RGB2Color((color16 & 0x7C00) >> 7, (color16 & 0x03E0) >> 2, (color16 & 0x001F) << 3);
- #endif
- offset += 2;
- }
- offset += bytes;
- }
- }
- break;
- case 8: //256 colormap
- bytes = 4 - width % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- int offSet = *(fileBuffer + offset) * 4;
- b = colorMap[offSet];
- g = colorMap[offSet + 1];
- r = colorMap[offSet + 2];
- *getXYData16(img, j, i) = mv_RGB2Color(r,g,b);
- offset ++;
- }
- offset += bytes;
- }
- break;
- default:
- break;
- }
- return 0;
- }
- int mv_loadBmp32(const void* bmpData, mv_surface* img)
- {
- unsigned char r,g,b;
- int i, j, bytes;
- int width, height, offset;
- short colorBits;
- unsigned char *colorMap;
- const unsigned char* fileBuffer = (const unsigned char*)bmpData;
- if (*fileBuffer != 'B')
- return -1;
- offset = *(int*)(fileBuffer + 10);//偏移量, 4Byte
- width = *(int*)(fileBuffer + 18);//宽度, 4Byte
- height = *(int*)(fileBuffer + 22);//高度, 4Byte
- colorBits = *(short*)(fileBuffer + 28); //色深, 2Byte
- colorMap = (unsigned char*)(fileBuffer + 54); //颜色表地址(8bit时使用)
- img->width = width;
- img->height = height;
- img->lineBytes = width * sizeof(unsigned int);
- switch (colorBits) {
- case 32: // r,g,b,a
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- b = *(fileBuffer + offset);
- g = *(fileBuffer + offset + 1);
- r = *(fileBuffer + offset + 2);
- // a = *(unsigned char*)(fileBuffer + offset + 3);
- *getXYData32(img, j, i) = mv_RGB2Color(r,g,b);
- offset += 4;
- }
- }
- break;
- case 24:// r,g,b
- bytes = 4 - (width * 3) % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- b = *(fileBuffer + offset);
- g = *(fileBuffer + offset + 1);
- r = *(fileBuffer + offset + 2);
- *getXYData32(img, j, i) = mv_RGB2Color(r,g,b);
- offset += 3;
- }
- offset += bytes;
- }
- break;
- case 16://16bit 555
- {
- unsigned short color16;
- bytes = 4 - (width * 2) % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- color16 = *(unsigned short *)(fileBuffer+offset);
- #if ( GUI_RGB_FORMAT == RGB_FORMAT_565)
- *getXYData32(img, j, i) = (color16<<1) & 0xFFC0 | (color16 & 0x1F);
- #else
- *getXYData32(img, j, i) = mv_RGB2Color((color16 & 0x7C00) >> 7, (color16 & 0x03E0) >> 2, (color16 & 0x001F) << 3);
- #endif
- offset += 2;
- }
- offset += bytes;
- }
- }
- break;
- case 8: //256 colormap
- bytes = 4 - width % 4;
- if (bytes == 4)
- bytes = 0;
- for (i = height - 1; i >= 0; i--) {
- for (j = 0; j < width; j++) {
- int offSet = *(fileBuffer + offset) * 4;
- b = colorMap[offSet];
- g = colorMap[offSet + 1];
- r = colorMap[offSet + 2];
- *getXYData32(img, j, i) = mv_RGB2Color(r,g,b);
- offset ++;
- }
- offset += bytes;
- }
- break;
- default:
- break;
- }
- return 0;
- }
- static int getGlyphIndex(unsigned short unicode)
- {
- int i;
- GlyphRange * const range = (GlyphRange*)(m_fh+1);
- GlyphScatter * start;
- GlyphScatter * scatter;
- int low;
- int high;
- int mid;
- int glyphIndex = 1; // == 1 to skip missing lattice
- for (i = 0 ; i < m_fh->rangeCount; i++) {
- if ( unicode >= range[i].ucs2Start && unicode <= range[i].ucs2End) {
- glyphIndex += (unicode - range[i].ucs2Start);
- return glyphIndex;
- }
- glyphIndex += range[i].ucs2End - range[i].ucs2Start + 1;
- }
- start = (GlyphScatter*)(range + m_fh->rangeCount);
- low = 0;
- high = m_fh->scatterCount - 1;
- while (low <= high) {
- mid = (low + high) / 2;
- scatter = start + mid;
- if ( *scatter < unicode)
- low = mid + 1;
- else if ( *scatter > unicode)
- high = mid - 1;
- else
- return(glyphIndex + mid);
- }
- return 0;// the missing glyph
- }
- static unsigned char * getLattice(int glyphIndex)
- {
- return m_glyphStart + glyphIndex * m_fh->glyphBytes;
- }
- static int setFontFileDat(const unsigned char * dat)
- {
- FontFileHeadV1 * fh = (FontFileHeadV1*)dat;
- if ( fh->magic[0] != 'F' || fh->magic[1] != 'T') {
- printf("fh->magic[0] %c,fh->magic[1] %c\n",fh->magic[0],fh->magic[1]);
- return -1;
- }
- m_fileStart = (unsigned char * )dat;
- m_fh = (FontFileHeadV1*)m_fileStart;
- m_glyphStart = m_fileStart + sizeof(FontFileHeadV1)
- + m_fh->rangeCount * sizeof(GlyphRange)
- + m_fh->scatterCount * sizeof(GlyphScatter);
- return 0;
- }
- static void loadFontImage(int code, mv_surface* img)
- {
- int idx = 0;
- idx = getGlyphIndex((unsigned short)code);
- img->width = m_fh->charWidth;
- img->height = m_fh->charHeight;
- img->startAddr = (char *)getLattice(idx);
- }
- int mv_textOut(int x, int y, const char * string, unsigned int textColor)
- {
- if(g_bpp == 16)
- mv_textOut16(x, y, string, textColor);
- else if(g_bpp == 32)
- mv_textOut32(x, y, string, textColor);
- }
- int mv_textOut16(int x, int y, const char * string, unsigned short textColor)
- {
- mv_surface img;
- const char * p;
- const unsigned char * lattice;
- int h,w;
- int height = 0;
- for (p = string; *p != '\0'; p++) {
- loadFontImage(*p, &img);
- if(img.height > height)
- height = img.height;
- lattice = (const unsigned char * )img.startAddr;
- if (!lattice)
- continue;
- for ( h = 0 ; h < img.height; ++h) {
- unsigned char mask = 0x80;
- for ( w = 0 ; w < img.width; ++w) {
- if (*lattice & mask) {
- *(getXYData16(&s_primary, x + w, y + h)) = textColor;
- }
- mask >>= 1;
- if ( mask == 0 ) {
- mask = 0x80;
- ++lattice;// next byte
- }
- }
- if (mask != 0x80) {
- ++lattice;// next byte
- }
- }
- x += img.width;
- }
- return height;
- }
- int mv_textOut32(int x, int y, const char * string, unsigned int textColor)
- {
- mv_surface img;
- const char * p;
- const unsigned char * lattice;
- int h,w;
- int height = 0;
- for (p = string; *p != '\0'; p++) {
- loadFontImage(*p, &img);
- if(img.height > height)
- height = img.height;
- lattice = (const unsigned char * )img.startAddr;
- if (!lattice)
- continue;
- for ( h = 0 ; h < img.height; ++h) {
- unsigned char mask = 0x80;
- for ( w = 0 ; w < img.width; ++w) {
- if (*lattice & mask) {
- *(getXYData32(&s_primary, x + w, y + h)) = textColor;
- }
- mask >>= 1;
- if ( mask == 0 ) {
- mask = 0x80;
- ++lattice;// next byte
- }
- }
- if (mask != 0x80) {
- ++lattice;// next byte
- }
- }
- x += img.width;
- }
- return height;
- }
|