Esempio n. 1
0
        public void CreateMapFromUserCodePointToGlyphIndices(List <UserCodePointToGlyphIndex> mapUserCodePointToGlyphIndex)
        {
            //(optional)
            //this method should be called after we finish the substitution process
            //--------------------------------------
            int codePointCount = _inputCodePointIndexList.Count;

            for (int i = 0; i < codePointCount; ++i)
            {
                //
                var codePointToGlyphIndexMap = new UserCodePointToGlyphIndex();
                //set index that point to original codePointIndex
                codePointToGlyphIndexMap.userCodePointIndex = _inputCodePointIndexList[i];
                //
                mapUserCodePointToGlyphIndex.Add(codePointToGlyphIndexMap);
            }
            //--------------------------------------
            //then fill the user-codepoint with glyph information information

            int glyphIndexCount = _glyphIndices.Count;

            for (int i = 0; i < glyphIndexCount; ++i)
            {
                GlyphIndexToUserCodePoint glyphIndexToUserCodePoint = _mapGlyphIndexToUserCodePoint[i];
                //
                UserCodePointToGlyphIndex charToGlyphIndexMap = mapUserCodePointToGlyphIndex[glyphIndexToUserCodePoint.o_codepoint_charOffset];
                charToGlyphIndexMap.AppendData((ushort)(i + 1), (glyphIndexToUserCodePoint.len));
                //replace with the changed value
                mapUserCodePointToGlyphIndex[glyphIndexToUserCodePoint.o_codepoint_charOffset] = charToGlyphIndexMap;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// remove:add_new >=1:1
        /// </summary>
        /// <param name="index"></param>
        /// <param name="removeLen"></param>
        /// <param name="newGlyphIndex"></param>
        public void Replace(int index, int removeLen, ushort newGlyphIndex)
        {
            //eg f-i ligation
            //original f glyph and i glyph are removed
            //and then replace with a single glyph
            _glyphIndices.RemoveRange(index, removeLen);
            _glyphIndices.Insert(index, newGlyphIndex);
            //------------------------------------------------

            GlyphIndexToUserCodePoint firstRemove = _mapGlyphIndexToUserCodePoint[index];

#if DEBUG
            _tmpGlypIndexBackup.Clear();
            int endAt = index + removeLen;
            for (int i = index; i < endAt; ++i)
            {
                _tmpGlypIndexBackup.Add(_mapGlyphIndexToUserCodePoint[i]);
            }
            _tmpGlypIndexBackup.Clear();
#endif
            //TODO: check if removeLen > ushort.Max
            GlyphIndexToUserCodePoint newMap = new GlyphIndexToUserCodePoint(firstRemove.o_codepoint_charOffset, (ushort)removeLen);
#if DEBUG
            newMap.dbug_glyphIndex = newGlyphIndex;
#endif

            //------------------------------------------------
            _mapGlyphIndexToUserCodePoint.RemoveRange(index, removeLen);
            _mapGlyphIndexToUserCodePoint.Insert(index, newMap);
        }
Esempio n. 3
0
 //
 public void GetGlyphIndexAndMap(int index, out ushort glyphIndex, out ushort input_codepointOffset, out ushort input_mapLen)
 {
     glyphIndex = _glyphIndices[index];
     GlyphIndexToUserCodePoint glyphIndexToUserCodePoint = _mapGlyphIndexToUserCodePoint[index];
     input_codepointOffset = glyphIndexToUserCodePoint.o_codepoint_charOffset;
     input_mapLen = glyphIndexToUserCodePoint.len;
 }
Esempio n. 4
0
        /// <summary>
        ///  add codepoint index and its glyph index
        /// </summary>
        /// <param name="codePointIndex">index to codepoint element in code point array</param>
        /// <param name="glyphIndex">map to glyphindex</param>
        public void AddGlyph(int codePointIndex, ushort glyphIndex)
        {
            //so we can monitor what substituion process

            _inputCodePointIndexList.Add(codePointIndex);
            _glyphIndices.Add(glyphIndex);

            var glyphIndexToCharMap = new GlyphIndexToUserCodePoint(_originalCodePointOffset, 1);
            #if DEBUG
            //glyphIndexToCharMap.dbug_glyphIndex = glyphIndex;
            #endif
            _mapGlyphIndexToUserCodePoint.Add(glyphIndexToCharMap);
            _originalCodePointOffset++;
        }
Esempio n. 5
0
 /// <summary>
 /// remove: add_new 1:>=1
 /// </summary>
 /// <param name="index"></param>
 /// <param name="newGlyphIndices"></param>
 public void Replace(int index, ushort[] newGlyphIndices)
 {
     _glyphIndices.RemoveAt(index);
     _glyphIndices.InsertRange(index, newGlyphIndices);
     GlyphIndexToUserCodePoint cur = _mapGlyphIndexToUserCodePoint[index];
     _mapGlyphIndexToUserCodePoint.RemoveAt(index);
     //insert
     int j = newGlyphIndices.Length;
     for (int i = 0; i < j; ++i)
     {
         var newglyph = new GlyphIndexToUserCodePoint(cur.o_codepoint_charOffset, 1);
     #if DEBUG
         //newglyph.dbug_glyphIndex = newGlyphIndices[i];
     #endif
         //may point to the same user char
         _mapGlyphIndexToUserCodePoint.Insert(index, newglyph);
     }
 }