示例#1
0
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
//ORIGINAL LINE: const AlphabetTable1* alphabetTable1() const
        public AlphabetTable1 alphabetTable1()
        {
//C++ TO C# CONVERTER TODO TASK: There is no equivalent to 'reinterpret_cast' in C#:
            return(reinterpret_cast <const AlphabetTable1>(bytes() + alphabet_offset));
        }
示例#2
0
        // Try looking up word in alphabet table, return DONT_BREAK if any code units
        // fail to map. Otherwise, returns BREAK_AND_INSERT_HYPHEN,
        // BREAK_AND_INSERT_ARMENIAN_HYPHEN, or BREAK_AND_DONT_INSERT_HYPHEN based on
        // the the script of the characters seen. Note that this method writes len+2
        // entries into alpha_codes (including start and stop)
        private HyphenationType alphabetLookup(UInt16[] alpha_codes, UInt16[] word, int len)
        {
            Header          header = getHeader();
            HyphenationType result = HyphenationType.BREAK_AND_INSERT_HYPHEN;
            // TODO: check header magic
            uint alphabetVersion = header.alphabetVersion();

            if (alphabetVersion == 0)
            {
                AlphabetTable0 alphabet      = header.alphabetTable0();
                uint           min_codepoint = new uint(alphabet.min_codepoint);
                uint           max_codepoint = new uint(alphabet.max_codepoint);
                alpha_codes[0] = 0; // word start
                for (int i = 0; i < len; i++)
                {
                    UInt16 c = word[i];
                    if (c < min_codepoint || c >= max_codepoint)
                    {
                        return(HyphenationType.DONT_BREAK);
                    }
                    byte code = alphabet.data[c - min_codepoint];
                    if (code == 0)
                    {
                        return(HyphenationType.DONT_BREAK);
                    }
                    if (result == HyphenationType.BREAK_AND_INSERT_HYPHEN)
                    {
                        result = minikin.GlobalMembers.hyphenationTypeBasedOnScript(new UInt16(c));
                    }
                    alpha_codes[i + 1] = code;
                }
                alpha_codes[len + 1] = 0; // word termination
                return(result);
            }
            else if (alphabetVersion == 1)
            {
                AlphabetTable1 alphabet  = header.alphabetTable1();
                int            n_entries = alphabet.n_entries;
                uint[]         begin     = new uint(alphabet.data);
                uint           end       = begin + n_entries;
                alpha_codes[0] = 0;
                for (int i = 0; i < len; i++)
                {
                    UInt16 c = word[i];
                    var    p = std::lower_bound <uint *, uint>(begin, end, c << 11);
                    if (p == end)
                    {
                        return(HyphenationType.DONT_BREAK);
                    }
                    uint entry = p;
                    if (AlphabetTable1.codepoint(new uint(entry)) != c)
                    {
                        return(HyphenationType.DONT_BREAK);
                    }
                    if (result == HyphenationType.BREAK_AND_INSERT_HYPHEN)
                    {
                        result = minikin.GlobalMembers.hyphenationTypeBasedOnScript(new UInt16(c));
                    }
                    alpha_codes[i + 1] = AlphabetTable1.value(new uint(entry));
                }
                alpha_codes[len + 1] = 0;
                return(result);
            }
            return(HyphenationType.DONT_BREAK);
        }