Bug 676178 - Scale stroke dashes to text size properly. r=jwatt

This commit is contained in:
Robert Longson 2012-01-16 15:36:25 +00:00
parent 61fbc9c6dc
commit 00866bc80f
4 changed files with 31 additions and 2 deletions

View File

@ -235,6 +235,7 @@ fails-if(Android) random-if(gtk2Widget) != text-language-01.xhtml text-language-
== text-scale-01.svg text-scale-01-ref.svg
== text-stroke-scaling-01.svg text-stroke-scaling-01-ref.svg
== stroke-dasharray-and-pathLength-01.svg pass.svg
== stroke-dasharray-and-text-01.svg stroke-dasharray-and-text-01-ref.svg
== stroke-linecap-square-w-zero-length-segs-01.svg pass.svg
== stroke-linecap-square-w-zero-length-segs-02.svg pass.svg
== textPath-01.svg textPath-01-ref.svg

View File

@ -0,0 +1,10 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<title>Test stroke-dasharray with text and zooming</title>
<g fill="none" stroke-width="2" stroke="black" stroke-dasharray="20">
<text font-size="100" x="100" y="100">|</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 357 B

View File

@ -0,0 +1,10 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg" reftest-zoom="2">
<title>Test stroke-dasharray with text and zooming</title>
<g fill="none" stroke-width="1" stroke="black" stroke-dasharray="10">
<text font-size="50" x="50" y="50">|</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 371 B

View File

@ -137,8 +137,16 @@ public:
* We are scaling the glyphs up/down to the size we want so we need to
* inverse scale the outline widths of those glyphs so they are invariant
*/
void SetLineWidthForDrawing(gfxContext *aContext) {
void SetLineWidthAndDashesForDrawing(gfxContext *aContext) {
aContext->SetLineWidth(aContext->CurrentLineWidth() / mDrawScale);
AutoFallibleTArray<gfxFloat, 10> dashes;
gfxFloat dashOffset;
if (aContext->CurrentDash(dashes, &dashOffset)) {
for (PRUint32 i = 0; i < dashes.Length(); i++) {
dashes[i] /= mDrawScale;
}
aContext->SetDash(dashes.Elements(), dashes.Length(), dashOffset / mDrawScale);
}
}
/**
@ -546,7 +554,7 @@ void
nsSVGGlyphFrame::AddCharactersToPath(CharacterIterator *aIter,
gfxContext *aContext)
{
aIter->SetLineWidthForDrawing(aContext);
aIter->SetLineWidthAndDashesForDrawing(aContext);
if (aIter->SetupForDirectTextRunDrawing(aContext)) {
mTextRun->DrawToPath(aContext, gfxPoint(0, 0), 0,
mTextRun->GetLength(), nsnull, nsnull);