[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:32:06 PDT 2013


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





--- Comment #35 from Rashmi Shyamasundar <rashmi.s2 at samsung.com>  2013-08-13 06:31:40 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;
> }
> 
> 
> As suggested by Mr. Darin Adler, the above approach avoids the expensive memory re-allocations unlike the function replaceCharacterInString().

Re-wrote the function replaceHTMLSpace() as below :-

static void replaceHTMLSpace(String& text)
{    
    unsigned int textLength = text.length();
    const UChar *textArray = text.characters();
    UChar *finalTextArray = new UChar[textLength];

    UChar ch;
    unsigned int i=0;
       while (i != textLength)
       {
           ch = textArray[i];
        if (!isHTMLSpace(ch))
            finalTextArray[i] = ch;
        else    
            finalTextArray[i] = ' ';
        i++;
        }

    String finalText(finalTextArray, textLength);
    text = finalText;

}

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