Title: [265455] trunk
Revision
265455
Author
[email protected]
Date
2020-08-10 14:51:58 -0700 (Mon, 10 Aug 2020)

Log Message

Shaping can be performed on glyphIDs from the wrong font
https://bugs.webkit.org/show_bug.cgi?id=215333

Reviewed by Darin Adler.

Source/WebCore:

The problem is this line:
if (font != lastFontData && width)

This means we will only trigger shaping code if width is non-zero.
However, even if width is non-zero, we will still happily add glyphs
to the glyph buffer, and when we do eventually get around to shaping,
we shape all yet-unshaped glyphs, regardless of which font they came
from.

Test: fast/text/zero-width-shaping-font-mismatch.html

* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::commitCurrentFontRange):
(WebCore::WidthIterator::advanceInternal):
* platform/graphics/WidthIterator.h:

LayoutTests:

* fast/text/resources/Ahem-zero-width-shaping-font-mismatch.ttf: Added. This is a font where
U+2C95 COPTIC SMALL LETTER KAPA (which Times doesn't support) is mapped to glyph 73. Also,
the font has fewer than 192 glyphs.
* fast/text/zero-width-shaping-font-mismatch-expected-mismatch.html: Added. Times has a
ligature where the glyph sequence 73,76 gets replaced with glyph 192. The test has characters
U+2C95 COPTIC SMALL LETTER KAPA (which Times doesn't support but the webfont does, so we map
this to glyph 73 inside the web font) followed by U+0069 LATIN SMALL LETTER I, (which Times
does support, so we map this to glyph 76 inside Times). Then, because of this bug, we'll try
to shape glyphs 73,76 using Times, which replaces them with glyph 192, but then try to render
glyph 192 with the web font, which doesn't support it, so we get a white screen.
* fast/text/zero-width-shaping-font-mismatch.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (265454 => 265455)


--- trunk/LayoutTests/ChangeLog	2020-08-10 21:50:39 UTC (rev 265454)
+++ trunk/LayoutTests/ChangeLog	2020-08-10 21:51:58 UTC (rev 265455)
@@ -1,3 +1,22 @@
+2020-08-10  Myles C. Maxfield  <[email protected]>
+
+        Shaping can be performed on glyphIDs from the wrong font
+        https://bugs.webkit.org/show_bug.cgi?id=215333
+
+        Reviewed by Darin Adler.
+
+        * fast/text/resources/Ahem-zero-width-shaping-font-mismatch.ttf: Added. This is a font where
+        U+2C95 COPTIC SMALL LETTER KAPA (which Times doesn't support) is mapped to glyph 73. Also,
+        the font has fewer than 192 glyphs.
+        * fast/text/zero-width-shaping-font-mismatch-expected-mismatch.html: Added. Times has a
+        ligature where the glyph sequence 73,76 gets replaced with glyph 192. The test has characters
+        U+2C95 COPTIC SMALL LETTER KAPA (which Times doesn't support but the webfont does, so we map
+        this to glyph 73 inside the web font) followed by U+0069 LATIN SMALL LETTER I, (which Times
+        does support, so we map this to glyph 76 inside Times). Then, because of this bug, we'll try
+        to shape glyphs 73,76 using Times, which replaces them with glyph 192, but then try to render
+        glyph 192 with the web font, which doesn't support it, so we get a white screen.
+        * fast/text/zero-width-shaping-font-mismatch.html: Added.
+
 2020-08-10  Hector Lopez  <[email protected]>
 
         [ macOS wk1 Release ] svg/text/hidpi-text-selection-rect-position.html is a flaky failure

Added: trunk/LayoutTests/fast/text/resources/Ahem-zero-width-shaping-font-mismatch.ttf (0 => 265455)


--- trunk/LayoutTests/fast/text/resources/Ahem-zero-width-shaping-font-mismatch.ttf	                        (rev 0)
+++ trunk/LayoutTests/fast/text/resources/Ahem-zero-width-shaping-font-mismatch.ttf	2020-08-10 21:51:58 UTC (rev 265455)
@@ -0,0 +1,10 @@
+����������\x80����0OS/2sf&������\xBC������`cmap}-\xF5����������Tgasp����	����p������glyf\xCE\xF2\xC8H����\x80����^head\xDBP͵����\xE0������6hhea
+l����	������$hmtx(��}����	<����,locaB\xE0D\xC8����
+h������\x98maxp��N��	������������ name\xB8)\xC6���� ����)\xA2post<+\x9E����4\xC4������\xC6��\xD6\x90������\xBC\x8A������\x8F\xBC\x8A����\xC5��2��������������������\x80����\xAF�� H����������������W3C ��@�� ,\x95 \xFF8���� ��\xC8\xFF\xFC����\xFF\xFF  ������ ������������������������������������@��������������&��f��h��l,\x95\xFF\xFF������ ��(��h��j,\x95\xFF\xFF\xFF\xE3\xFF\xE2\xFF\xE2\xFF\xE2Ӵ����������������������������������������\xFF\xFF������}����k ��������3!%!!}\xEE\xFD\x8F\xF4\xFE \xFC\xE0}&������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\x
 FF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!
 !\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC
  \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC 
 \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC����
 ��\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF
 8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������\xFF8\xE8 ������!!\xE8\xFC \xFC������������\x80��\xB8-F\x99_<\xF5��	\xE8��������\xB3o_Y��������\xC4ݫ$����\xFF8\xE8 ���������������������������� \xFF8����\xE8��������\xE8��������������������������������K\xE8��}��������\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE
 8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\xE8����\
 xE8������������\xE8������������������!��.��;��H��U��b��o��|��\x89��\x96��\xA3��\xB0��\xBD��\xCA��\xD7��\xE4��\xF1��\xFE%2?LYfs\x80\x8D\x9A\xA7\xB4\xC1\xCE\xDB\xE8\xF5)6CP]jw\x84\x91\x9E\xAB\xB8\xC5\xD2\xDF\xEC\xF9 -:GTan{\x88\x95\xA2\xAF��������K����������������������������������������������������$\xB6����������������\xF0��������������������\xF0����������������\xF8����������������"����������������(����������������0����������������H��������������
+hP����������������$\xB8����������������R\xDC����������������\xF8.��������������&��������������*��������������1��������������B��������������F��������������R������������
+����V��������������V��������������)h��������������\x91��������������\x95��������������\x9C����	����\xF0\xA0����	����\x90����	����\x98����	����"\xA6����	����\xC8����	����\xD0����	����\xE8����	��
+h\xF0����	����$'X����	����R'|����	����'\xCE����	����'\xD6����	����'\xE4��T��h��e�� ��A��h��e��m�� ��f��o��n��t�� ��b��e��l��o��n��g��s�� ��t��o�� ��t��h��e�� ��p��u��b��l��i��c�� ��d��o��m��a��i��n��.�� ��I��n�� ��j��u��r��i��s��d��i��c��t��i��o��n��s�� ��t��h��a��t�� ��d��o�� ��n��o��t�� ��r��e��c��o��g��n��i��z��e�� ��p��u��b��l��i��c�� ��d��o��m��a��i��n�� ��o��w��n��e��r��s��h��i��p�� ��o��f�� ��t��h��e��s��e�� ��f��i��l��e��s��,�� ��t��h��e�� ��f��o��l��l��o��w��i��n��g�� ��C��r��e��a��t��i��v��e�� ��C��o��m��m��o��n��s�� ��Z��e��r��o�� ��d��e��c��l��a��r��a��t��i��o��n�� ��a��p��p��l��i��e��s��:�� ��h��t��t��p��:��/��/��l��a��b��s��.��c��r��e��a��t��i��v��e��c��o��m��m��o��n��s��.��o��r��g��/��l��i��c��e��n��s��e��s��/��z��e��r��o��-��w��a��i��v��e��/��1��.��0��/��u��s��/��l��e��g��a��l��c��o��d��e��A��h��e��m��R��e��g��u��l��a��r��V��e��r��s��i��o��n�� ��1��.��5��0�� ��A��h��e��m��A��h��e��m��V��e��r��s��i��o��n�� ��1��.��5��0��A��h��e��m��T��h��e�� �
 �A��h��e��m�� ��f��o��n��t�� ��w��a��s�� ��d��e��v��e��l��o��p��e��d�� ��b��y�� ��T��o��d��d�� ��F��a��h��r��n��e��r�� ��a��n��d�� ��M��y��l��e��s�� ��C��.�� ��M��a��x��f��i��e��l��d�� ��t��o�� ��h��e��l��p�� ��t��e��s��t�� ��w��r��i��t��e��r��s�� ��d��e��v��e��l��o��p�� ��p��r��e��d��i��c��t��a��b��l��e�� ��t��e��s��t��s��.�� ��T��h��e�� ��u��n��i��t��s�� ��p��e��r�� ��e��m�� ��i��s�� ��1��0��0��0��,�� ��t��h��e�� ��a��d��v��a��n��c��e�� ��i��s�� ��8��0��0��,�� ��a��n��d�� ��
 t��h��e�� ��d��e��s��c��e��n��t�� ��i��s�� ��2��0��0��,�� ��t��h��e��r��e��b��y�� ��m��a��k��i��n��g�� ��t��h��e�� ��e��m�� ��s��q��u��a��r��e�� ��e��x��a��c��t��l��y�� ��s��q��u��a��r��e��.�� ��T��h��e�� ��g��l��y��p��h��s�� ��f��o��r�� ��m��o��s��t�� ��c��h��a��r��a��c��t��e��r��s�� ��i��s�� ��s��i��m��p��l��y�� ��a�� ��b��o��x�� ��w��h��i��c��h�� ��f��i��l��l��s�� ��t��h��i��s�� ��s��q��u��a��r��e��.�� ��T��h��e�� ��c��o��d��e��p��o��i��n��t��s�� ��m��a��p��p��e��d�� ��t��o�� ��t��h��i��s�� ��f��u��l��l�� ��s��q��u��a��r��e�� ��w��i��t��h�� ��a�� ��f��u��l��l�� ��a��d��v��a��n��c��e�� ��a��r��e�� ��t��h��e�� ��f��o��l��l��o��w��i��n��g�� ��r��a��n��g��e��s��:�� ��U��+��2��0��-��U��+��2��6��,�� ��U��+��2��8��-��U��+��6��F��,�� ��U��+��7��1��-��U��+��7��E��,�� ��U��+��A��0��-��U��+��C��8��,�� ��U��+��C��A��-��U��+��F��F��,�� ��U��+��1��3��1��,�� ��U��+��1��5��2��-��U��+��1��5��3��,�� ��U��+��1��7��8��,�� ��U��+��1��9��2��,�� ��U��+��2��C��6��-��U��+��2��C��7��,�� ��U��+��2��C��9��,
 �� ��U��+��2��D��8��-��U��+��2��D��D��,�� ��U��+��3��9��4��,�� ��U��+��3��A��5��,�� ��U��+��3��A��7��,�� ��U��+��3��A��9��,�� ��U��+��3��B��C��,�� ��U��+��3��C��0��,�� ��U��+��2��0��1��3��-��U��+��2��0��1��4��,�� ��U��+��2��0��1��8��-��U��+��2��0��1��A��,�� ��U��+��2��0��1��C��-��U��+��2��0��1��E��,�� ��U��+��2��0��2��0��-��U��+��2��0��2��2��,�� ��U��+��2��0��2��6��,�� ��U��+��2��0��3��0��,�� ��U��+��2��0��3��9��-��U��+��2��0��3��A��,�� ��U��+��2��0��4��4��,�� ��U��+��2��1��2��2��,�� ��U��+��2
 ��1��2��6��,�� ��U��+��2��2��0��2��,�� ��U��+��2��2��0��6��,�� ��U��+��2��2��0��F��,�� ��U��+��2��2��1��1��-��U��+��2��2��1��2��,�� ��U��+��2��2��1��9��-��U��+��2��2��1��A��,�� ��U��+��2��2��1��E��,�� ��U��+��2��2��2��B��,�� ��U��+��2��2��4��8��,�� ��U��+��2��2��6��0��,�� ��U��+��2��2��6��4��-��U��+��2��2��6��5��,�� ��U��+��2��2��F��2��,�� ��U��+��2��5��C��A��,�� ��U��+��3��0��0��7��,�� ��U��+��4��E��0��0��,�� ��U��+��4��E��0��3��,�� ��U��+��4��E��0��9��,�� ��U��+��4��E��5��D��,�� ��U��+��4��E��8��C��,�� ��U��+��4��E��9��4��,�� ��U��+��5��1��6��B��,�� ��U��+��5��1��6��D��,�� ��U��+��5��3��4��1��,�� ��U��+��5��6��D��7��,�� ��U��+��5��6��D��B��,�� ��U��+��5��7��1��F��,�� ��U��+��6��7��2��8��,�� ��U��+��6��C��3��4��,�� ��U��+��7��0��6��B��,�� ��U��+��9��1��D��1��,�� ��U��+��F��0��0��0��-��U��+��F��0��0��2��.�� ��T��h��e�� ��c��o��d��e��p��o��i��n��t��s�� ��w��h��i��c��h�� ��a��r��e�� ��m��a��p��p��e��d�� ��t��o�� ��s��o��m��e��t��h��i��n��g�� ��e��l��s��e�� ��a��r��e�� ��t��h��e�� ��f�
 �o��l��l��o��w��i��n��g��:�� ��"�� ��"�� ��(��U��+��2��0��)��:�� ��N��o�� ��p��a��t��h�� ��b��u��t�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��"��p��"�� ��(��U��+��7��0��)��:�� ��P��a��t��h�� ��h��a��s�� ��0�� ��a��s��c��e��n��t�� ��b��u��t�� ��f��u��l��l�� ��d��e��s��c��e��n��t��;�� ��"��\xC9��"�� ��(��U��+��C��9��)��:�� ��P��a��t��h�� ��h��a��s�� ��0�� ��d��e��s��c��e��n��t�� ��b��u��t�� ��f��u��l��l�� ��a��s��c��e��n��t��;�� ��N��o��n��-��b��r
 ��e��a��k��i��n��g�� ��s��p��a��c��e�� ��(��U��+��A��0��)��:�� ��N��o�� ��p��a��t��h�� ��b��u��t�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��Z��e��r��o��-��w��i��d��t��h�� ��n��o��n��-��b��r��e��a��k��i��n��g�� ��s��p��a��c��e�� ��(��U��+��F��E��F��F��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��0�� ��a��d��v��a��n��c��e��;�� ��E��n�� ��s��p��a��c��e�� ��(��U��+��2��0��0��2��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��h��a��l��f�� ��a��d��v��a��n��c��e��;�� ��E��m�� ��s��p��a��c��e�� ��(��U��+��2��0��0��3��)��:�� ��N��o�� ��p��a��t��h�� ��b��u��t�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��T��h��r��e��e��-��p��e��r��-��e��m�� ��s��p��a��c��e�� ��(��U��+��2��0��0��4��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��t��h��i��r��d�� ��a��d��v��a��n��c��e��;�� ��F��o��u��r��-��p��e��r��-��e��m�� ��s��p��a��c��e�� ��(��U��+��2��0��0��5��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��q��u��a��r��t��e��r�� ��a��d��v��a��n��c��e��;�� ��S��i��x��-��p��e��r��-��e��m�� �
 �s��p��a��c��e�� ��(��U��+��2��0��0��6��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��s��i��x��t��h�� ��a��d��v��a��n��c��e��;�� ��T��h��i��n�� ��s��p��a��c��e�� ��(��U��+��2��0��0��9��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��f��i��f��t��h�� ��a��d��v��a��n��c��e��;�� ��H��a��i��r�� ��s��p��a��c��e�� ��(��U��+��2��0��0��A��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��t��e��n��t��h�� ��a��d��v��a��n��c��e��;�� ��Z��e��r��o�� ��w��i��d��t��h�� ��s��p��a��c��
 e�� ��(��U��+��2��0��0��B��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��n��o�� ��a��d��v��a��n��c��e��;�� ��I��d��e��o��g��r��a��p��h��i��c�� ��s��p��a��c��e�� ��(��U��+��3��0��0��0��)��:�� ��N��o�� ��p��a��t��h�� ��b��u��t�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��Z��e��r��o�� ��w��i��d��t��h�� ��n��o��n��-��j��o��i��n��e��r�� ��(��U��+��2��0��0��C��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��n��o�� ��a��d��v��a��n��c��e��;�� ��Z��e��r��o�� ��w��i��d��t��h�� ��j��o��i��n��e��r�� ��(��U��+��2��0��0��D��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��n��o�� ��a��d��v��a��n��c��e��;�� ��G��r��e��e��k�� ��c��a��p��i��t��a��l�� ��l��e��t��t��e��r�� ��C��h��i�� ��(��U��+��3��A��7��)��:�� ��T��h��i��n�� ��h��o��r��i��z��o��n��t��a��l�� ��s��t��r��i��p��e�� ��a��n��d�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��"j*��"�� ��(��U��+��6��A��2��A��)��:�� ��T��h��i��n�� ��h��o��r��i��z��o��n��t��a��l�� ��s��t��r��i��p��e�� ��a��n��d�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��G��r
 ��e��e��k�� ��c��a��p��i��t��a��l�� ��l��e��t��t��e��r�� ��U��p��s��i��l��o��n�� ��(��U��+��3��A��5��)��:�� ��T��h��i��n�� ��v��e��r��t��i��c��a��l�� ��s��t��r��i��p��e�� ��a��n��d�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��"~\xB5��"�� ��(��U��+��7��E��B��5��)��:�� ��T��h��i��n�� ��v��e��r��t��i��c��a��l�� ��s��t��r��i��p��e�� ��a��n��d�� ��f��u��l��l�� ��a��d��v��a��n��c��e��.��h��t��t��p��:��/��/��w��w��w��.��w��3��c��.��o��r��g��h��t��t��p��:��/��/��d��e��v��.��w��
 3��.��o��r��g��/��C��S��S��/��f��o��n��t��s��/��a��h��e��m��/��C��O��P��Y��I��N��G��
+The Ahem font belongs to the public domain. In jurisdictions that do not recognize public domain ownership of these files, the following Creative Commons Zero declaration applies: http://labs.creativecommons.org/licenses/zero-waive/1.0/us/legalcodeAhemRegularVersion 1.50 AhemAhemVersion 1.50Ahemhttp://www.w3c.orghttp://dev.w3.org/CSS/fonts/ahem/COPYING
+AhemRegularAhem��T��h��e�� ��A��h��e��m�� ��f��o��n��t�� ��b��e��l��o��n��g��s�� ��t��o�� ��t��h��e�� ��p��u��b��l��i��c�� ��d��o��m��a��i��n��.�� ��I��n�� ��j��u��r��i��s��d��i��c��t��i��o��n��s�� ��t��h��a��t�� ��d��o�� ��n��o��t�� ��r��e��c��o��g��n��i��z��e�� ��p��u��b��l��i��c�� ��d��o��m��a��i��n�� ��o��w��n��e��r��s��h��i��p�� ��o��f�� ��t��h��e��s��e�� ��f��i��l��e��s��,�� ��t��h��e�� ��f��o��l��l��o��w��i��n��g�� ��C��r��e��a��t��i��v��e�� ��C��o��m��m��o��n��s�� ��Z��e��r��o�� ��d��e��c��l��a��r��a��t��i��o��n�� ��a��p��p��l��i��e��s��:�� ��h��t��t��p��:��/��/��l��a��b��s��.��c��r��e��a��t��i��v��e��c��o��m��m��o��n��s��.��o��r��g��/��l��i��c��e��n��s��e��s��/��z��e��r��o��-��w��a��i��v��e��/��1��.��0��/��u��s��/��l��e��g��a��l��c��o��d��e��A��h��e��m��R��e��g��u��l��a��r��V��e��r��s��i��o��n�� ��1��.��5��0�� ��A��h��e��m��A��h��e��m��V��e��r��s��i��o��n�� ��1��.��5��0��A��h��e��m��T��h��e�� ��A��h��e��m�� ��f��o��n��t�� ��w��a��s�� ��d��e��v��e��l��o��p��e��d�� ��b��y�� �
 �T��o��d��d�� ��F��a��h��r��n��e��r�� ��a��n��d�� ��M��y��l��e��s�� ��C��.�� ��M��a��x��f��i��e��l��d�� ��t��o�� ��h��e��l��p�� ��t��e��s��t�� ��w��r��i��t��e��r��s�� ��d��e��v��e��l��o��p�� ��p��r��e��d��i��c��t��a��b��l��e�� ��t��e��s��t��s��.�� ��T��h��e�� ��u��n��i��t��s�� ��p��e��r�� ��e��m�� ��i��s�� ��1��0��0��0��,�� ��t��h��e�� ��a��d��v��a��n��c��e�� ��i��s�� ��8��0��0��,�� ��a��n��d�� ��t��h��e�� ��d��e��s��c��e��n��t�� ��i��s�� ��2��0��0��,�� ��t��h��e��r��e��b��y�� ��m��a��k
 ��i��n��g�� ��t��h��e�� ��e��m�� ��s��q��u��a��r��e�� ��e��x��a��c��t��l��y�� ��s��q��u��a��r��e��.�� ��T��h��e�� ��g��l��y��p��h��s�� ��f��o��r�� ��m��o��s��t�� ��c��h��a��r��a��c��t��e��r��s�� ��i��s�� ��s��i��m��p��l��y�� ��a�� ��b��o��x�� ��w��h��i��c��h�� ��f��i��l��l��s�� ��t��h��i��s�� ��s��q��u��a��r��e��.�� ��T��h��e�� ��c��o��d��e��p��o��i��n��t��s�� ��m��a��p��p��e��d�� ��t��o�� ��t��h��i��s�� ��f��u��l��l�� ��s��q��u��a��r��e�� ��w��i��t��h�� ��a�� ��f��u��l��l�� ��a��d��v��a��n��c��e�� ��a��r��e�� ��t��h��e�� ��f��o��l��l��o��w��i��n��g�� ��r��a��n��g��e��s��:�� ��U��+��2��0��-��U��+��2��6��,�� ��U��+��2��8��-��U��+��6��F��,�� ��U��+��7��1��-��U��+��7��E��,�� ��U��+��A��0��-��U��+��C��8��,�� ��U��+��C��A��-��U��+��F��F��,�� ��U��+��1��3��1��,�� ��U��+��1��5��2��-��U��+��1��5��3��,�� ��U��+��1��7��8��,�� ��U��+��1��9��2��,�� ��U��+��2��C��6��-��U��+��2��C��7��,�� ��U��+��2��C��9��,�� ��U��+��2��D��8��-��U��+��2��D��D��,�� ��U��+��3��9��4��,�� ��U��+��3��A��5��,�� ��U��+�
 �3��A��7��,�� ��U��+��3��A��9��,�� ��U��+��3��B��C��,�� ��U��+��3��C��0��,�� ��U��+��2��0��1��3��-��U��+��2��0��1��4��,�� ��U��+��2��0��1��8��-��U��+��2��0��1��A��,�� ��U��+��2��0��1��C��-��U��+��2��0��1��E��,�� ��U��+��2��0��2��0��-��U��+��2��0��2��2��,�� ��U��+��2��0��2��6��,�� ��U��+��2��0��3��0��,�� ��U��+��2��0��3��9��-��U��+��2��0��3��A��,�� ��U��+��2��0��4��4��,�� ��U��+��2��1��2��2��,�� ��U��+��2��1��2��6��,�� ��U��+��2��2��0��2��,�� ��U��+��2��2��0��6��,�� ��U��+��2��2��0��F��,�� ��U��
 +��2��2��1��1��-��U��+��2��2��1��2��,�� ��U��+��2��2��1��9��-��U��+��2��2��1��A��,�� ��U��+��2��2��1��E��,�� ��U��+��2��2��2��B��,�� ��U��+��2��2��4��8��,�� ��U��+��2��2��6��0��,�� ��U��+��2��2��6��4��-��U��+��2��2��6��5��,�� ��U��+��2��2��F��2��,�� ��U��+��2��5��C��A��,�� ��U��+��3��0��0��7��,�� ��U��+��4��E��0��0��,�� ��U��+��4��E��0��3��,�� ��U��+��4��E��0��9��,�� ��U��+��4��E��5��D��,�� ��U��+��4��E��8��C��,�� ��U��+��4��E��9��4��,�� ��U��+��5��1��6��B��,�� ��U��+��5��1��6��D��,�� ��U��+��5��3��4��1��,�� ��U��+��5��6��D��7��,�� ��U��+��5��6��D��B��,�� ��U��+��5��7��1��F��,�� ��U��+��6��7��2��8��,�� ��U��+��6��C��3��4��,�� ��U��+��7��0��6��B��,�� ��U��+��9��1��D��1��,�� ��U��+��F��0��0��0��-��U��+��F��0��0��2��.�� ��T��h��e�� ��c��o��d��e��p��o��i��n��t��s�� ��w��h��i��c��h�� ��a��r��e�� ��m��a��p��p��e��d�� ��t��o�� ��s��o��m��e��t��h��i��n��g�� ��e��l��s��e�� ��a��r��e�� ��t��h��e�� ��f��o��l��l��o��w��i��n��g��:�� ��"�� ��"�� ��(��U��+��2��0��)��:�� ��N��o�� ��p��a��
 t��h�� ��b��u��t�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��"��p��"�� ��(��U��+��7��0��)��:�� ��P��a��t��h�� ��h��a��s�� ��0�� ��a��s��c��e��n��t�� ��b��u��t�� ��f��u��l��l�� ��d��e��s��c��e��n��t��;�� ��"��\xC9��"�� ��(��U��+��C��9��)��:�� ��P��a��t��h�� ��h��a��s�� ��0�� ��d��e��s��c��e��n��t�� ��b��u��t�� ��f��u��l��l�� ��a��s��c��e��n��t��;�� ��N��o��n��-��b��r��e��a��k��i��n��g�� ��s��p��a��c��e�� ��(��U��+��A��0��)��:�� ��N��o�� ��p��a��t��h�� ��b��
 u��t�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��Z��e��r��o��-��w��i��d��t��h�� ��n��o��n��-��b��r��e��a��k��i��n��g�� ��s��p��a��c��e�� ��(��U��+��F��E��F��F��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��0�� ��a��d��v��a��n��c��e��;�� ��E��n�� ��s��p��a��c��e�� ��(��U��+��2��0��0��2��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��h��a��l��f�� ��a��d��v��a��n��c��e��;�� ��E��m�� ��s��p��a��c��e�� ��(��U��+��2��0��0��3��)��:�� ��N��o�� ��p��a��t��h�� ��b��u��t�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��T��h��r��e��e��-��p��e��r��-��e��m�� ��s��p��a��c��e�� ��(��U��+��2��0��0��4��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��t��h��i��r��d�� ��a��d��v��a��n��c��e��;�� ��F��o��u��r��-��p��e��r��-��e��m�� ��s��p��a��c��e�� ��(��U��+��2��0��0��5��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��q��u��a��r��t��e��r�� ��a��d��v��a��n��c��e��;�� ��S��i��x��-��p��e��r��-��e��m�� ��s��p��a��c��e�� ��(��U��+��2��0��0��6��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e
 �� ��s��i��x��t��h�� ��a��d��v��a��n��c��e��;�� ��T��h��i��n�� ��s��p��a��c��e�� ��(��U��+��2��0��0��9��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��f��i��f��t��h�� ��a��d��v��a��n��c��e��;�� ��H��a��i��r�� ��s��p��a��c��e�� ��(��U��+��2��0��0��A��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��o��n��e�� ��t��e��n��t��h�� ��a��d��v��a��n��c��e��;�� ��Z��e��r��o�� ��w��i��d��t��h�� ��s��p��a��c��e�� ��(��U��+��2��0��0��B��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��n��o�� ��a��d��v��a
 ��n��c��e��;�� ��I��d��e��o��g��r��a��p��h��i��c�� ��s��p��a��c��e�� ��(��U��+��3��0��0��0��)��:�� ��N��o�� ��p��a��t��h�� ��b��u��t�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��Z��e��r��o�� ��w��i��d��t��h�� ��n��o��n��-��j��o��i��n��e��r�� ��(��U��+��2��0��0��C��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��n��o�� ��a��d��v��a��n��c��e��;�� ��Z��e��r��o�� ��w��i��d��t��h�� ��j��o��i��n��e��r�� ��(��U��+��2��0��0��D��)��:�� ��N��o�� ��p��a��t��h�� ��a��n��d�� ��n��o�� ��a��d��v��a��n��c��e��;�� ��G��r��e��e��k�� ��c��a��p��i��t��a��l�� ��l��e��t��t��e��r�� ��C��h��i�� ��(��U��+��3��A��7��)��:�� ��T��h��i��n�� ��h��o��r��i��z��o��n��t��a��l�� ��s��t��r��i��p��e�� ��a��n��d�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��"j*��"�� ��(��U��+��6��A��2��A��)��:�� ��T��h��i��n�� ��h��o��r��i��z��o��n��t��a��l�� ��s��t��r��i��p��e�� ��a��n��d�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��G��r��e��e��k�� ��c��a��p��i��t��a��l�� ��l��e��t��t��e��r�� ��U��p��s��i��l��o��n�� ��(��U��+�
 �3��A��5��)��:�� ��T��h��i��n�� ��v��e��r��t��i��c��a��l�� ��s��t��r��i��p��e�� ��a��n��d�� ��f��u��l��l�� ��a��d��v��a��n��c��e��;�� ��"~\xB5��"�� ��(��U��+��7��E��B��5��)��:�� ��T��h��i��n�� ��v��e��r��t��i��c��a��l�� ��s��t��r��i��p��e�� ��a��n��d�� ��f��u��l��l�� ��a��d��v��a��n��c��e��.��h��t��t��p��:��/��/��w��w��w��.��w��3��c��.��o��r��g��h��t��t��p��:��/��/��d��e��v��.��w��3��.��o��r��g��/��C��S��S��/��f��o��n��t��s��/��a��h��e��m��/��C��O��P��Y��I��N��G��
+��A��h��e��m��R��e��g��u��l��a��r��A��h��e��m������������������\xFF{��������������������������������������������K������������������	������+�������������������������������������� ��!��"��#��$��%��&��'��(��)��*��+��,��-��.��/��0��1��2��3��4��5��6��7��8��9��:��;��<��=��>��?��@��A��B��C��D��E��F��G��H��I��J��KNULLglyph243����
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/zero-width-shaping-font-mismatch-expected-mismatch.html (0 => 265455)


--- trunk/LayoutTests/fast/text/zero-width-shaping-font-mismatch-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/zero-width-shaping-font-mismatch-expected-mismatch.html	2020-08-10 21:51:58 UTC (rev 265455)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/zero-width-shaping-font-mismatch.html (0 => 265455)


--- trunk/LayoutTests/fast/text/zero-width-shaping-font-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/zero-width-shaping-font-mismatch.html	2020-08-10 21:51:58 UTC (rev 265455)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: WebFont;
+    src: url("resources/Ahem-zero-width-shaping-font-mismatch.ttf") format("truetype");
+}
+</style>
+</head>
+<body>
+<div style="font: 192px Times, WebFont">&#x2C95;i</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (265454 => 265455)


--- trunk/Source/WebCore/ChangeLog	2020-08-10 21:50:39 UTC (rev 265454)
+++ trunk/Source/WebCore/ChangeLog	2020-08-10 21:51:58 UTC (rev 265455)
@@ -1,3 +1,26 @@
+2020-08-10  Myles C. Maxfield  <[email protected]>
+
+        Shaping can be performed on glyphIDs from the wrong font
+        https://bugs.webkit.org/show_bug.cgi?id=215333
+
+        Reviewed by Darin Adler.
+
+        The problem is this line:
+        if (font != lastFontData && width)
+
+        This means we will only trigger shaping code if width is non-zero.
+        However, even if width is non-zero, we will still happily add glyphs
+        to the glyph buffer, and when we do eventually get around to shaping,
+        we shape all yet-unshaped glyphs, regardless of which font they came
+        from.
+
+        Test: fast/text/zero-width-shaping-font-mismatch.html
+
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::commitCurrentFontRange):
+        (WebCore::WidthIterator::advanceInternal):
+        * platform/graphics/WidthIterator.h:
+
 2020-08-10  Clark Wang  <[email protected]>
 
         Add AudioProcessingEvent Constructor

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (265454 => 265455)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2020-08-10 21:50:39 UTC (rev 265454)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2020-08-10 21:51:58 UTC (rev 265455)
@@ -166,6 +166,25 @@
     return std::make_pair(expandLeft, expandRight);
 }
 
+void WidthIterator::commitCurrentFontRange(GlyphBuffer& glyphBuffer, unsigned lastGlyphCount, const Font& font, UChar32 previousCharacter, const Font& primaryFont, UChar32 character, float widthOfCurrentFontRange, CharactersTreatedAsSpace& charactersTreatedAsSpace)
+{
+    auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
+    if (transformsType != TransformsType::None)
+        m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, font, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
+
+    if (widthOfCurrentFontRange && m_fallbackFonts && &font != &primaryFont) {
+        // FIXME: This does a little extra work that could be avoided if
+        // glyphDataForCharacter() returned whether it chose to use a small caps font.
+        if (!m_font.isSmallCaps() || character == u_toupper(character))
+            m_fallbackFonts->add(&font);
+        else {
+            auto glyphFont = m_font.glyphDataForCharacter(u_toupper(character), m_run.rtl()).font;
+            if (glyphFont != &primaryFont)
+                m_fallbackFonts->add(glyphFont);
+        }
+    }
+}
+
 template <typename TextIterator>
 inline void WidthIterator::advanceInternal(TextIterator& textIterator, GlyphBuffer& glyphBuffer)
 {
@@ -189,7 +208,7 @@
     UChar32 previousCharacter = 0;
     unsigned clusterLength = 0;
     CharactersTreatedAsSpace charactersTreatedAsSpace;
-    String normalizedSpacesStringCache;
+    float widthOfCurrentFontRange = 0;
     // We are iterating in string order, not glyph order. Compare this to ComplexTextController::adjustGlyphsAndAdvances()
     while (textIterator.consume(character, clusterLength)) {
         unsigned advanceLength = clusterLength;
@@ -223,26 +242,14 @@
             width *= m_run.horizontalGlyphStretch();
         }
 
-        if (font != lastFontData && width) {
-            auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
-            if (transformsType != TransformsType::None) {
-                m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, *lastFontData, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
-                glyphBuffer.shrink(lastGlyphCount);
-            }
-
+        if (font != lastFontData) {
+            commitCurrentFontRange(glyphBuffer, lastGlyphCount, *lastFontData, previousCharacter, primaryFont, character, widthOfCurrentFontRange, charactersTreatedAsSpace);
+            m_currentCharacterIndex = currentCharacterIndex;
+            lastGlyphCount = glyphBuffer.size();
             lastFontData = font;
-            if (m_fallbackFonts && font != &primaryFont) {
-                // FIXME: This does a little extra work that could be avoided if
-                // glyphDataForCharacter() returned whether it chose to use a small caps font.
-                if (!m_font.isSmallCaps() || character == u_toupper(character))
-                    m_fallbackFonts->add(font);
-                else {
-                    const GlyphData& uppercaseGlyphData = m_font.glyphDataForCharacter(u_toupper(character), rtl);
-                    if (uppercaseGlyphData.font != &primaryFont)
-                        m_fallbackFonts->add(uppercaseGlyphData.font);
-                }
-            }
-        }
+            widthOfCurrentFontRange = width;
+        } else
+            widthOfCurrentFontRange += width;
 
         if (hasExtraSpacing) {
             // Account for letter-spacing.
@@ -340,6 +347,9 @@
         previousCharacter = character;
     }
 
+    commitCurrentFontRange(glyphBuffer, lastGlyphCount, *lastFontData, previousCharacter, primaryFont, character, widthOfCurrentFontRange, charactersTreatedAsSpace);
+    m_currentCharacterIndex = textIterator.currentIndex();
+
     if (leftoverJustificationWidth) {
         if (m_forTextEmphasis)
             glyphBuffer.add(lastFontData->zeroWidthSpaceGlyph(), *lastFontData, leftoverJustificationWidth, m_run.length() - 1);
@@ -346,14 +356,6 @@
         else
             glyphBuffer.add(lastFontData->spaceGlyph(), *lastFontData, leftoverJustificationWidth, m_run.length() - 1);
     }
-
-    auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
-    if (transformsType != TransformsType::None) {
-        m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, *lastFontData, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
-        glyphBuffer.shrink(lastGlyphCount);
-    }
-
-    m_currentCharacterIndex = textIterator.currentIndex();
 }
 
 void WidthIterator::advance(unsigned offset, GlyphBuffer& glyphBuffer)

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (265454 => 265455)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.h	2020-08-10 21:50:39 UTC (rev 265454)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h	2020-08-10 21:51:58 UTC (rev 265455)
@@ -62,6 +62,7 @@
     enum class TransformsType { None, Forced, NotForced };
     TransformsType shouldApplyFontTransforms(const GlyphBuffer&, unsigned lastGlyphCount, UChar32 previousCharacter) const;
     float applyFontTransforms(GlyphBuffer&, bool ltr, unsigned& lastGlyphCount, const Font&, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&);
+    void commitCurrentFontRange(GlyphBuffer&, unsigned lastGlyphCount, const Font&, UChar32 previousCharacter, const Font& primaryFont, UChar32 character, float widthOfCurrentFontRange, CharactersTreatedAsSpace&);
 
     const FontCascade& m_font;
     const TextRun& m_run;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to