public GlyphBitmapData GetGlyphBitmapData(int index, int glyphId) { if (index < 0 || index >= EBLC.bitmapSizes.Length) { return(null); } if (File.Exists(filePath) == false) { return(null); } BitmapSize size = EBLC.bitmapSizes[index]; IndexSubTableArray array = size.FindSubTableArray(glyphId); if (array == null) { return(null); } using (Stream stream = File.OpenRead(filePath)) using (BinaryReaderFont reader = new BinaryReaderFont(stream)) { reader.Position = position + array.subTable.header.imageDataOffset; return(array.subTable.ReadBitmapData(reader, glyphId, glyphId - array.firstGlyphIndex)); } /* * if (index < 0 || index >= bitmapData.Count) { * return null; * } * if (bitmapData[index].ContainsKey((ushort)glyphId) == false) { * return null; * } * return bitmapData[index][(ushort)glyphId]; * //*/ }
protected static void DrawBitmapData5(RendererContext context, BitmapSize size, GlyphBitmapData5 data) { //Console.WriteLine("data5: {0}", data5); BigGlyphMetrics bigMetrics = null; IndexSubTableArray subTable = size.FindSubTableArray(context.GlyphId); if (subTable != null) { //Console.WriteLine("Size 2: {0}", context.GlyphId); //Console.WriteLine("Size 3: {0}", subTable); bigMetrics = subTable.GetBigGlyphMetrics(); //Console.WriteLine("Size 4: {0}", metrics); } if (bigMetrics != null) { DrawImageData( context, size.bitDepth, bigMetrics, data.imageData ); } else { DrawImageData( context, size.bitDepth, size.hori.widthMax, context.FontSize, data.imageData ); context.X += context.FontSize; } }
public static BitmapSize[] ReadArray(BinaryReaderFont reader, int count) { BitmapSize[] array = new BitmapSize[count]; for (int i = 0; i < count; i++) { array[i] = Read(reader); } return(array); }
public static EBLCTable Read(BinaryReaderFont reader) { long position = reader.Position; EBLCTable value = new EBLCTable { majorVersion = reader.ReadUInt16(), minorVersion = reader.ReadUInt16(), numSizes = reader.ReadUInt32() }; value.bitmapSizes = BitmapSize.ReadArray(reader, (int)value.numSizes); for (int i = 0; i < value.numSizes; i++) { value.bitmapSizes[i].ReadSubTableArray(reader, position); value.bitmapSizes[i].index = i; } return(value); }
public BitmapSize GetBitmapSize(int ppemX, int ppemY) { if (bitmapSizes == null) { return(null); } int length = bitmapSizes.Length; for (int i = 0; i < length; i++) { BitmapSize size = bitmapSizes[i]; if (size.ppemX == ppemX && size.ppemY == ppemY) { return(size); } } return(null); }
public bool HasSize(int ppemX, int ppemY) { if (bitmapSizes == null) { return(false); } int length = bitmapSizes.Length; for (int i = 0; i < length; i++) { BitmapSize size = bitmapSizes[i]; if (size.ppemX == ppemX && size.ppemY == ppemY) { return(true); } } return(false); }
public static BitmapSize Read(BinaryReaderFont reader) { BitmapSize value = new BitmapSize { indexSubTableArrayOffset = reader.ReadUInt32(), indexTablesSize = reader.ReadUInt32(), numberofIndexSubTables = reader.ReadUInt32(), colorRef = reader.ReadUInt32(), hori = SbitLineMetrics.Read(reader), vert = SbitLineMetrics.Read(reader), startGlyphIndex = reader.ReadUInt16(), endGlyphIndex = reader.ReadUInt16(), ppemX = reader.ReadByte(), ppemY = reader.ReadByte(), bitDepth = (BitDepth)reader.ReadByte(), flags = (BitmapFlags)reader.ReadByte() }; return(value); }
public static void DrawGlyph(RendererContext context) { EBLCTable EBLC = context.Font.Tables.EBLC; EBDTTable EBDT = context.Font.Tables.EBDT; //Bitmap bitmap = context.Bitmap; BitmapSize size = EBLC.GetBitmapSize(context.FontSize, context.FontSize); //Console.WriteLine("bitDepth: {0}", size.bitDepth); //Console.WriteLine("subTables.Length: {0}", size.subTables.Length); //for (int i = 0; i < size.subTables.Length; i++) { // Console.WriteLine("subTables {0}: {1}", i, size.subTables[i]); //} //Console.WriteLine("flags: {0}", size.flags); //GlyphBitmapData data = EBDT.bitmapData[0x53F8]; GlyphBitmapData data = EBDT.GetGlyphBitmapData(size.index, context.GlyphId); if (data == null) { data = EBDT.GetGlyphBitmapData(size.index, 0); } if (data == null) { context.X += context.FontSize; return; } //GlyphBitmapData data = EBDT.bitmapData[0x835]; switch (data.format) { case 1: GlyphBitmapData1 data1 = data as GlyphBitmapData1; //Console.WriteLine("data7: {0}", data7); DrawImageData( context, size.bitDepth, data1.smallMetrics, data1.imageData ); break; case 2: GlyphBitmapData2 data2 = data as GlyphBitmapData2; //Console.WriteLine("data7: {0}", data7); DrawImageData( context, size.bitDepth, data2.smallMetrics, data2.imageData ); break; case 5: DrawBitmapData5(context, size, data as GlyphBitmapData5); break; case 6: GlyphBitmapData6 data6 = data as GlyphBitmapData6; //Console.WriteLine("data7: {0}", data); DrawImageData( context, size.bitDepth, data6.bigMetrics, data6.imageData ); break; case 7: GlyphBitmapData7 data7 = data as GlyphBitmapData7; //Console.WriteLine("data7: {0}", data7); DrawImageData( context, size.bitDepth, data7.bigMetrics, data7.imageData ); break; case 8: break; case 9: break; } //context.X += context.FontSize; }