Font Colours not correct

  • Hi,

    When saving TWRichText content to HTML, any text formatted as red or yellow is being converted to blue. For example, using MyText.SaveToFile('c:\myText.html', False, 'HTML'); produces incorrect colours. Has anything changed in recent versions? We upgraded to v9.4.2.0 recently, and earlier versions did not show this behaviour.

    The HTML page source is below:

    --></style></head><body>
    <div class="emptypar">&nbsp;</div>
    <div class="emptypar">&nbsp;</div>
    <div><span style="color:Blue;font-family:'Calibri';font-size:11.00pt;">red</span></div>
    <div><span style="color:Aqua;font-family:'Calibri';font-size:11.00pt;">yellow</span></div>
    <div><span style="color:#00FF00;font-family:'Calibri';font-size:11.00pt;">green</span></div>
    <div><span style="color:#0000FF;font-family:'Calibri';font-size:11.00pt;">blue</span></div>
    <div><span style="font-family:'Calibri';font-size:11.00pt;">black</span></div>
    </body></html>

    We are using the WPToolbar along with WPRichText.

    • Official Post

    I found the reson for this problem -

    Please paste this function right at the start of implementation in
    unit WPIOHTML and it should work:

    function WPColorToString(Color: TColor): string;
    var
    rgb : Cardinal;
    begin
    if Color = clNone then Result:='transparent'
    else
    begin
    rgb := ColorToRGB(Color);
    Result := Format('#%.2x%.2x%.2x',
    [GetRValue(rgb), GetGValue(rgb), GetBValue(rgb)]);
    end;
    end;