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 IndexSubTableArray FindSubTableArray(int glyphId) { for (int i = 0; i < numberofIndexSubTables; i++) { IndexSubTableArray subTable = subTables[i]; if (subTable.firstGlyphIndex <= glyphId && subTable.lastGlyphIndex >= glyphId) { return(subTable); } } return(null); }
public void ReadSubTableArray(BinaryReaderFont reader, long start) { uint offset = indexSubTableArrayOffset; reader.Position = start + offset; subTables = new IndexSubTableArray[numberofIndexSubTables]; for (int i = 0; i < numberofIndexSubTables; i++) { subTables[i] = IndexSubTableArray.Read(reader, start + offset); } /* * subTableArray = IndexSubTableArray.Read( * reader, start + offset, (int)numberofIndexSubTables * ); */ }
public static IndexSubTableArray Read(BinaryReaderFont reader, long start) { IndexSubTableArray value = new IndexSubTableArray { firstGlyphIndex = reader.ReadUInt16(), lastGlyphIndex = reader.ReadUInt16(), additionalOffsetToIndexSubtable = reader.ReadUInt32() }; long position = reader.Position; uint offset = value.additionalOffsetToIndexSubtable; reader.Position = start + offset; value.subTable = IndexSubTable.Read( reader, value.firstGlyphIndex, value.lastGlyphIndex ); reader.Position = position; //value.subTables = new IndexSubTable[count]; //uint offset = value.additionalOffsetToIndexSubtable; //for (int i = 0; i < count; i++) { //reader.Position = start + offset * (i + 1); //value.subTables[i] = IndexSubTable.Read(reader); //} return(value); }