emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace XChar2b with unsigned in all font backends


From: Andy Moreton
Subject: Re: Replace XChar2b with unsigned in all font backends
Date: Wed, 22 May 2019 00:04:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.50 (windows-nt)

On Tue 21 May 2019, Alex Gramiak wrote:

> martin rudalics <address@hidden> writes:
>
>>> Does the following diff work for you?
>>
>> The warnings go away but characters are still displayed as empty
>> boxes.
>
> Right, that's not unexpected since I made a flub on that patch and
> didn't multiply by sizeof (wchar_t) (I posted a version that fixed that
> in another message but didn't CC you, sorry).
>
> Here's a third version that uses SAFE_NALLOCA instead:
>
> diff --git a/src/w32font.c b/src/w32font.c
> index bd68e22cc9..08d0f370bf 100644
> --- a/src/w32font.c
> +++ b/src/w32font.c
> @@ -704,11 +704,21 @@ w32font_draw (struct glyph_string *s, int from, int to,
>        int i;
>  
>        for (i = 0; i < len; i++)
> -     ExtTextOutW (s->hdc, x + i, y, options, NULL,
> -                  s->char2b + from + i, 1, NULL);
> +        {
> +          const wchar_t ch = s->char2b[from + i];
> +          ExtTextOutW (s->hdc, x + i, y, options, NULL, &ch, 1, NULL);
> +        }
>      }
>    else
> -    ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, len, NULL);
> +    {
> +      USE_SAFE_ALLOCA;
> +      wchar_t *str;
> +      SAFE_NALLOCA (str, 1, len);
> +      for (int i = 0; i < len; ++i)
> +        str[i] = s->char2b[from + i];
> +      ExtTextOutW (s->hdc, x, y, options, NULL, str, len, NULL);
> +      SAFE_FREE ();
> +    }
>  
>    /* Restore clip region.  */
>    if (s->num_clips > 0)

This seems much better: no more mojibake, and `view-hello-file' works.

Thanks,

    AndyM




reply via email to

[Prev in Thread] Current Thread [Next in Thread]