Closed Bug 1769965 Opened 4 years ago Closed 4 years ago

`context-value` stroke attributes in SVG glyphs are handled incorrectly

Categories

(Core :: SVG, defect)

defect

Tracking

()

RESOLVED FIXED
102 Branch
Tracking Status
firefox102 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

Details

Attachments

(3 files)

When an SVG-in-OpenType glyph uses the context-value keyword for stroke properties such as stroke-width, the resulting value is computed incorrectly depending on the device-pixel scale of the context.

Testcase: from a local mozilla-central checkout, load the two files

layout/reftests/text-svgglyphs/svg-glyph-objectvalue.svg
layout/reftests/text-svgglyphs/svg-glyph-objectvalue-ref.svg

These should render four squares with dashed borders, and the two files should render identically. These are SVG glyphs found in the test font's SVG table; the four glyphs are encoded as 'a' through 'd':

    <svgDoc endGlyphID="71" startGlyphID="68">
      <![CDATA[<svg xmlns="http://www.w3.org/2000/svg">
<!--
    Test SVG glyphs for text object stroke value inheritance
    Covers glyph ID range 68 (a) to 71 (d)
-->
  <!-- a -->
  <rect x="100" y="-900" width="800" height="800" stroke="powderblue"
    stroke-width="50" stroke-dashoffset="35"
    stroke-dasharray="50 50" id="glyph68" />

  <!-- b -->
  <rect x="100" y="-900" width="800" height="800" stroke="chartreuse"
    stroke-width="50" stroke-dashoffset="35"
    stroke-dasharray="context-value" id="glyph69" />

  <!-- c -->
  <rect x="100" y="-900" width="800" height="800" stroke="sienna"
    stroke-width="50" stroke-dasharray="50 50"
    stroke-dashoffset="context-value" id="glyph70" />

  <!-- d -->
  <rect x="100" y="-900" width="800" height="800" stroke="olivedrab"
    stroke-width="context-value" stroke-dasharray="context-value"
    stroke-dashoffset="context-value" id="glyph71" />
</svg>
]]>
    </svgDoc>

On a display with 100% scaling (devicePixelRatio = 1.0), the test document does indeed match the reference file.

However, on a Mac retina (200%) display, or a Windows display with scaling > 100%, the borders of the glyphs where context-value is used vary in their dashing and/or width, because the context-value is evaluated incorrectly.

This error can also be seen even on a low-dpi (100% scaling) display by simply zooming the document. As the display is zoomed in (and so the CSS-to-devicePixel ratio changes), the dashing of the three test squares progressively changes.

This makes the context-value option for stroke width and dash properties in SVG glyphs work
consistently in non-1.0 devicePixelRatio situations (e.g. browser zoom, high-dpi displays).

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

This checks for CSS-vs-devicePixel confusion when setting "context-value" properties
for the stroke.

Depends on D146886

Attachment #9277433 - Attachment description: Bug 1769965 - Convert stroke properties (width, dashes) to device pixels when passing them to the gfxContext. r=#gfx-reviewers → Bug 1769965 - Convert stroke properties (width, dashes) to device pixels when passing them to the gfxContext. r=emilio
Attachment #9277434 - Attachment description: Bug 1769965 - Run the svg-glyph-objectvalue reftest at several different devicePixelRatio settings. r=#gfx-reviewers → Bug 1769965 - Create copies of the svg-glyph-objectvalue reftest with different zoom levels. r=emilio
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7fafe3b74c95 Convert stroke properties (width, dashes) to device pixels when passing them to the gfxContext. r=emilio https://hg.mozilla.org/integration/autoland/rev/27060af60766 Create copies of the svg-glyph-objectvalue reftest with different zoom levels. r=emilio

Backed out for causing reftest failures on svg-glyph-objectvalue.svg

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: REFTEST TEST-UNEXPECTED-FAIL | layout/reftests/text-svgglyphs/svg-glyph-objectvalue.svg != layout/reftests/text-svgglyphs/svg-glyph-objectvalue-75.svg | image comparison, max difference: 0, number of differing pixels: 0
Flags: needinfo?(jfkthame)
Severity: -- → S3

The failure appears only on the reftest-snapshot job, which apparently doesn't respect reftest-zoom. I'll annotate it as failing there.

Flags: needinfo?(jfkthame)
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6f75b115c177 Convert stroke properties (width, dashes) to device pixels when passing them to the gfxContext. r=emilio https://hg.mozilla.org/integration/autoland/rev/bd92b2280e0d Create copies of the svg-glyph-objectvalue reftest with different zoom levels. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: