Пример #1
0
            private UnicodeFont.UnicodeFontFactory.CharacterBits GetCharacter(char c, bool needBits)
            {
                int index = (int)c;

                if (index < 0 || index >= 256)
                {
                    return(this.LoadCharacter(index, needBits));
                }
                if (this.m_LowCharacters == null)
                {
                    this.m_LowCharacters = new UnicodeFont.UnicodeFontFactory.CharacterBits[256];
                }
                UnicodeFont.UnicodeFontFactory.CharacterBits characterBits = this.m_LowCharacters[index];
                if (characterBits == null)
                {
                    this.m_LowCharacters[index] = characterBits = this.LoadCharacter(index, true);
                }
                return(characterBits);
            }
Пример #2
0
            protected override unsafe void CoreProcessImage(int width, int height, int stride, ushort *pLine, ushort *pLineEnd, ushort *pImageEnd, int lineDelta, int lineEndDelta)
            {
                string str        = this.m_String;
                int    num1       = 0;
                int    num2       = 0;
                int    spaceWidth = this.m_Font.SpaceWidth;
                bool   flag1      = false;
                int    size       = width * height;

                byte[] numArray = UnicodeFont.UnicodeFontFactory.m_Buffer;
                if (numArray == null || size > numArray.Length)
                {
                    UnicodeFont.UnicodeFontFactory.m_Buffer = numArray = new byte[size];
                }
                bool flag2 = (this.m_Flags & 8) != 0;

                fixed(byte *buffer = numArray)
                {
                    UnsafeMethods.ZeroMemory(buffer, size);
                    for (int index1 = 0; index1 < str.Length; ++index1)
                    {
                        char c = str[index1];
                        switch (c)
                        {
                        case '\t':
                            flag1 = false;
                            num1 += 24;
                            break;

                        case '\n':
                        case '\r':
                            if (!flag1)
                            {
                                num1  = 0;
                                num2 += 18;
                                flag1 = true;
                                break;
                            }
                            break;

                        case ' ':
                            flag1 = false;
                            num1 += spaceWidth;
                            break;

                        default:
                            flag1 = false;
                            UnicodeFont.UnicodeFontFactory.CharacterBits character = this.GetCharacter(c, true);
                            if (num1 > 0)
                            {
                                ++num1;
                            }
                            int num3 = num1 + character.m_xOffset;
                            fixed(byte *numPtr1 = character.m_Bits)
                            {
                                IntPtr localPtr = (IntPtr)numPtr1;
                                byte * numPtr2  = buffer + ((num2 + 1 + character.m_yOffset) * width) + (num3 + 1 + character.m_xWidth - 1);
                                int    num4     = 32 - character.m_xWidth;
                                int    num5     = character.m_xWidth + 7 >> 3;
                                int    num6     = (num2 + 1 + character.m_yOffset) * width + (num3 + 1 + character.m_xWidth - 1);
                                int    num7     = 0;

                                while (num7 < character.m_yHeight)
                                {
                                    uint  num8    = *(uint *)localPtr;
                                    uint  num9    = (uint)(((int)num8 & (int)byte.MaxValue) << 24 | ((int)num8 & 65280) << 8 | (int)((num8 & 16711680U) >> 8) | (int)(num8 >> 24) & (int)byte.MaxValue) >> num4;
                                    byte *numPtr3 = numPtr2;
                                    int   index2  = num6;
                                    int   num10   = num3 + 1 + character.m_xWidth - 1;
                                    int   num11   = num2 + 1 + character.m_yOffset + num7;
                                    if (num11 > 0 && num11 + 1 < height)
                                    {
                                        if (flag2)
                                        {
                                            if (num10 + 1 < width)
                                            {
                                                while ((int)num9 != 0 && num10 > 0)
                                                {
                                                    if (((int)num9 & 1) != 0)
                                                    {
                                                        IntPtr num12 = (IntPtr)(numPtr3 - width);
                                                        int    num13 = (int)(byte)((uint)*(byte *)num12 | 128U);
                                                        *(sbyte *)num12 = (sbyte)num13;
                                                        IntPtr num14 = (IntPtr)(numPtr3 - 1);
                                                        int    num15 = (int)(byte)((uint)*(byte *)num14 | 128U);
                                                        *(sbyte *)num14 = (sbyte)num15;
                                                        *      numPtr3 = (byte)2;
                                                        IntPtr num16   = (IntPtr)(numPtr3 + 1);
                                                        int    num17   = (int)(byte)((uint)*(byte *)num16 | 128U);
                                                        *(sbyte *)num16 = (sbyte)num17;
                                                        IntPtr num18 = (IntPtr)(numPtr3 + width);
                                                        int    num19 = (int)(byte)((uint)*(byte *)num18 | 128U);
                                                        *(sbyte *)num18           = (sbyte)num19;
                                                        numArray[index2 - width] |= (byte)128;
                                                        numArray[index2 - 1]     |= (byte)128;
                                                        numArray[index2]          = (byte)2;
                                                        numArray[index2 + 1]     |= (byte)128;
                                                        numArray[index2 + width] |= (byte)128;
                                                    }
                                                    --numPtr3;
                                                    --index2;
                                                    --num10;
                                                    num9 >>= 1;
                                                }
                                            }
                                        }
                                        else if (num10 + 1 < width)
                                        {
                                            while ((int)num9 != 0 && num10 > 0)
                                            {
                                                if (((int)num9 & 1) != 0)
                                                {
                                                    *numPtr3 = (byte)2;
                                                    numArray[index2] = (byte)2;
                                                }
                                                --numPtr3;
                                                --index2;
                                                --num10;
                                                num9 >>= 1;
                                            }
                                        }
                                    }
                                    ++num7;
                                    numPtr2  += width;
                                    num6     += width;
                                    localPtr += num5;
                                }
                            }

                            num1 = num3 + character.m_xWidth;
                            break;
                        }
                    }
                    int   num20   = width;
                    int   num21   = height;
                    int   num22   = 0;
                    int   num23   = 0;
                    bool  flag3   = (this.m_Flags & 1) != 0;
                    byte *numPtr4 = buffer;

                    fixed(short *numPtr1 = UnicodeFont.m_Colors)
                    fixed(short *numPtr2 = UnicodeFont.m_HuedColors)
                    {
                        Hues.Default.CopyPixels((void *)(numPtr1 + 1), (void *)((ushort *)numPtr2 + 1), 32);
                        Hues.Default.CopyPixels((void *)(numPtr1 + 129), (void *)((ushort *)numPtr2 + 129), 32);
                        for (int index1 = 0; index1 < height; ++index1)
                        {
                            for (int index2 = 0; index2 < width; ++index2)
                            {
                                if ((int)*numPtr4 != 0)
                                {
                                    if (index2 < num20)
                                    {
                                        num20 = index2;
                                    }
                                    if (index2 > num22)
                                    {
                                        num22 = index2;
                                    }
                                    if (index1 < num21)
                                    {
                                        num21 = index1;
                                    }
                                    if (index1 > num23)
                                    {
                                        num23 = index1;
                                    }
                                }
                                if (flag3 && index1 % 18 == 15)
                                {
                                    *numPtr4 = (byte)16;
                                }
                                *pLine++ = ((ushort *)numPtr2)[*numPtr4++];
                            }
                            pLine += lineDelta;
                        }
                    }
                    this.m_xMin = num20;
                    this.m_yMin = num21;
                    this.m_xMax = num22;
                    this.m_yMax = num23;
                }
            }
Пример #3
0
            protected override void CoreGetDimensions(out int width, out int height)
            {
                string str        = this.m_String;
                int    num1       = 0;
                int    num2       = 0;
                int    num3       = 0;
                int    num4       = 18;
                int    spaceWidth = this.m_Font.SpaceWidth;
                bool   flag       = false;

                for (int index = 0; index < str.Length; ++index)
                {
                    char c = str[index];
                    switch (c)
                    {
                    case '\t':
                        flag  = false;
                        num1 += 24;
                        if (num1 > num3)
                        {
                            num3 = num1;
                            break;
                        }
                        break;

                    case '\n':
                    case '\r':
                        if (!flag)
                        {
                            num1  = 0;
                            num2 += 18;
                            num4 += 18;
                            flag  = true;
                            break;
                        }
                        break;

                    case ' ':
                        flag  = false;
                        num1 += spaceWidth;
                        if (num1 > num3)
                        {
                            num3 = num1;
                            break;
                        }
                        break;

                    default:
                        flag = false;
                        UnicodeFont.UnicodeFontFactory.CharacterBits character = this.GetCharacter(c, false);
                        if (num1 > 0)
                        {
                            ++num1;
                        }
                        num1 += character.m_xOffset + character.m_xWidth;
                        if (num1 > num3)
                        {
                            num3 = num1;
                        }
                        if (num2 + character.m_yOffset + character.m_yHeight > num4)
                        {
                            num4 = num2 + character.m_yOffset + character.m_yHeight;
                            break;
                        }
                        break;
                    }
                }
                width  = num3 + 2;
                height = num4 + 2;
            }