public GlyphSymbol(GlyphFlags GlyphType = GlyphFlags.FONT_PGF_CHARGLYPH) { this.GlyphType = GlyphType; }
public GlyphSymbol Read(PGF PGF, int GlyphIndex) { var br = new BitReader(PGF.charData); br.Position = PGF.charPointer[GlyphIndex] * 4 * 8; this.GlyphIndex = GlyphIndex; this.UnicodeChar = (char)PGF.reverseCharMap[GlyphIndex]; //int NextOffset = br.Position; //br.Position = NextOffset; int ShadowOffset = (int)br.Position + (int)br.ReadBits(14) * 8; if (GlyphType == GlyphFlags.FONT_PGF_SHADOWGLYPH) { br.Position = ShadowOffset; br.SkipBits(14); } this.Width = br.ReadBits(7); this.Height = br.ReadBits(7); this.Left = br.ReadBitsSigned(7); this.Top = br.ReadBitsSigned(7); this.Flags = (GlyphFlags)br.ReadBits(6); if (Flags.HasFlag(GlyphFlags.FONT_PGF_CHARGLYPH)) { br.SkipBits(7); var shadowId = br.ReadBits(9); br.SkipBits(24); if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG1)) br.SkipBits(56); if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG2)) br.SkipBits(56); if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG3)) br.SkipBits(56); this.AdvanceIndex = br.ReadBits(8); } this.DataByteOffset = (uint)(br.Position / 8); uint PixelIndex = 0; uint NumberOfPixels = Width * Height; bool BitmapHorizontalRows = (Flags & GlyphFlags.FONT_PGF_BMP_OVERLAY) == GlyphFlags.FONT_PGF_BMP_H_ROWS; this.Data = new byte[NumberOfPixels]; int Count; uint Value = 0; uint x, y; //Console.WriteLine(br.BitsLeft); while (PixelIndex < NumberOfPixels) { uint Code = br.ReadBits(4); if (Code < 8) { Value = br.ReadBits(4); Count = (int)Code + 1; } else { Count = 16 - (int)Code; } for (int n = 0; (n < Count) && (PixelIndex < NumberOfPixels); n++) { if (Code >= 8) { Value = br.ReadBits(4); } if (BitmapHorizontalRows) { x = PixelIndex % Width; y = PixelIndex / Width; } else { x = PixelIndex / Height; y = PixelIndex % Height; } this.Data[x + y * Width] = (byte)((Value << 0) | (Value << 4)); PixelIndex++; } } /* for (int y = 0, n = 0; y < Height; y++) { for (int x = 0; x < Width; x++, n++) { Console.Write("{0:X1}", this.Data[n] & 0xF); //String.Format } Console.WriteLine(""); } */ //Console.WriteLine(this); return this; }
public GlyphSymbol(GlyphFlags glyphType = GlyphFlags.FontPgfCharglyph) => _glyphType = glyphType;
private PositionedGlyph(uint index, GlyphFlags flags, Vector2 position) { Index = index; Flags = flags; Position = position; }
private static void UpdateGlyphFlags( IOpenTypeFont Font, GlyphInfoList GlyphInfo, int FirstGlyph, int AfterLastGlyph, bool DoAll, GlyphFlags FlagToSet ) { Debug.Assert( FlagToSet==GlyphFlags.NotChanged || FlagToSet==GlyphFlags.Substituted || FlagToSet==GlyphFlags.Positioned); ushort typemask = (ushort)GlyphFlags.GlyphTypeMask; FontTable gdefTable = Font.GetFontTable(OpenTypeTags.GDEF); if (!gdefTable.IsPresent) { //GDEF(i.e. class def in it) is not present. //Assign unassigned to all glyphs for(int i=FirstGlyph;i<AfterLastGlyph;i++) { ushort flags = (ushort)( (GlyphInfo.GlyphFlags[i] & (ushort)~typemask) | (ushort)GlyphFlags.Unassigned | (ushort)FlagToSet); } return; } GDEFHeader gdefHeader = new GDEFHeader(0); ClassDefTable GlyphClassDef = gdefHeader.GetGlyphClassDef(gdefTable); for(int i=FirstGlyph;i<AfterLastGlyph;i++) { ushort flags = (ushort)(GlyphInfo.GlyphFlags[i] | (ushort)FlagToSet); if ((flags & typemask) == (ushort)GlyphFlags.Unresolved || FlagToSet!=GlyphFlags.NotChanged) { ushort glyph = GlyphInfo.Glyphs[i]; flags &= (ushort)~typemask; int glyphClass = GlyphClassDef.GetClass(gdefTable,glyph); GlyphInfo.GlyphFlags[i] = (ushort)(flags| ((glyphClass==-1)? (ushort)GlyphFlags.Unassigned: (ushort)glyphClass ) ); } } }
public GlyphSymbol Read(PGF PGF, int GlyphIndex) { var br = new BitReader(PGF.charData); br.Position = PGF.charPointer[GlyphIndex] * 4 * 8; this.GlyphIndex = GlyphIndex; this.UnicodeChar = (char)PGF.reverseCharMap[GlyphIndex]; //int NextOffset = br.Position; //br.Position = NextOffset; int ShadowOffset = (int)br.Position + (int)br.ReadBits(14) * 8; if (GlyphType == GlyphFlags.FONT_PGF_SHADOWGLYPH) { br.Position = ShadowOffset; br.SkipBits(14); } this.Width = br.ReadBits(7); this.Height = br.ReadBits(7); this.Left = br.ReadBitsSigned(7); this.Top = br.ReadBitsSigned(7); this.Flags = (GlyphFlags)br.ReadBits(6); if (Flags.HasFlag(GlyphFlags.FONT_PGF_CHARGLYPH)) { br.SkipBits(7); var shadowId = br.ReadBits(9); br.SkipBits(24); if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG1)) { br.SkipBits(56); } if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG2)) { br.SkipBits(56); } if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG3)) { br.SkipBits(56); } this.AdvanceIndex = br.ReadBits(8); } this.DataByteOffset = (uint)(br.Position / 8); uint PixelIndex = 0; uint NumberOfPixels = Width * Height; bool BitmapHorizontalRows = (Flags & GlyphFlags.FONT_PGF_BMP_OVERLAY) == GlyphFlags.FONT_PGF_BMP_H_ROWS; this.Data = new byte[NumberOfPixels]; int Count; uint Value = 0; uint x, y; //Console.WriteLine(br.BitsLeft); while (PixelIndex < NumberOfPixels) { uint Code = br.ReadBits(4); if (Code < 8) { Value = br.ReadBits(4); Count = (int)Code + 1; } else { Count = 16 - (int)Code; } for (int n = 0; (n < Count) && (PixelIndex < NumberOfPixels); n++) { if (Code >= 8) { Value = br.ReadBits(4); } if (BitmapHorizontalRows) { x = PixelIndex % Width; y = PixelIndex / Width; } else { x = PixelIndex / Height; y = PixelIndex % Height; } this.Data[x + y * Width] = (byte)((Value << 0) | (Value << 4)); PixelIndex++; } } /* * for (int y = 0, n = 0; y < Height; y++) * { * for (int x = 0; x < Width; x++, n++) * { * Console.Write("{0:X1}", this.Data[n] & 0xF); * //String.Format * } * Console.WriteLine(""); * } * */ //Console.WriteLine(this); return(this); }