Example #1
0
        private BfEntryList GroupCMapEntries()
        {
            // List of grouped bfranges
            BfEntryList groups = new BfEntryList();

            ushort  prevGlyphIndex   = (ushort)ranges.GetKey(0);
            ushort  prevUnicodeValue = (ushort)ranges[prevGlyphIndex];
            BfEntry range            = new BfEntry(prevGlyphIndex, prevUnicodeValue);

            groups.Add(range);

            for (int i = 1; i < ranges.Count; i++)
            {
                ushort glyphIndex   = (ushort)ranges.GetKey(i);
                ushort unicodeValue = (ushort)ranges[glyphIndex];

                if (unicodeValue == prevUnicodeValue + 1 &&
                    glyphIndex == prevGlyphIndex + 1)
                {
                    // Contingous block - use existing range
                    range.IncrementEndIndex();
                }
                else
                {
                    // Non-contiguous block - start new range
                    range = new BfEntry(glyphIndex, unicodeValue);
                    groups.Add(range);
                }

                prevGlyphIndex   = glyphIndex;
                prevUnicodeValue = unicodeValue;
            }

            return(groups);
        }
Example #2
0
        /// <summary>
        ///     Writes the bfrange entries to the content stream in groups of 100.
        /// </summary>
        /// <param name="entries"></param>
        private void WriteBfRanges(BfEntryList entries)
        {
            // bfrange entries must be grouped in blocks of 100
            BfEntry[] rangeEntries = entries.Ranges;
            int       numBlocks    = (rangeEntries.Length / 100) + (((rangeEntries.Length % 100) > 0) ? 1 : 0);

            for (int i = 0; i < numBlocks; i++)
            {
                int blockSize = 0;
                if ((i + 1) == numBlocks)
                {
                    blockSize = rangeEntries.Length - (i * 100);
                }
                else
                {
                    blockSize = 100;
                }

                WriteLine(String.Format("{0} beginbfrange", blockSize));

                for (int j = 0; j < blockSize; j++)
                {
                    BfEntry entry = rangeEntries[(i * 100) + j];
                    WriteLine(String.Format("<{0:X4}> <{1:X4}> <{2:X4}>",
                                            entry.StartGlyphIndex,
                                            entry.EndGlyphIndex,
                                            entry.UnicodeValue));
                }
                WriteLine("endbfrange");
            }
        }
Example #3
0
        private void WriteCodespaceRange(BfEntryList entries)
        {
            BfEntry first = entries[0];
            BfEntry last  = entries[entries.Count - 1];

            WriteLine("1 begincodespacerange");
            WriteLine(String.Format("<{0:X4}> <{1:X4}>",
                                    first.StartGlyphIndex, last.EndGlyphIndex));
            WriteLine("endcodespacerange");
        }
Example #4
0
 /// <summary>
 ///     Adds the supplied <see cref="BfEntry"/> to the end of the collection.
 /// </summary>
 /// <param name="entry"></param>
 public void Add(BfEntry entry)
 {
     entries.Add(entry);
 }
Example #5
0
 /// <summary>
 ///     Adds the supplied <see cref="BfEntry"/> to the end of the collection.
 /// </summary>
 /// <param name="entry"></param>
 public void Add(BfEntry entry)
 {
     entries.Add(entry);
 }
Example #6
0
        private BfEntryList GroupCMapEntries()
        {
            // List of grouped bfranges
            BfEntryList groups = new BfEntryList();

            ushort prevGlyphIndex = (ushort)ranges.GetKey(0);
            ushort prevUnicodeValue = (ushort)ranges[prevGlyphIndex];
            BfEntry range = new BfEntry(prevGlyphIndex, prevUnicodeValue);
            groups.Add(range);

            for (int i = 1; i < ranges.Count; i++)
            {
                ushort glyphIndex = (ushort)ranges.GetKey(i);
                ushort unicodeValue = (ushort)ranges[glyphIndex];

                if (unicodeValue == prevUnicodeValue + 1 &&
                    glyphIndex == prevGlyphIndex + 1)
                {
                    // Contingous block - use existing range
                    range.IncrementEndIndex();
                }
                else
                {
                    // Non-contiguous block - start new range
                    range = new BfEntry(glyphIndex, unicodeValue);
                    groups.Add(range);
                }

                prevGlyphIndex = glyphIndex;
                prevUnicodeValue = unicodeValue;
            }

            return groups;
        }