[PATCH] gdi32: Implement GetCharWidthFloat().

Zebediah Figura z.figura12 at gmail.com
Wed Oct 16 10:01:49 CDT 2019


On 10/16/2019 05:23 AM, Huw Davies wrote:
> On Thu, Sep 26, 2019 at 09:17:03AM -0500, Zebediah Figura wrote:
>> diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
>> index b57effd349d..ccae09edc19 100644
>> --- a/dlls/gdi32/tests/font.c
>> +++ b/dlls/gdi32/tests/font.c
>> @@ -7189,6 +7189,51 @@ static void test_GetCharWidthInfo(void)
>>      ReleaseDC(NULL, hdc);
>>  }
>>  
>> +static int CALLBACK get_char_width_proc(const LOGFONTA *lf,
>> +        const TEXTMETRICA *tm, DWORD type, LPARAM ctx)
>> +{
>> +    HFONT font = CreateFontIndirectA(lf);
>> +    HDC dc = GetDC(NULL);
>> +    const char c = 'm';
>> +    ABCFLOAT abcf;
>> +    int i, i32;
>> +    BOOL ret;
>> +    float f;
>> +    ABC abc;
>> +
>> +    SelectObject(dc, font);
>> +
>> +    ret = GetCharWidthFloatA(dc, c, c, &f);
>> +    ok(ret, "%s: GetCharWidthFloat() failed\n", lf->lfFaceName);
>> +    ret = GetCharWidth32A(dc, c, c, &i32);
>> +    ok(ret, "%s: GetCharWidth32A() failed\n", lf->lfFaceName);
>> +    ret = GetCharWidthA(dc, c, c, &i);
>> +    ok(ret, "%s: GetCharWidthA() failed\n", lf->lfFaceName);
>> +    ok(i == i32, "%s: mismatched widths %d/%d\n", lf->lfFaceName, i, i32);
>> +    ok((float)i / 16.0f == f, "%s: mismatched widths %d/%.8e\n", lf->lfFaceName, i, f);
>> +
> 
> This factor of sixteen is strange.  Is it perhaps possible that the
> selected font has a ppem of sixteen and that GetCharWidthFloat()
> returns widths as a fraction of the em square width?

It is strange, but as the tests imply, it remained true for me for every
font on my system. I didn't check the ppem, and it's possible they all
have 16, but on the other hand mintty has that factor hard-coded in [1].

[1] https://github.com/mintty/mintty/blob/master/src/wintext.c

> 
> Huw.
> 




More information about the wine-devel mailing list