[Webkit-unassigned] [Bug 108881] Canvas fillText and measureText handle ideographic spaces differently

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Aug 16 06:39:53 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=108881





--- Comment #41 from Christophe Dumez <dchris at gmail.com>  2013-08-16 06:39:24 PST ---
(In reply to comment #40)
> (In reply to comment #39)
> > Please comment on below piece of code :-
> > 
> > static void normalizeSpaces(String& text)
> > {
> >     unsigned textLength = text.length();
> > 
> >     unsigned i = 0;
> >     for (; i != textLength; ++i) {
> >         if (spaceNeedsReplacing(text[i]))
> >             break;
> >     }
> > 
> >     if (i == textLength)
> >         return;
> > 
> >     WTF::Vector<UChar> charVector(textLength);

N WTF:: is not needed.

> >     memcpy(&charVector, &text, i * sizeof(UChar));

If you use String::charactersWithNullTermination(), you won't need to memcpy.

> >     charVector[i] = ' ';
> >     ++i;
> > 
> >     for (; i != textLength; ++i) {
> >         if (spaceNeedsReplacing(text[i]))
> >             charVector[i] = ' ';
> >         else
> >             charVector[i] = text[i];
If you use String::charactersWithNullTermination() you only need to replace spaces, no write non-spaces.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list