示例#1
0
 public OS2Table(OS2Table versionLessthan5Table, ushort lowerOpticalPointSize, ushort upperOpticalPointSize)
     : this(versionLessthan5Table,
            versionLessthan5Table.codePageRange1,
            versionLessthan5Table.codePageRange2,
            versionLessthan5Table.heightX,
            versionLessthan5Table.capHeight,
            versionLessthan5Table.defaultChar,
            versionLessthan5Table.breakChar,
            versionLessthan5Table.maxContext)
 {
     this.lowerOpticalPointSize = lowerOpticalPointSize;
     this.upperOpticalPointSize = upperOpticalPointSize;
 }
示例#2
0
 public OS2Table(OS2Table version0Table, ushort codePageRange1, ushort codePageRange2, short heightX, short capHeight, ushort defaultChar, ushort breakChar, ushort maxContext)
     : this(version0Table.averageCharWidth,
            version0Table.weightClass,
            version0Table.widthClass,
            version0Table.styleType,
            version0Table.subscriptXSize,
            version0Table.subscriptYSize,
            version0Table.subscriptXOffset,
            version0Table.subscriptYOffset,
            version0Table.superscriptXSize,
            version0Table.superscriptYSize,
            version0Table.superscriptXOffset,
            version0Table.superscriptYOffset,
            version0Table.strikeoutSize,
            version0Table.strikeoutPosition,
            version0Table.familyClass,
            version0Table.panose,
            version0Table.unicodeRange1,
            version0Table.unicodeRange2,
            version0Table.unicodeRange3,
            version0Table.unicodeRange4,
            version0Table.tag,
            version0Table.FontStyle,
            version0Table.firstCharIndex,
            version0Table.lastCharIndex,
            version0Table.TypoAscender,
            version0Table.TypoDescender,
            version0Table.TypoLineGap,
            version0Table.winAscent,
            version0Table.winDescent)
 {
     this.codePageRange1 = codePageRange1;
     this.codePageRange2 = codePageRange2;
     this.heightX        = heightX;
     this.capHeight      = capHeight;
     this.defaultChar    = defaultChar;
     this.breakChar      = breakChar;
     this.maxContext     = maxContext;
 }
示例#3
0
        public static OS2Table Load(BinaryReader reader)
        {
            // Version 1.0
            // Type   | Name                   | Comments
            // -------|------------------------|-----------------------
            // uint16 |version                 | 0x0005
            // int16  |xAvgCharWidth           |
            // uint16 |usWeightClass           |
            // uint16 |usWidthClass            |
            // uint16 |fsType                  |
            // int16  |ySubscriptXSize         |
            // int16  |ySubscriptYSize         |
            // int16  |ySubscriptXOffset       |
            // int16  |ySubscriptYOffset       |
            // int16  |ySuperscriptXSize       |
            // int16  |ySuperscriptYSize       |
            // int16  |ySuperscriptXOffset     |
            // int16  |ySuperscriptYOffset     |
            // int16  |yStrikeoutSize          |
            // int16  |yStrikeoutPosition      |
            // int16  |sFamilyClass            |
            // uint8  |panose[10]              |
            // uint32 |ulUnicodeRange1         | Bits 0–31
            // uint32 |ulUnicodeRange2         | Bits 32–63
            // uint32 |ulUnicodeRange3         | Bits 64–95
            // uint32 |ulUnicodeRange4         | Bits 96–127
            // Tag    |achVendID               |
            // uint16 |fsSelection             |
            // uint16 |usFirstCharIndex        |
            // uint16 |usLastCharIndex         |
            // int16  |sTypoAscender           |
            // int16  |sTypoDescender          |
            // int16  |sTypoLineGap            |
            // uint16 |usWinAscent             |
            // uint16 |usWinDescent            |
            // uint32 |ulCodePageRange1        | Bits 0–31
            // uint32 |ulCodePageRange2        | Bits 32–63
            // int16  |sxHeight                |
            // int16  |sCapHeight              |
            // uint16 |usDefaultChar           |
            // uint16 |usBreakChar             |
            // uint16 |usMaxContext            |
            // uint16 |usLowerOpticalPointSize |
            // uint16 |usUpperOpticalPointSize |
            var version          = reader.ReadUInt16(); // assert 0x0005
            var averageCharWidth = reader.ReadInt16();
            var weightClass      = reader.ReadUInt16();
            var widthClass       = reader.ReadUInt16();
            var styleType        = reader.ReadUInt16();
            var subscriptXSize   = reader.ReadInt16();
            var subscriptYSize   = reader.ReadInt16();
            var subscriptXOffset = reader.ReadInt16();
            var subscriptYOffset = reader.ReadInt16();

            var superscriptXSize   = reader.ReadInt16();
            var superscriptYSize   = reader.ReadInt16();
            var superscriptXOffset = reader.ReadInt16();
            var superscriptYOffset = reader.ReadInt16();

            var strikeoutSize     = reader.ReadInt16();
            var strikeoutPosition = reader.ReadInt16();
            var familyClass       = reader.ReadInt16();
            var panose            = reader.ReadUInt8Array(10);
            var unicodeRange1     = reader.ReadUInt32(); // Bits 0–31
            var unicodeRange2     = reader.ReadUInt32(); // Bits 32–63
            var unicodeRange3     = reader.ReadUInt32(); // Bits 64–95
            var unicodeRange4     = reader.ReadUInt32(); // Bits 96–127
            var tag            = reader.ReadTag();
            var fontStyle      = reader.ReadUInt16 <FontStyleSelection>();
            var firstCharIndex = reader.ReadUInt16();
            var lastCharIndex  = reader.ReadUInt16();
            var typoAscender   = reader.ReadInt16();
            var typoDescender  = reader.ReadInt16();
            var typoLineGap    = reader.ReadInt16();
            var winAscent      = reader.ReadUInt16();
            var winDescent     = reader.ReadUInt16();

            var version0Table = new OS2Table(
                averageCharWidth,
                weightClass,
                widthClass,
                styleType,
                subscriptXSize,
                subscriptYSize,
                subscriptXOffset,
                subscriptYOffset,
                superscriptXSize,
                superscriptYSize,
                superscriptXOffset,
                superscriptYOffset,
                strikeoutSize,
                strikeoutPosition,
                familyClass,
                panose,
                unicodeRange1,
                unicodeRange2,
                unicodeRange3,
                unicodeRange4,
                tag,
                fontStyle,
                firstCharIndex,
                lastCharIndex,
                typoAscender,
                typoDescender,
                typoLineGap,
                winAscent,
                winDescent);

            if (version == 0)
            {
                return(version0Table);
            }

            ushort codePageRange1 = 0;
            ushort codePageRange2 = 0;
            short  heightX        = 0;
            short  capHeight      = 0;

            ushort defaultChar = 0;
            ushort breakChar   = 0;
            ushort maxContext  = 0;

            codePageRange1 = reader.ReadUInt16(); // Bits 0–31
            codePageRange2 = reader.ReadUInt16(); // Bits 32–63
            heightX        = reader.ReadInt16();
            capHeight      = reader.ReadInt16();

            defaultChar = reader.ReadUInt16();
            breakChar   = reader.ReadUInt16();
            maxContext  = reader.ReadUInt16();

            var versionLessthan5Table = new OS2Table(
                version0Table,
                codePageRange1,
                codePageRange2,
                heightX,
                capHeight,
                defaultChar,
                breakChar,
                maxContext);

            if (version < 5)
            {
                return(versionLessthan5Table);
            }

            ushort lowerOpticalPointSize = reader.ReadUInt16();
            ushort upperOpticalPointSize = reader.ReadUInt16();

            return(new OS2Table(
                       versionLessthan5Table,
                       lowerOpticalPointSize,
                       upperOpticalPointSize));
        }