Changeset 106551 in webkit


Ignore:
Timestamp:
Feb 2, 2012 6:27:10 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Fix mirroring with SVG fonts
https://bugs.webkit.org/show_bug.cgi?id=77067

Patch by Philip Rogers <pdr@google.com> on 2012-02-02
Reviewed by Nikolas Zimmermann.

Source/WebCore:

SVG fonts were incorrectly handling mirrored characters in bidi text.
In this change I added the function createStringWithMirroredCharacters
which handles mirroring the characters when selecting glyphs for SVG
fonts. I also made a small cosmetic change in the function
charactersWithArabicForm, changing the bool parameter "mirror" to "rtl"
which better reflects what it actually does.

Several new tests were added to test mirroring with SVG fonts in the
presence of Arabic forms and non-BMP characters.

Tests: svg/custom/glyph-selection-arabic-forms.svg

svg/custom/glyph-selection-bidi-mirror.svg
svg/custom/glyph-selection-non-bmp.svg

  • platform/graphics/SVGGlyph.cpp:

(WebCore::charactersWithArabicForm):

  • svg/SVGFontData.cpp:

(WebCore::SVGFontData::applySVGGlyphSelection):
(WebCore::SVGFontData::createStringWithMirroredCharacters):

  • svg/SVGFontData.h:

(SVGFontData):

LayoutTests:

SVG fonts were incorrectly handling mirrored characters in bidi text.
In this change I added the function createStringWithMirroredCharacters
which handles mirroring the characters when selecting glyphs for SVG
fonts. I also made a small cosmetic change in the function
charactersWithArabicForm, changing the bool parameter "mirror" to "rtl"
which better reflects what it actually does.

Several new tests were added to test mirroring with SVG fonts in the
presence of Arabic forms and non-BMP characters.

  • svg/custom/glyph-selection-arabic-forms-expected.txt: Added.
  • svg/custom/glyph-selection-arabic-forms.svg: Added.
  • svg/custom/glyph-selection-bidi-mirror-expected.txt: Added.
  • svg/custom/glyph-selection-bidi-mirror.svg: Added.
  • svg/custom/glyph-selection-non-bmp-expected.txt: Added.
  • svg/custom/glyph-selection-non-bmp.svg: Added.
Location:
trunk
Files:
9 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r106548 r106551  
     12012-02-02  Philip Rogers  <pdr@google.com>
     2
     3        Fix mirroring with SVG fonts
     4        https://bugs.webkit.org/show_bug.cgi?id=77067
     5
     6        Reviewed by Nikolas Zimmermann.
     7
     8        SVG fonts were incorrectly handling mirrored characters in bidi text.
     9        In this change I added the function createStringWithMirroredCharacters
     10        which handles mirroring the characters when selecting glyphs for SVG
     11        fonts. I also made a small cosmetic change in the function
     12        charactersWithArabicForm, changing the bool parameter "mirror" to "rtl"
     13        which better reflects what it actually does.
     14
     15        Several new tests were added to test mirroring with SVG fonts in the
     16        presence of Arabic forms and non-BMP characters.
     17
     18        * svg/custom/glyph-selection-arabic-forms-expected.txt: Added.
     19        * svg/custom/glyph-selection-arabic-forms.svg: Added.
     20        * svg/custom/glyph-selection-bidi-mirror-expected.txt: Added.
     21        * svg/custom/glyph-selection-bidi-mirror.svg: Added.
     22        * svg/custom/glyph-selection-non-bmp-expected.txt: Added.
     23        * svg/custom/glyph-selection-non-bmp.svg: Added.
     24
    1252012-02-02  Philippe Normand  <pnormand@igalia.com>
    226
  • trunk/Source/WebCore/ChangeLog

    r106550 r106551  
     12012-02-02  Philip Rogers  <pdr@google.com>
     2
     3        Fix mirroring with SVG fonts
     4        https://bugs.webkit.org/show_bug.cgi?id=77067
     5
     6        Reviewed by Nikolas Zimmermann.
     7
     8        SVG fonts were incorrectly handling mirrored characters in bidi text.
     9        In this change I added the function createStringWithMirroredCharacters
     10        which handles mirroring the characters when selecting glyphs for SVG
     11        fonts. I also made a small cosmetic change in the function
     12        charactersWithArabicForm, changing the bool parameter "mirror" to "rtl"
     13        which better reflects what it actually does.
     14
     15        Several new tests were added to test mirroring with SVG fonts in the
     16        presence of Arabic forms and non-BMP characters.
     17
     18        Tests: svg/custom/glyph-selection-arabic-forms.svg
     19               svg/custom/glyph-selection-bidi-mirror.svg
     20               svg/custom/glyph-selection-non-bmp.svg
     21
     22        * platform/graphics/SVGGlyph.cpp:
     23        (WebCore::charactersWithArabicForm):
     24        * svg/SVGFontData.cpp:
     25        (WebCore::SVGFontData::applySVGGlyphSelection):
     26        (WebCore::SVGFontData::createStringWithMirroredCharacters):
     27        * svg/SVGFontData.h:
     28        (SVGFontData):
     29
    1302012-02-02  Pavel Feldman  <pfeldman@google.com>
    231
  • trunk/Source/WebCore/platform/graphics/SVGGlyph.cpp

    r84498 r106551  
    8181}
    8282
    83 Vector<SVGGlyph::ArabicForm> charactersWithArabicForm(const String& input, bool mirror)
     83Vector<SVGGlyph::ArabicForm> charactersWithArabicForm(const String& input, bool rtl)
    8484{
    8585    Vector<SVGGlyph::ArabicForm> forms;
     
    100100
    101101    // Start identifying arabic forms
    102     if (mirror) {
     102    if (rtl) {
    103103        for (int i = length - 1; i >= 0; --i)
    104104            forms.prepend(processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.first()));
  • trunk/Source/WebCore/svg/SVGFontData.cpp

    r103155 r106551  
    3232#include "WidthIterator.h"
    3333#include "XMLNames.h"
     34#include <wtf/text/StringBuilder.h>
     35#include <wtf/unicode/CharacterNames.h>
     36#include <wtf/unicode/Unicode.h>
     37
     38using namespace WTF;
     39using namespace Unicode;
    3440
    3541namespace WebCore {
     
    131137    String remainingTextInRun(run.data(currentCharacter), run.charactersLength() - currentCharacter);
    132138    remainingTextInRun = Font::normalizeSpaces(remainingTextInRun.characters(), remainingTextInRun.length());
     139    if (mirror)
     140        remainingTextInRun = createStringWithMirroredCharacters(remainingTextInRun.characters(), remainingTextInRun.length());
    133141    if (!currentCharacter && arabicForms.isEmpty())
    134142        arabicForms = charactersWithArabicForm(remainingTextInRun, mirror);
     
    261269}
    262270
     271String SVGFontData::createStringWithMirroredCharacters(const UChar* characters, unsigned length) const
     272{
     273    StringBuilder mirroredCharacters;
     274    mirroredCharacters.reserveCapacity(length);
     275
     276    UChar32 character;
     277    unsigned i = 0;
     278    while (i < length) {
     279        U16_NEXT(characters, i, length, character);
     280        character = mirroredChar(character);
     281
     282        if (U16_LENGTH(character) == 1)
     283            mirroredCharacters.append(static_cast<UChar>(character));
     284        else {
     285            mirroredCharacters.append(U16_LEAD(character));
     286            mirroredCharacters.append(U16_TRAIL(character));
     287        }
     288    }
     289
     290    return mirroredCharacters.toString();
     291}
    263292
    264293} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFontData.h

    r95901 r106551  
    5757    bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
    5858
     59    String createStringWithMirroredCharacters(const UChar* characters, unsigned length) const;
     60
    5961    // Ths SVGFontFaceElement is kept alive --
    6062    // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
Note: See TracChangeset for help on using the changeset viewer.