[PATCH 2/2] [v4] user32: Implement EC_USEFONTINFO margins in the CJK case.

Huw Davies huw at codeweavers.com
Wed Mar 27 10:48:15 CDT 2019


On Wed, Mar 27, 2019 at 10:25:48PM +0900, Akihiro Sagawa wrote:
> Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
> ---
>  dlls/user32/edit.c       | 91 ++++++++++++++++++++++++++++++++++++++++++++++--
>  dlls/user32/tests/edit.c |  4 +--
>  2 files changed, 90 insertions(+), 5 deletions(-)
> 

> diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
> index d1659b4..c0cb056 100644
> --- a/dlls/user32/edit.c
> +++ b/dlls/user32/edit.c
> @@ -2842,6 +2842,70 @@ static void EDIT_EM_SetLimitText(EDITSTATE *es, UINT limit)
>  }
>  
>  
> +static BOOL is_cjk_charset(HDC dc)
> +{
> +    switch (GdiGetCodePage(dc)) {
> +    case 932: case 936: case 949: case 950: case 1361:
> +        return TRUE;
> +    default:
> +        return FALSE;
> +    }
> +}
> +
> +#ifdef WORDS_BIGENDIAN
> +#define GET_BE_WORD(x) (x)
> +#else
> +#define GET_BE_WORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
> +#endif
> +
> +#define MS_MAKE_TAG(ch0, ch1, ch2, ch3)                               \
> +                    ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
> +                    ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
> +
> +static BOOL get_side_bearings(HDC hdc, short *min_lsb, short *min_rsb)
> +{
> +    const DWORD hhea_tag = MS_MAKE_TAG('h','h','e','a');
> +#include "pshpack2.h"
> +    struct {
> +        unsigned short majorVersion;
> +        unsigned short minorVersion;
> +        short ascender;
> +        short descender;
> +        short lineGap;
> +        unsigned short advanceWidthMax;
> +        short minLeftSideBearing;
> +        short minRightSideBearing;
> +        short xMaxExtent;
> +        short caretSlopeRise;
> +        short caretSlopeRun;
> +        short caretOffset;
> +        short reserved[4];
> +        short metricDataFormat;
> +        short numberOfHMetrics;
> +    } hhea_table;
> +#include "poppack.h"
> +    LONG size;
> +
> +    size = GetFontData(hdc, hhea_tag, 0, &hhea_table, sizeof(hhea_table));
> +    if (size != sizeof(hhea_table))
> +        return FALSE;
> +    *min_lsb = GET_BE_WORD(hhea_table.minLeftSideBearing);
> +    *min_rsb = GET_BE_WORD(hhea_table.minRightSideBearing);
> +    return TRUE;
> +}

The undocumented gdi32 export GetCharWidthInfo() could help here.
Its prototype seems to be:

struct width_info
{
    INT lsb;
    INT rsb;
    INT unknown;
};

INT WINAPI GetCharWidthInfo(HDC hdc, struct width_info *info);

You'd first want to implement and write tests for this in gdi32.

Huw.



More information about the wine-devel mailing list