Hi, I'm getting strange and unreliable results when querying text extents for proportional fonts. (I have no issues with monospace fonts.)<div><br></div><div>The overall_width that's returned is often a few pixels larger than what it should be. It seems like XCB is assuming all characters in a string are the same pixel width, which will give wrong results if you use a proportional font with "slim" characters like 'i', '1', '/', '(', etc.</div>
<div><br></div><div>However, this could very likely be an issue with how I'm setting up the xcb_char2b_t that I send to xcb_query_text_extents().</div><div><br></div><div><div>xcb_char2b_t *build_chars(char *str, int length)</div>
<div>{</div><div> xcb_char2b_t *ret = malloc(length * sizeof(xcb_char2b_t));</div><div> int i;</div><div> </div><div> for (i = 0; i < length; i++) {</div><div> if (str[i] < length) {</div>
<div> ret[i].byte1 = str[i];</div><div> ret[i].byte2 = '\0';</div><div> }</div><div> }</div><div> </div><div> return ret;</div><div>}</div>
<div><br></div><div>Parameter "str" is the string I want extents on, obviously, and "length" woud be strlen(str). Is this how I should be going about it?</div></div>