// TODO(drott): crbug.com/623940 Fix lack of context sensitive case mapping here.
void CaseMappingHarfBuzzBufferFiller::fillSlowCase(
    CaseMapIntend caseMapIntend,
    AtomicString locale,
    const UChar* buffer,
    unsigned bufferLength,
    unsigned startIndex,
    unsigned numCharacters)
{
    // Record pre-context.
    hb_buffer_add_utf16(m_harfBuzzBuffer, toUint16(buffer), bufferLength, startIndex, 0);

    for (unsigned charIndex = startIndex; charIndex < startIndex + numCharacters;) {
        unsigned newCharIndex = charIndex;
        U16_FWD_1(buffer, newCharIndex, numCharacters);
        String charByChar(&buffer[charIndex], newCharIndex - charIndex);
        String caseMappedChar;
        if (caseMapIntend == CaseMapIntend::UpperCase)
            caseMappedChar = charByChar.upper(locale);
        else
            caseMappedChar = charByChar.lower(locale);

        for (unsigned j = 0; j < caseMappedChar.length();) {
            UChar32 codepoint = 0;
            U16_NEXT(caseMappedChar.characters16(), j, caseMappedChar.length(), codepoint);
            // Add all characters of the case mapping result at the same cluster position.
            hb_buffer_add(m_harfBuzzBuffer, codepoint, charIndex);
        }
        charIndex = newCharIndex;
    }

    // Record post-context
    hb_buffer_add_utf16(m_harfBuzzBuffer, toUint16(buffer), bufferLength, startIndex + numCharacters, 0);
}
Beispiel #2
0
static void
fixture_init (fixture_t *fixture, gconstpointer user_data)
{
  hb_buffer_t *b;
  unsigned int i;

  b = fixture->buffer = hb_buffer_create ();

  switch (GPOINTER_TO_INT (user_data))
  {
    case BUFFER_EMPTY:
      break;

    case BUFFER_ONE_BY_ONE:
      for (i = 1; i < G_N_ELEMENTS (utf32) - 1; i++)
	hb_buffer_add (b, utf32[i], i);
      break;

    case BUFFER_UTF32:
      hb_buffer_add_utf32 (b, utf32, G_N_ELEMENTS (utf32), 1, G_N_ELEMENTS (utf32) - 2);
      break;

    case BUFFER_UTF16:
      hb_buffer_add_utf16 (b, utf16, G_N_ELEMENTS (utf16), 1, G_N_ELEMENTS (utf16) - 2);
      break;

    case BUFFER_UTF8:
      hb_buffer_add_utf8  (b, utf8,  G_N_ELEMENTS (utf8),  1, G_N_ELEMENTS (utf8)  - 2);
      break;

    default:
      g_assert_not_reached ();
  }
}