public void SetGlyphInfo(BDF_Glyph_Header GlyphHeader) { OffsetX = GlyphHeader.BitmapOffsetX; OffsetY -= GlyphHeader.BitmapOffsetY + GlyphHeader.BitmapHeight; BitmapWidth = GlyphHeader.BitmapWidth; BitmapHeight = GlyphHeader.BitmapHeight; }
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 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); } }
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 void EraseRemainingBackground(BDF_Glyph_Header GlyphHeader) { Int32 StartBitmapY = FontHeader.BoundingBoxHeight + FontHeader.BoundingBoxOffsetY - GlyphHeader.BitmapOffsetY - GlyphHeader.BitmapHeight; Int32 EndBitmapY = StartBitmapY + GlyphHeader.BitmapHeight; for (int Y = 0; Y < FontHeader.BoundingBoxHeight; Y++) { for (int X = 0; X < FontHeader.BoundingBoxWidth; X++) { if (Y >= StartBitmapY && Y < EndBitmapY) { if (X == GlyphHeader.BitmapOffsetX) { X += GlyphHeader.BitmapWidth; } } PutFontPixel(X, Y, false); } } }
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; } }