コード例 #1
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;
        }
コード例 #2
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;
        }