public static iText.IO.Font.Cmap.CMapToUnicode GetIdentity() {
     iText.IO.Font.Cmap.CMapToUnicode uni = new iText.IO.Font.Cmap.CMapToUnicode();
     for (int i = 0; i < 65537; i++) {
         uni.AddChar(i, TextUtil.ConvertFromUtf32(i));
     }
     return uni;
 }
Exemple #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(TextUtil.ConvertFromUtf32((int)newGlyph.GetUnicode()));
                }
                else
                {
                    if (oldGlyph.HasValidUnicode())
                    {
                        newGlyph.SetChars(TextUtil.ConvertFromUtf32((int)oldGlyph.GetUnicode()));
                    }
                }
            }
            glyphs[idx] = newGlyph;
        }
Exemple #3
0
        public virtual String ToUnicodeString(int start, int end)
        {
            ActualTextIterator iter = new ActualTextIterator(this, start, end);
            StringBuilder      str  = new StringBuilder();

            while (iter.HasNext())
            {
                GlyphLine.GlyphLinePart part = iter.Next();
                if (part.actualText != null)
                {
                    str.Append(part.actualText);
                }
                else
                {
                    for (int i = part.start; i < part.end; i++)
                    {
                        if (glyphs[i].GetChars() != null)
                        {
                            str.Append(glyphs[i].GetChars());
                        }
                        else
                        {
                            if (glyphs[i].HasValidUnicode())
                            {
                                str.Append(TextUtil.ConvertFromUtf32((int)glyphs[i].GetUnicode()));
                            }
                        }
                    }
                }
            }
            return(str.ToString());
        }
Exemple #4
0
        public virtual CMapToUnicode ExportToUnicode()
        {
            CMapToUnicode uni = new CMapToUnicode();

            int[] keys = map.ToOrderedKeys();
            foreach (int key in keys)
            {
                uni.AddChar(map.Get(key), TextUtil.ConvertFromUtf32(key));
            }
            int spaceCid = Lookup(32);

            if (spaceCid != 0)
            {
                uni.AddChar(spaceCid, TextUtil.ConvertFromUtf32(32));
            }
            return(uni);
        }
Exemple #5
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(TextUtil.ConvertFromUtf32((int)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(TextUtil.ConvertFromUtf32((int)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;
        }
Exemple #6
0
        private bool GlyphLinePartNeedsActualText(GlyphLine.GlyphLinePart glyphLinePart)
        {
            if (glyphLinePart.actualText == null)
            {
                return(false);
            }
            bool          needsActualText    = false;
            StringBuilder toUnicodeMapResult = new StringBuilder();

            for (int i = glyphLinePart.start; i < glyphLinePart.end; i++)
            {
                Glyph currentGlyph = glyphLine.glyphs[i];
                if (!currentGlyph.HasValidUnicode())
                {
                    needsActualText = true;
                    break;
                }
                toUnicodeMapResult.Append(TextUtil.ConvertFromUtf32(currentGlyph.GetUnicode()));
            }
            return(needsActualText || !toUnicodeMapResult.ToString().Equals(glyphLinePart.actualText
                                                                            ));
        }
Exemple #7
0
 private static char[] GetChars(int unicode)
 {
     return(unicode > -1 ? TextUtil.ConvertFromUtf32(unicode) : null);
 }