unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andy Moreton <andrewjmoreton@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Replace XChar2b with unsigned in all font backends
Date: Wed, 22 May 2019 00:04:01 +0100	[thread overview]
Message-ID: <86tvdnmmu6.fsf@gmail.com> (raw)
In-Reply-To: 8736l7v6hy.fsf@gmail.com

On Tue 21 May 2019, Alex Gramiak wrote:

> martin rudalics <rudalics@gmx.at> 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	other threads:[~2019-05-21 23:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20  8:26 Replace XChar2b with unsigned in all font backends martin rudalics
2019-05-20 12:05 ` Andy Moreton
2019-05-20 18:14   ` Alex Gramiak
2019-05-20 18:29     ` Andy Moreton
2019-05-20 19:20       ` Eli Zaretskii
2019-05-20 22:52         ` Andy Moreton
2019-05-21  8:00           ` Eli Zaretskii
2019-05-21 11:50             ` Andy Moreton
2019-05-21 12:38               ` Eli Zaretskii
2019-05-20 19:34       ` Alex Gramiak
2019-05-20 18:07 ` Alex Gramiak
2019-05-21  7:33   ` martin rudalics
2019-05-21 21:32     ` Alex Gramiak
2019-05-21 23:04       ` Andy Moreton [this message]
2019-05-22  8:30       ` martin rudalics
2019-05-21 11:47   ` Andy Moreton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86tvdnmmu6.fsf@gmail.com \
    --to=andrewjmoreton@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).