View Issue Details

IDProjectCategoryView StatusLast Update
0008589Multi Theft Auto : San AndreasScriptingpublic2015-07-26 02:33
ReporterFeche Assigned Tosbx320  
Status resolvedResolutionfixed 
Product Version1.1 
Target Version1.5Fixed in Version1.5 
Summary0008589: outputChatBox returns with space if using color codes

If you use true on 'colorCoded' argument you get a nice big space, I don't really know how to explain it, here is the code to reproduce it.. tested both client and server.

As you can see string is only 75 characters long, a picture is worth a thousand words:

Steps To Reproduce

outputChatBox("#80808011111111111111111111111111111111111111111111111111: #FFFFFFhiiiiiiii", root, 255, 255, 255, true)


TagsNo tags attached.


has duplicate 0008952 closed New issues outputChatBox wrong characters width when using colorcodes 



2015-06-28 11:09

administrator   ~~0023464

GetTextExtentPoint32W (used in CGraphics::GetDXTextExtent which in turn is used to determine the width of a to be colorfully printed substring) returns the amount of pixels in width and height required to display the substring. However GetTextExtendPoint32W does not consider font kerning.

Because some devices kern characters, the sum of the extents of the characters in a string may not be equal to the extent of the string.

Some information about font kerning can be found here :

I've fixed this issue by using DT_CALCRECT to get the exact width required to render the substring in


2015-07-15 15:09

manager   ~~0023610

Last edited: 2015-07-15 15:56

srun outputChatBox("#FF0000Test: #FFFFFFHello", root, 0, 0, 0, true)
In console there is 1 space, in chatbox there is 2 spaces (between Test: and Hello)

See the screenshot I've attached to this bug report: |#FFFFFF| Should look like || but it's looking like | |


2015-07-16 14:49

administrator   ~~0023627

It's not actually two spaces, but actually the width of an undescore (_) which is a bit more than a space. DT_CALCRECT ignores trailing spaces, so I needed something to substitue the space with. Not an optimal solution but it should work for most purposes.

Properly fixing this is a likely to be a bit more complicated.


2015-07-16 16:56

manager   ~~0023630

Can't you use the width of - instead of _?


2015-07-18 21:52

administrator   ~~0023682

ID3DXFont::DrawText docs says it modifies the rect. Not sure if it would make any difference, but we don't initialize rect.


2015-07-19 09:05

administrator   ~~0023691

It looks like moving trailing spaces to the front improves width calculation


2015-07-26 02:33

administrator   ~~0023720

Moving spaces to the front caused issues when passing a space-only string.

Issue History

Date Modified Username Field Change