| 1 | <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"> |
| 2 | <rect width="100%" height="100%" fill="white"/> |
| 3 | |
| 4 | <g transform="matrix(2 0 0 3 100 136)"> |
| 5 | <!-- Explanation of the transform above: |
| 6 | |
| 7 | The bug is about text-anchor="middle" not working properly when there is a |
| 8 | transform with scaling. |
| 9 | |
| 10 | So, we create a transform with horizontal scaling 2, and vertical scaling 3. |
| 11 | Then we translate by 100 pixels horizontally (200/2 of the viewBox width), and |
| 12 | 136 pixels vertically, because of the following: |
| 13 | |
| 14 | In the Ahem font, each glyph is a square - https://web-platform-tests.org/writing-tests/ahem.html |
| 15 | |
| 16 | The ascent above the baseline is 0.8em, and the descent below the baseline |
| 17 | is 0.2em. So, at font-size=40 it means the top is 0.8*40 = 32 units above the baseline. Since |
| 18 | the vertical scaling factor is 3, we translate by 32*3=96 pixels in the Y axis, plus an additional |
| 19 | (200 - (40 * 3)) / 2 = 40 pixels, thus adding up to the 136 pixels in the transform above. |
| 20 | |
| 21 | The vertical translation will center the glyph vertically in the available space. |
| 22 | |
| 23 | The bug is about the glyph not being horizontally centered in the available space. |
| 24 | --> |
| 25 | <text x="0" y="0" fill="black" font-family="Ahem" font-size="40" text-anchor="middle">W</text> |
| 26 | </g> |
| 27 | </svg> |