Ejemplo n.º 1
0
        private DPixelFont.CharItem HanzToPixel(HanzFontItem hanzItem)
        {
            DPixelFont.CharItem ret = new DPixelFont.CharItem();
            ret.Code = hanzItem.code;
            if (hanzItem.code < 128)
            {
                if (hanzItem.code - 0x20 <= AscFontSize.Length)
                {
                    ret.CharWidth = (ushort)AscFontSize[hanzItem.code - 0x20].Width;
                }
                else
                {
                    ret.CharWidth = AscWidth;
                }
                ret.Data = new byte[(ret.CharWidth + 7) / 8 * CharLines];
                for (int i = 0; i < CharLines; i++)
                {
                    int pixelStart = (ret.CharWidth + 7) / 8 * i;
                    int hanzStart  = (MapWidth + 7) / 8 * i;

                    for (int j = 0; j < ret.CharWidth; j = j + 8)
                    {
                        ret.Data[pixelStart + j / 8] = copyLeftBit(hanzItem.array[hanzStart + j / 8], ret.CharWidth - j);
                    }
                }
            }
            else
            {
                ret.CharWidth = this.MapWidth;
                ret.Data      = hanzItem.array;
            }

            return(ret);
        }
Ejemplo n.º 2
0
        private HanzFontItem loadAscFont(MemoryReader mr, int charSize, int code)
        {
            HanzFontItem ret = new HanzFontItem();

            gbkBuffer[0] = (byte)(code & 0xff);
            gbkBuffer[1] = 0;

            ret.code  = gbkEncoding.GetChars(gbkBuffer)[0];
            ret.array = new byte[charSize];
            mr.readBytes(ret.array);

            return(ret);
        }