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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 13 06:27:32 PDT 2013


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





--- Comment #34 from Christophe Dumez <dchris at gmail.com>  2013-08-13 06:27:05 PST ---
(In reply to comment #33)
> Please comment on the below function "replaceHTMLSpace()", which can be used instead of the existing function "replaceCharacterInString()"
> 
> static void replaceHTMLSpace(String& text)
> {    
>     unsigned int textLength = text.length();
>     std::vector<char> charVector(textLength);
> 
>     unsigned int i=0;
>        while (i != textLength)
>        {
>                ch = text.characterStartingAt(i);
>         if (!isHTMLSpace(ch))
>             charVector[i] = ch;
>         else    
>             charVector[i] = ' ';
>         i++;
>         }
>     charVector[i] = '\0';
>     string tempText(charVector.begin(), charVector.end());
>     String finalText(tempText.c_str(),textLength);
>         text = finalText;
> }

A few comments comments:
- Looks like you could use a for loop.
- You can use String::adopt() to avoid copying the input Vector
- You don't handle vertical spaces anymore
- As Darin advised, you should not replace ' ' (U+0020) chars by ' '. The space matching function should return false for those
- Use a WTF::Vector<UChar>, not a std::vector<char>
- iirc Darin wanted to allocate memory only if there is at least 1 char that needs replacing
- You can use operator[] instead of characterStartingAt()

-- 
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