private Int32 DecodeBitFieldSigned(GlyphDecodeInfo DecodeInfo, byte NrOfBits)
        {
            Int32 v = DecodeBitFieldUnsigned(DecodeInfo, NrOfBits);
            Int32 d = 1 << (NrOfBits - 1);

            v -= d;

            return(v);
        }
        private BDF_Glyph_Header ReadGlyphHeader(ref GlyphDecodeInfo DecodeInfo)
        {
            BDF_Glyph_Header GlyphHeader = new BDF_Glyph_Header();

            GlyphHeader.BitmapWidth   = DecodeBitFieldUnsigned(DecodeInfo, FontHeader.GlyphWidthSizeInBits);
            GlyphHeader.BitmapHeight  = DecodeBitFieldUnsigned(DecodeInfo, FontHeader.GlyphHeightSizeInBits);
            GlyphHeader.BitmapOffsetX = DecodeBitFieldSigned(DecodeInfo, FontHeader.GlyphOffetXSizeInBits);
            GlyphHeader.BitmapOffsetY = DecodeBitFieldSigned(DecodeInfo, FontHeader.GlyphOffetYSizeInBits);
            GlyphHeader.BitmapPitch   = DecodeBitFieldSigned(DecodeInfo, FontHeader.GlyphPitchSizeInBits);
            return(GlyphHeader);
        }
 private void WritePixels(ref GlyphDecodeInfo DecodeInfo, Int32 NrOfPixels, bool Color)
 {
     for (int i = 0; i < NrOfPixels; i++)
     {
         if (DecodeInfo.IsBitmapReady())
         {
             return;
         }
         PutFontPixel(DecodeInfo.BitmapX + DecodeInfo.OffsetX, DecodeInfo.BitmapY + DecodeInfo.OffsetY, Color);
         DecodeInfo.MoveOnePixel();
     }
 }
 private void DrawGlyph(GlyphDecodeInfo DecodeInfo, BDF_Glyph_Header GlyphHeader)
 {
     while (!DecodeInfo.IsBitmapReady())
     {
         Int32 Pixels0 = DecodeBitFieldUnsigned(DecodeInfo, (byte)FontHeader.m0);
         Int32 Pixels1 = DecodeBitFieldUnsigned(DecodeInfo, (byte)FontHeader.m1);
         do
         {
             WritePixels(ref DecodeInfo, Pixels0, false);
             WritePixels(ref DecodeInfo, Pixels1, true);
         } while (DecodeBitFieldUnsigned(DecodeInfo, 1) == 1);
     }
 }
示例#5
0
        public Int32 GetPixelLength(String Text)
        {
            Int32 PixelWidth = 0;

            for (int i = 0; i < Text.Length; i++)
            {
                Int32            GlyphPos    = GetCharPos(Text[i]);
                GlyphDecodeInfo  DecodeInfo  = new GlyphDecodeInfo(FontHeader, GlyphPos);
                BDF_Glyph_Header GlyphHeader = ReadGlyphHeader(ref DecodeInfo);
                PixelWidth += GlyphHeader.BitmapPitch;
            }

            return(PixelWidth);
        }
        private Int32 DecodeBitFieldUnsigned(GlyphDecodeInfo DecodeInfo, byte NrOfBits)
        {
            Int32 BytePos = DecodeInfo.GlyphPos + 2 + (DecodeInfo.BitOffset / 8);
            Int32 AlreadyReadBitsOfByte = DecodeInfo.BitOffset % 8;
            Int32 BitMask = (Int32) ~(0xFFFFFFFF << NrOfBits);

            Int32 BytesValue = (Int32)(FontHeader.FontData[BytePos + 1] * 256) + FontHeader.FontData[BytePos];

            BytesValue = BytesValue >> AlreadyReadBitsOfByte;
            BytesValue = BytesValue & BitMask;

            DecodeInfo.BitOffset += NrOfBits;

            return(BytesValue);
        }
        private void DrawGlyph(Int32 GlyphPos, bool RightAlignment)
        {
            GlyphDecodeInfo  DecodeInfo  = new GlyphDecodeInfo(FontHeader, GlyphPos);
            BDF_Glyph_Header GlyphHeader = ReadGlyphHeader(ref DecodeInfo);

            DecodeInfo.SetGlyphInfo(GlyphHeader);

            if (RightAlignment)
            {
                CursorX -= GlyphHeader.BitmapPitch;
            }

            DrawGlyph(DecodeInfo, GlyphHeader);

            if (!ModeTransparent)
            {
                EraseRemainingBackground(GlyphHeader);
            }

            if (!RightAlignment)
            {
                CursorX += GlyphHeader.BitmapPitch;
            }
        }