[PATCH v2 8/8] d3dx9: Implement ID3DXFont_DrawText.

Nikolay Sivov nsivov at codeweavers.com
Thu Jan 23 04:36:52 CST 2020


On 1/22/20 7:14 PM, Matteo Bruni wrote:
> On Mon, Jan 6, 2020 at 3:36 PM Sven Baars <sbaars at codeweavers.com> wrote:
>
>> +/* DrawText helpers copied from user32 */
>> +#define TAB     9
>> +#define LF     10
>> +#define CR     13
>> +#define SPACE  32
>> +static void TEXT_WordBreak(HDC hdc, WCHAR *str, unsigned int max_str,
>> +                           unsigned int *len_str,
>> +                           int width, int format, unsigned int chars_fit,
>> +                           unsigned int *chars_used, SIZE *size)
> As I already mentioned in a private email a while back, I don't think
> copying whole chunks of user32 is going to be a good idea.
>
> ID3DXFont's DrawText is supposed to be quite a bit simpler than the
> user32 counterpart. I imagine that it should be possible to
> reimplement the required features without carrying this much stuff
> over. Maybe Uniscribe can help more, I don't know the API (Nikolay?)
The reason it's exploded like that is because you need access to glyph 
sequence + positions at the end,
to render from glyph-indexed cache. As far as I can tell it should at 
least support multiple lines.

Uniscribe is lower level, it won't do such layout for you, and that's 
why existing DrawText has line breaking logic,
while using Uniscribe.

There is a way with minimal or potentially no duplication of formatting 
code - you can use regular DrawTextExW()
enhanced metafile context. This will create a number of EXTTEXTOUT 
records that could be iterated over and rendered.
Each record should contain glyph ids, and positions. This way you don't 
have to deal with formatting at all.

>
> Either way, I'd initially introduce a simpler DrawText implementation
> (no line breaks, no word breaks, as bare-bones as possible) and then
> proceed to add features incrementally over a number of patches. That
> will also make the initial DrawText patch easier to review.
>




More information about the wine-devel mailing list