Esempio n. 1
0
 public static VTable Read(BinaryReaderFont reader)
 {
     return(new VTable {
         yPelHeight = reader.ReadUInt16(),
         yMax = reader.ReadInt16(),
         yMin = reader.ReadInt16()
     });
 }
Esempio n. 2
0
 public static AnchorFormat1 Read(BinaryReaderFont reader)
 {
     return(new AnchorFormat1 {
         anchorFormat = reader.ReadUInt16(),
         xCoordinate = reader.ReadInt16(),
         yCoordinate = reader.ReadInt16()
     });
 }
Esempio n. 3
0
 public static GlyphData Read(BinaryReaderFont reader, uint dataLength)
 {
     return(new GlyphData {
         originOffsetX = reader.ReadInt16(),
         originOffsetY = reader.ReadInt16(),
         graphicType = reader.ReadTag(),
         data = reader.ReadBytes((int)dataLength)
     });
 }
Esempio n. 4
0
 public static AnchorFormat3 Read(BinaryReaderFont reader)
 {
     return(new AnchorFormat3 {
         anchorFormat = reader.ReadUInt16(),
         xCoordinate = reader.ReadInt16(),
         yCoordinate = reader.ReadInt16(),
         xDeviceOffset = reader.ReadUInt16(),
         yDeviceOffset = reader.ReadUInt16()
     });
 }
Esempio n. 5
0
 public static ValueRecord Read(BinaryReaderFont reader)
 {
     return(new ValueRecord {
         xPlacement = reader.ReadInt16(),
         yPlacement = reader.ReadInt16(),
         xAdvance = reader.ReadInt16(),
         yAdvance = reader.ReadInt16(),
         xPlaDeviceOffset = reader.ReadUInt16(),
         yPlaDeviceOffset = reader.ReadUInt16(),
         xAdvDeviceOffset = reader.ReadUInt16(),
         yAdvDeviceOffset = reader.ReadUInt16()
     });
 }
Esempio n. 6
0
        /*
         * public static LongHorMetric[] ReadArray(BinaryReaderFont reader, int count) {
         *      LongHorMetric[] array = new LongHorMetric[count];
         *      for (int i = 0; i < count; i++) {
         *              array[i] = Read(reader);
         *      }
         *      return array;
         * }
         */

        public static LongHorMetric Read(BinaryReaderFont reader)
        {
            return(new LongHorMetric {
                advanceWidth = reader.ReadUInt16(),
                lsb = reader.ReadInt16()
            });
        }
Esempio n. 7
0
        protected void ReadYCoordinates(BinaryReaderFont reader, int count)
        {
            SimpleGlyphFlags bit2 = SimpleGlyphFlags.Y_SHORT_VECTOR;
            SimpleGlyphFlags bit5 = SimpleGlyphFlags.Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR;

            yCoordinates = new short[count];
            int prevY = 0;

            for (int i = 0; i < count; i++)
            {
                SimpleGlyphFlags flag = flags[i];
                int y = 0;
                if ((flag & bit2) > 0)
                {
                    y = reader.ReadByte();
                    if ((flag & bit5) == 0)
                    {
                        y = -y;
                    }
                }
                else
                {
                    if ((flag & bit5) == 0)
                    {
                        y = reader.ReadInt16();
                    }
                }
                yCoordinates[i] = (short)(y + prevY);
                prevY           = yCoordinates[i];
            }
        }
Esempio n. 8
0
 public static BaseCoordFormat1 Read(BinaryReaderFont reader)
 {
     return(new BaseCoordFormat1 {
         baseCoordFormat = reader.ReadUInt16(),
         coordinate = reader.ReadInt16()
     });
 }
Esempio n. 9
0
        protected void ReadXCoordinates(BinaryReaderFont reader, int count)
        {
            SimpleGlyphFlags bit1 = SimpleGlyphFlags.X_SHORT_VECTOR;
            SimpleGlyphFlags bit4 = SimpleGlyphFlags.X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR;

            xCoordinates = new short[count];
            int prevX = 0;

            for (int i = 0; i < count; i++)
            {
                SimpleGlyphFlags flag = flags[i];
                int x = 0;
                if ((flag & bit1) > 0)
                {
                    x = reader.ReadByte();
                    if ((flag & bit4) == 0)
                    {
                        x = -x;
                    }
                }
                else
                {
                    if ((flag & bit4) == 0)
                    {
                        x = reader.ReadInt16();
                    }
                }
                xCoordinates[i] = (short)(x + prevX);
                prevX           = xCoordinates[i];
            }
        }
Esempio n. 10
0
        public LongHorMetric GetMetric(int glyphId)
        {
            if (glyphId < 0 || glyphId >= numGlyphs)
            {
                return(null);
            }
            if (File.Exists(filePath) == false)
            {
                return(null);
            }
            if (glyphId < numberOfHMetrics)
            {
                using (Stream stream = File.OpenRead(filePath))
                    using (BinaryReaderFont reader = new BinaryReaderFont(stream)) {
                        reader.Position = position + glyphId * LongHorMetric.ByteSize;
                        return(LongHorMetric.Read(reader));
                    }
            }
            using (Stream stream = File.OpenRead(filePath))
                using (BinaryReaderFont reader = new BinaryReaderFont(stream)) {
                    reader.Position = position
                                      + numberOfHMetrics * LongHorMetric.ByteSize
                                      + (glyphId - numberOfHMetrics) * 2;
                    LongHorMetric hMetric = new LongHorMetric();
                    hMetric.lsb = reader.ReadInt16();
                    return(hMetric);
                }

            /*
             * if (glyphId >= hMetrics.Count) {
             *      return null;
             * }
             * return hMetrics[glyphId];
             */
        }
Esempio n. 11
0
 public static HdmxTable Read(BinaryReaderFont reader)
 {
     return(new HdmxTable {
         version = reader.ReadUInt16(),
         numRecords = reader.ReadInt16(),
         sizeDeviceRecord = reader.ReadInt32()
     });
 }
Esempio n. 12
0
 public static SubHeader Read(BinaryReaderFont reader)
 {
     return(new SubHeader {
         firstCode = reader.ReadUInt16(),
         entryCount = reader.ReadUInt16(),
         idDelta = reader.ReadInt16(),
         idRangeOffset = reader.ReadUInt16()
     });
 }
Esempio n. 13
0
 public static BaseCoordFormat2 Read(BinaryReaderFont reader)
 {
     return(new BaseCoordFormat2 {
         baseCoordFormat = reader.ReadUInt16(),
         coordinate = reader.ReadInt16(),
         referenceGlyph = reader.ReadUInt16(),
         baseCoordPoint = reader.ReadUInt16()
     });
 }
Esempio n. 14
0
 public static VORGTable Read(BinaryReaderFont reader)
 {
     return(new VORGTable {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         defaultVertOriginY = reader.ReadInt16(),
         numVertOriginYMetrics = reader.ReadUInt16()
     });
 }
Esempio n. 15
0
        public static Glyph Read(BinaryReaderFont reader)
        {
            Glyph value = new Glyph {
                numberOfContours = reader.ReadInt16(),
                xMin             = reader.ReadInt16(),
                yMin             = reader.ReadInt16(),
                xMax             = reader.ReadInt16(),
                yMax             = reader.ReadInt16()
            };

            if (value.numberOfContours >= 0)
            {
                value.simpleGlyph = SimpleGlyph.Read(reader, value);
            }
            else
            {
                value.compositeGlyph = CompositeGlyph.Read(reader, value);
            }
            return(value);
        }
Esempio n. 16
0
 public static HeadTable Read(BinaryReaderFont reader)
 {
     return(new HeadTable {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         fontRevision = reader.ReadFixed(),
         checkSumAdjustment = reader.ReadUInt32(),
         magicNumber = reader.ReadUInt32(),
         flags = (FontHeaderFlags)reader.ReadUInt16(),
         unitsPerEm = reader.ReadUInt16(),
         created = reader.ReadDateTime(),
         modified = reader.ReadDateTime(),
         xMin = reader.ReadInt16(),
         yMin = reader.ReadInt16(),
         xMax = reader.ReadInt16(),
         yMax = reader.ReadInt16(),
         macStyle = (FontHeaderMacStyle)reader.ReadUInt16(),
         lowestRecPPEM = reader.ReadUInt16(),
         fontDirectionHint = reader.ReadInt16(),
         indexToLocFormat = reader.ReadInt16(),
         glyphDataFormat = reader.ReadInt16()
     });
 }
Esempio n. 17
0
 public static new VerticalHeader1_1 Read(BinaryReaderFont reader)
 {
     return(new VerticalHeader1_1 {
         vertTypoAscender = reader.ReadInt16(),
         vertTypoDescender = reader.ReadInt16(),
         vertTypoLineGap = reader.ReadInt16(),
         advanceHeightMax = reader.ReadInt16(),
         minTopSideBearing = reader.ReadInt16(),
         minBottomSideBearing = reader.ReadInt16(),
         yMaxExtent = reader.ReadInt16(),
         caretSlopeRise = reader.ReadInt16(),
         caretSlopeRun = reader.ReadInt16(),
         caretOffset = reader.ReadInt16(),
         reserved0 = reader.ReadInt16(),
         reserved1 = reader.ReadInt16(),
         reserved2 = reader.ReadInt16(),
         reserved3 = reader.ReadInt16(),
         metricDataFormat = reader.ReadInt16(),
         numOfLongVerMetrics = reader.ReadUInt16()
     });
 }
Esempio n. 18
0
 public static HheaTable Read(BinaryReaderFont reader)
 {
     return(new HheaTable {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         ascender = reader.ReadInt16(),
         descender = reader.ReadInt16(),
         lineGap = reader.ReadInt16(),
         advanceWidthMax = reader.ReadUInt16(),
         minLeftSideBearing = reader.ReadInt16(),
         minRightSideBearing = reader.ReadInt16(),
         xMaxExtent = reader.ReadInt16(),
         caretSlopeRise = reader.ReadInt16(),
         caretSlopeRun = reader.ReadInt16(),
         caretOffset = reader.ReadInt16(),
         reserved0 = reader.ReadInt16(),
         reserved1 = reader.ReadInt16(),
         reserved2 = reader.ReadInt16(),
         reserved3 = reader.ReadInt16(),
         metricDataFormat = reader.ReadInt16(),
         numberOfHMetrics = reader.ReadUInt16()
     });
 }
Esempio n. 19
0
        public static OS2Table Read(BinaryReaderFont reader)
        {
            OS2Table value = new OS2Table {
                version             = reader.ReadUInt16(),
                xAvgCharWidth       = reader.ReadInt16(),
                usWeightClass       = reader.ReadUInt16(),
                usWidthClass        = reader.ReadUInt16(),
                fsType              = reader.ReadUInt16(),
                ySubscriptXSize     = reader.ReadInt16(),
                ySubscriptYSize     = reader.ReadInt16(),
                ySubscriptXOffset   = reader.ReadInt16(),
                ySubscriptYOffset   = reader.ReadInt16(),
                ySuperscriptXSize   = reader.ReadInt16(),
                ySuperscriptYSize   = reader.ReadInt16(),
                ySuperscriptXOffset = reader.ReadInt16(),
                ySuperscriptYOffset = reader.ReadInt16(),
                yStrikeoutSize      = reader.ReadInt16(),
                yStrikeoutPosition  = reader.ReadInt16(),
                sFamilyClass        = reader.ReadInt16(),
                panose              = reader.ReadBytes(10),
                ulUnicodeRange1     = reader.ReadUInt32(),
                ulUnicodeRange2     = reader.ReadUInt32(),
                ulUnicodeRange3     = reader.ReadUInt32(),
                ulUnicodeRange4     = reader.ReadUInt32(),
                achVendID           = reader.ReadTag(),
                fsSelection         = reader.ReadUInt16(),
                usFirstCharIndex    = reader.ReadUInt16(),
                usLastCharIndex     = reader.ReadUInt16(),
                sTypoAscender       = reader.ReadInt16(),
                sTypoDescender      = reader.ReadInt16(),
                sTypoLineGap        = reader.ReadInt16(),
                usWinAscent         = reader.ReadUInt16(),
                usWinDescent        = reader.ReadUInt16()
            };

            if (value.version >= 1)
            {
                value.ulCodePageRange1 = reader.ReadUInt32();
                value.ulCodePageRange2 = reader.ReadUInt32();
            }
            if (value.version >= 4)
            {
                value.sxHeight      = reader.ReadInt16();
                value.sCapHeight    = reader.ReadInt16();
                value.usDefaultChar = reader.ReadUInt16();
                value.usBreakChar   = reader.ReadUInt16();
                value.usMaxContext  = reader.ReadUInt16();
            }
            if (value.version >= 5)
            {
                value.usLowerOpticalPointSize = reader.ReadUInt16();
                value.usUpperOpticalPointSize = reader.ReadUInt16();
            }
            return(value);
        }