Changeset 241402 in webkit


Ignore:
Timestamp:
Feb 13, 2019 1:10:13 AM (5 years ago)
Author:
Carlos Garcia Campos
Message:

[FreeType] Unable to render some Hebrew characters
https://bugs.webkit.org/show_bug.cgi?id=194498

Reviewed by Michael Catanzaro.

We are failing to find a font for some of the combining character sequences because normalization is failing due
to overflow error. In case of overflow, normalize returns the required length for the normalized characters, so
we should handle that case to resize the output buffer and try again.

  • platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:

(WebCore::FontCascade::fontForCombiningCharacterSequence const):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r241352 r241402  
     12019-02-13  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [FreeType] Unable to render some Hebrew characters
     4        https://bugs.webkit.org/show_bug.cgi?id=194498
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        We are failing to find a font for some of the combining character sequences because normalization is failing due
     9        to overflow error. In case of overflow, normalize returns the required length for the normalized characters, so
     10        we should handle that case to resize the output buffer and try again.
     11
     12        * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
     13        (WebCore::FontCascade::fontForCombiningCharacterSequence const):
     14
    1152019-02-13  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp

    r239822 r241402  
    105105    UErrorCode error = U_ZERO_ERROR;
    106106    Vector<UChar, 4> normalizedCharacters(length);
    107     ALLOW_DEPRECATED_DECLARATIONS_BEGIN
    108     int32_t normalizedLength = unorm_normalize(characters, length, UNORM_NFC, UNORM_UNICODE_3_2, normalizedCharacters.data(), length, &error);
    109     ALLOW_DEPRECATED_DECLARATIONS_END
     107    const auto* normalizer = unorm2_getNFCInstance(&error);
    110108    if (U_FAILURE(error))
    111109        return nullptr;
     110    int32_t normalizedLength = unorm2_normalize(normalizer, characters, length, normalizedCharacters.data(), length, &error);
     111    if (U_FAILURE(error)) {
     112        if (error != U_BUFFER_OVERFLOW_ERROR)
     113            return nullptr;
     114
     115        error = U_ZERO_ERROR;
     116        normalizedCharacters.resize(normalizedLength);
     117        normalizedLength = unorm2_normalize(normalizer, characters, length, normalizedCharacters.data(), normalizedLength, &error);
     118        if (U_FAILURE(error))
     119            return nullptr;
     120    }
    112121
    113122    UChar32 character;
Note: See TracChangeset for help on using the changeset viewer.