Exemplo n.º 1
0
        public static IList <IList <GposAnchor[]> > ReadLigatureArray(OpenTypeFontTableReader tableReader, int classCount
                                                                      , int location)
        {
            IList <IList <GposAnchor[]> > ligatureArray = new List <IList <GposAnchor[]> >();

            tableReader.rf.Seek(location);
            int ligatureCount = tableReader.rf.ReadUnsignedShort();

            int[] ligatureAttachLocations = ReadUShortArray(tableReader.rf, ligatureCount, location);
            for (int liga = 0; liga < ligatureCount; ++liga)
            {
                int ligatureAttachLocation          = ligatureAttachLocations[liga];
                IList <GposAnchor[]> ligatureAttach = new List <GposAnchor[]>();
                tableReader.rf.Seek(ligatureAttachLocation);
                int   componentCount           = tableReader.rf.ReadUnsignedShort();
                int[] componentRecordsLocation = ReadUShortArray(tableReader.rf, classCount * componentCount, ligatureAttachLocation
                                                                 );
                int idx = 0;
                for (int k = 0; k < componentCount; ++k)
                {
                    ligatureAttach.Add(ReadAnchorArray(tableReader, componentRecordsLocation, idx, idx + classCount));
                    idx += classCount;
                }
                ligatureArray.Add(ligatureAttach);
            }
            return(ligatureArray);
        }
Exemplo n.º 2
0
        public virtual void SubstituteOneToOne(OpenTypeFontTableReader tableReader, int substitutionGlyphIndex)
        {
            Glyph oldGlyph = glyphs[idx];
            Glyph newGlyph = tableReader.GetGlyph(substitutionGlyphIndex);

            if (oldGlyph.GetChars() != null)
            {
                newGlyph.SetChars(oldGlyph.GetChars());
            }
            else
            {
                if (newGlyph.HasValidUnicode())
                {
                    newGlyph.SetChars(iText.IO.Util.TextUtil.ConvertFromUtf32(newGlyph.GetUnicode()));
                }
                else
                {
                    if (oldGlyph.HasValidUnicode())
                    {
                        newGlyph.SetChars(iText.IO.Util.TextUtil.ConvertFromUtf32(oldGlyph.GetUnicode()));
                    }
                }
            }
            glyphs[idx] = newGlyph;
        }
Exemplo n.º 3
0
 /// <exception cref="System.IO.IOException"/>
 protected internal GsubLookupType5(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations
                                    )
     : base(openReader, lookupFlag, subTableLocations)
 {
     subTables = new List <ContextualSubTable>();
     ReadSubTables();
 }
Exemplo n.º 4
0
        public virtual void SubstituteOneToMany(OpenTypeFontTableReader tableReader, int[] substGlyphIds)
        {
            //sequence length shall be at least 1
            int   substCode = substGlyphIds[0];
            Glyph oldGlyph  = glyphs[idx];
            Glyph glyph     = tableReader.GetGlyph(substCode);

            glyphs[idx] = glyph;
            if (substGlyphIds.Length > 1)
            {
                IList <Glyph> additionalGlyphs = new List <Glyph>(substGlyphIds.Length - 1);
                for (int i = 1; i < substGlyphIds.Length; ++i)
                {
                    substCode = substGlyphIds[i];
                    glyph     = tableReader.GetGlyph(substCode);
                    additionalGlyphs.Add(glyph);
                }
                AddAllGlyphs(idx + 1, additionalGlyphs);
                if (null != actualText)
                {
                    if (null == actualText[idx])
                    {
                        actualText[idx] = new GlyphLine.ActualText(oldGlyph.GetUnicodeString());
                    }
                    for (int i = 0; i < additionalGlyphs.Count; i++)
                    {
                        this.actualText[idx + 1 + i] = actualText[idx];
                    }
                }
                idx += substGlyphIds.Length - 1;
                end += substGlyphIds.Length - 1;
            }
        }
Exemplo n.º 5
0
 public static GposAnchor[] ReadAnchorArray(OpenTypeFontTableReader tableReader, int[] locations, int left,
                                            int right)
 {
     GposAnchor[] anchors = new GposAnchor[right - left];
     for (int i = left; i < right; i++)
     {
         anchors[i - left] = ReadGposAnchor(tableReader, locations[i]);
     }
     return(anchors);
 }
Exemplo n.º 6
0
 public OpenTypeScript(OpenTypeFontTableReader openTypeReader, int locationScriptTable)
 {
     this.openTypeReader = openTypeReader;
     records             = new List <ScriptRecord>();
     openTypeReader.rf.Seek(locationScriptTable);
     TagAndLocation[] tagsLocs = openTypeReader.ReadTagAndLocations(locationScriptTable);
     foreach (TagAndLocation tagLoc in tagsLocs)
     {
         ReadScriptRecord(tagLoc);
     }
 }
Exemplo n.º 7
0
 public OpenTypeFeature(OpenTypeFontTableReader openTypeReader, int locationFeatureTable)
 {
     this.openTypeReader = openTypeReader;
     records             = new List <FeatureRecord>();
     openTypeReader.rf.Seek(locationFeatureTable);
     TagAndLocation[] tagsLocs = openTypeReader.ReadTagAndLocations(locationFeatureTable);
     foreach (TagAndLocation tagLoc in tagsLocs)
     {
         // +2 don't use FeatureParams
         openTypeReader.rf.Seek(tagLoc.location + 2L);
         int           lookupCount = openTypeReader.rf.ReadUnsignedShort();
         FeatureRecord rec         = new FeatureRecord();
         rec.tag     = tagLoc.tag;
         rec.lookups = openTypeReader.ReadUShortArray(lookupCount);
         records.Add(rec);
     }
 }
Exemplo n.º 8
0
        public virtual void SubstituteManyToOne(OpenTypeFontTableReader tableReader, int lookupFlag, int rightPartLen
                                                , int substitutionGlyphIndex)
        {
            OpenTableLookup.GlyphIndexer gidx = new OpenTableLookup.GlyphIndexer();
            gidx.line = this;
            gidx.idx  = idx;
            StringBuilder chars        = new StringBuilder();
            Glyph         currentGlyph = glyphs[idx];

            if (currentGlyph.GetChars() != null)
            {
                chars.Append(currentGlyph.GetChars());
            }
            else
            {
                if (currentGlyph.HasValidUnicode())
                {
                    chars.Append(iText.IO.Util.TextUtil.ConvertFromUtf32(currentGlyph.GetUnicode()));
                }
            }
            for (int j = 0; j < rightPartLen; ++j)
            {
                gidx.NextGlyph(tableReader, lookupFlag);
                currentGlyph = glyphs[gidx.idx];
                if (currentGlyph.GetChars() != null)
                {
                    chars.Append(currentGlyph.GetChars());
                }
                else
                {
                    if (currentGlyph.HasValidUnicode())
                    {
                        chars.Append(iText.IO.Util.TextUtil.ConvertFromUtf32(currentGlyph.GetUnicode()));
                    }
                }
                RemoveGlyph(gidx.idx--);
            }
            char[] newChars = new char[chars.Length];
            chars.GetChars(0, chars.Length, newChars, 0);
            Glyph newGlyph = tableReader.GetGlyph(substitutionGlyphIndex);

            newGlyph.SetChars(newChars);
            glyphs[idx] = newGlyph;
            end        -= rightPartLen;
        }
Exemplo n.º 9
0
        public static IList <GposAnchor[]> ReadBaseArray(OpenTypeFontTableReader tableReader, int classCount, int location
                                                         )
        {
            IList <GposAnchor[]> baseArray = new List <GposAnchor[]>();

            tableReader.rf.Seek(location);
            int baseCount = tableReader.rf.ReadUnsignedShort();

            int[] anchorLocations = ReadUShortArray(tableReader.rf, baseCount * classCount, location);
            int   idx             = 0;

            for (int k = 0; k < baseCount; ++k)
            {
                baseArray.Add(ReadAnchorArray(tableReader, anchorLocations, idx, idx + classCount));
                idx += classCount;
            }
            return(baseArray);
        }
Exemplo n.º 10
0
        public virtual void SubstituteOneToMany(OpenTypeFontTableReader tableReader, int[] substGlyphIds)
        {
            int substCode = substGlyphIds[0];
            //sequence length shall be at least 1
            Glyph glyph = tableReader.GetGlyph(substCode);

            glyphs[idx] = glyph;
            if (substGlyphIds.Length > 1)
            {
                IList <Glyph> additionalGlyphs = new List <Glyph>(substGlyphIds.Length - 1);
                for (int i = 1; i < substGlyphIds.Length; ++i)
                {
                    substCode = substGlyphIds[i];
                    glyph     = tableReader.GetGlyph(substCode);
                    additionalGlyphs.Add(glyph);
                }
                AddAllGlyphs(idx + 1, additionalGlyphs);
                idx += substGlyphIds.Length - 1;
                end += substGlyphIds.Length - 1;
            }
        }
Exemplo n.º 11
0
        public static GposAnchor ReadGposAnchor(OpenTypeFontTableReader tableReader, int location)
        {
            if (location == 0)
            {
                return(null);
            }
            tableReader.rf.Seek(location);
            int        format = tableReader.rf.ReadUnsignedShort();
            GposAnchor t      = null;

            switch (format)
            {
            default: {
                t             = new GposAnchor();
                t.XCoordinate = tableReader.rf.ReadShort() * 1000 / tableReader.GetUnitsPerEm();
                t.YCoordinate = tableReader.rf.ReadShort() * 1000 / tableReader.GetUnitsPerEm();
                break;
            }
            }
            return(t);
        }
Exemplo n.º 12
0
        public static GposValueRecord ReadGposValueRecord(OpenTypeFontTableReader tableReader, int mask)
        {
            GposValueRecord vr = new GposValueRecord();

            if ((mask & 0x0001) != 0)
            {
                vr.XPlacement = tableReader.rf.ReadShort() * 1000 / tableReader.GetUnitsPerEm();
            }
            if ((mask & 0x0002) != 0)
            {
                vr.YPlacement = tableReader.rf.ReadShort() * 1000 / tableReader.GetUnitsPerEm();
            }
            if ((mask & 0x0004) != 0)
            {
                vr.XAdvance = tableReader.rf.ReadShort() * 1000 / tableReader.GetUnitsPerEm();
            }
            if ((mask & 0x0008) != 0)
            {
                vr.YAdvance = tableReader.rf.ReadShort() * 1000 / tableReader.GetUnitsPerEm();
            }
            if ((mask & 0x0010) != 0)
            {
                tableReader.rf.Skip(2);
            }
            if ((mask & 0x0020) != 0)
            {
                tableReader.rf.Skip(2);
            }
            if ((mask & 0x0040) != 0)
            {
                tableReader.rf.Skip(2);
            }
            if ((mask & 0x0080) != 0)
            {
                tableReader.rf.Skip(2);
            }
            return(vr);
        }
Exemplo n.º 13
0
        public static IList <OtfMarkRecord> ReadMarkArray(OpenTypeFontTableReader tableReader, int location)
        {
            tableReader.rf.Seek(location);
            int markCount = tableReader.rf.ReadUnsignedShort();

            int[] classes   = new int[markCount];
            int[] locations = new int[markCount];
            for (int k = 0; k < markCount; ++k)
            {
                classes[k] = tableReader.rf.ReadUnsignedShort();
                int offset = tableReader.rf.ReadUnsignedShort();
                locations[k] = location + offset;
            }
            IList <OtfMarkRecord> marks = new List <OtfMarkRecord>();

            for (int k = 0; k < markCount; ++k)
            {
                OtfMarkRecord rec = new OtfMarkRecord();
                rec.markClass = classes[k];
                rec.anchor    = ReadGposAnchor(tableReader, locations[k]);
                marks.Add(rec);
            }
            return(marks);
        }
Exemplo n.º 14
0
 /// <exception cref="System.IO.IOException"/>
 public GposLookupType2(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations)
     : base(openReader, lookupFlag, subTableLocations)
 {
     ReadSubTables();
 }
Exemplo n.º 15
0
 public GposLookupType7(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations)
     : base(openReader, lookupFlag, subTableLocations)
 {
     subTables = new List <ContextualPositionTable>();
     ReadSubTables();
 }
Exemplo n.º 16
0
 /// <exception cref="System.IO.IOException"/>
 public PairPosAdjustmentFormat2(OpenTypeFontTableReader openReader, int lookupFlag, int subtableLocation)
     : base(openReader, lookupFlag, null)
 {
     ReadFormat(subtableLocation);
 }
Exemplo n.º 17
0
 /// <exception cref="System.IO.IOException"/>
 public GsubLookupType3(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations)
     : base(openReader, lookupFlag, subTableLocations)
 {
     substMap = new Dictionary <int, int[]>();
     ReadSubTables();
 }
Exemplo n.º 18
0
 /// <exception cref="System.IO.IOException"/>
 public GposLookupType5(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations)
     : base(openReader, lookupFlag, subTableLocations)
 {
     marksligatures = new List <GposLookupType5.MarkToLigature>();
     ReadSubTables();
 }
Exemplo n.º 19
0
 /// <exception cref="System.IO.IOException"/>
 public GposLookupType4(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations)
     : base(openReader, lookupFlag, subTableLocations)
 {
     marksbases = new List <GposLookupType4.MarkToBase>();
     ReadSubTables();
 }
Exemplo n.º 20
0
 public GsubLookupType4(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations)
     : base(openReader, lookupFlag, subTableLocations)
 {
     ligatures = new Dictionary <int, IList <int[]> >();
     ReadSubTables();
 }
Exemplo n.º 21
0
 public GsubLookupType1(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations)
     : base(openReader, lookupFlag, subTableLocations)
 {
     substMap = new IntHashtable();
     ReadSubTables();
 }
Exemplo n.º 22
0
 protected internal ContextualSubTable(OpenTypeFontTableReader openReader, int lookupFlag)
 {
     this.openReader = openReader;
     this.lookupFlag = lookupFlag;
 }
Exemplo n.º 23
0
 /// <exception cref="System.IO.IOException"/>
 protected internal GsubLookupType6(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations
                                    )
     : base(openReader, lookupFlag, subTableLocations)
 {
 }