From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Add a function that returns pixel distance between points? Date: Sun, 31 Jan 2021 00:17:58 -0500 Message-ID: <1EDD0FA5-025C-4A87-BBA1-7B8944E91A12@gmail.com> References: <960DAE7C-A1AF-416A-ACA5-F6674C87A2C9@gmail.com> <837dnt9400.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.40.0.2.32\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9709"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jan 31 06:19:02 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l658Y-0002QO-T4 for ged-emacs-devel@m.gmane-mx.org; Sun, 31 Jan 2021 06:19:02 +0100 Original-Received: from localhost ([::1]:54220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l658X-0006lQ-Vk for ged-emacs-devel@m.gmane-mx.org; Sun, 31 Jan 2021 00:19:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l657c-0006Jr-9P for emacs-devel@gnu.org; Sun, 31 Jan 2021 00:18:04 -0500 Original-Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]:43538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l657a-0000BE-KJ; Sun, 31 Jan 2021 00:18:04 -0500 Original-Received: by mail-qv1-xf33.google.com with SMTP id j13so6591716qvu.10; Sat, 30 Jan 2021 21:18:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=I17Wsi2wTnGIZ1rG+/oM4VxtB69c8jO/upCTtjfY9JU=; b=q+fQOWEKxBqg7faVKOwSysedWn8Yd650zHiiCVxzLyOUwtkp8HNVh1+VtIi6qFkVDf JFJyjoLN9IjmErZwdTJ7Y7rQS7oqm5z2PLAf7SlMDQrZfwdKy13UHAFArCgJZzGhn8ZU 7vBYfzTimsq9Sj3nPSHDUKuO3qQdLQ8emxNNx00aOdh7sghpUFgysSxdwIkFazJ5nsN0 WDyCWaECf6oaIFfS8aaL9JyV6BqXUpC292M5bdq7eZuFzKpxqX1NML8qfSslFYJighjj x7EwjZjtVde9KShHfo3bpFRAeaKKkF3FOix3oNxzWaYlhWq9/DGekLpZrMl6J2ehdIkd UbRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=I17Wsi2wTnGIZ1rG+/oM4VxtB69c8jO/upCTtjfY9JU=; b=q3eT4VdrEZ3nPO1X+oCodoPVF4qz9poMRzhCmL/r79CIuAlHL5/U98nl+drY4Glitg vaU8mSMdiEK86CsTliWsx2fYrRQ4TT+qiaS9uTNJjLyomxmfMIpPNJdXecvEchrtIjqc M+h3cPvTZrrSjPS36+uUH3I8Mht10mogwnWiUF4ATVn8OI01+/P2IU5obBIsJLDdoVRS xaWVo3jwNIzUGgSKAe9ULEhlICYYMegV+0KNHKm/bEF20Q6tTZJaFP3EQo50csUxjP0V rT9fcSANzKFeVrsnz7bsO02y0lK702sIrn41huVJ4p4NkF4+BEJrDSALk288AWPgzHnP 8zrA== X-Gm-Message-State: AOAM533lnEmglOaIfJz7fnrL5Ky2R+YDMLWAmnjO76A4sJVROhtcbGia o/qW3Czf9jhQ2uBdasCNRyj2x88bSohBbQ== X-Google-Smtp-Source: ABdhPJxcsya5Li5eDxCmsWotkQickmeWSRR35Pt8p+oRxgopGuvoAjS7h7ma47rzsMzSdBh2kxDHcg== X-Received: by 2002:a05:6214:592:: with SMTP id bx18mr10566464qvb.32.1612070280776; Sat, 30 Jan 2021 21:18:00 -0800 (PST) Original-Received: from ?IPv6:2601:98a:4200:9210:d580:9ad5:a27e:26fc? ([2601:98a:4200:9210:d580:9ad5:a27e:26fc]) by smtp.gmail.com with ESMTPSA id r54sm10719909qtr.70.2021.01.30.21.17.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Jan 2021 21:18:00 -0800 (PST) In-Reply-To: <837dnt9400.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.40.0.2.32) Received-SPF: pass client-ip=2607:f8b0:4864:20::f33; envelope-from=casouri@gmail.com; helo=mail-qv1-xf33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:263651 Archived-At: >> For aligning text according to their display size, I need to = calculate the width of some text. Currently I=E2=80=99m using = window-text-pixel-size, but it has some problem: if the text I=E2=80=99m = measuring has line-prefix or wrap-prefix, the size returned will include = the width of the prefix. So if the prefix is 14 pixels wide and the text = is 7 pixels wide, the returned value is 21 instead of 7. Line number = width is sometimes included in the result and sometimes not. >>=20 >> There is also posn-at-point but that requires the point to be visible = in the window. My alignment function wants to run in jit-lock so point = is not always visible, so I can=E2=80=99t use posn-at-point. >=20 > Please explain what you mean by "align text according to display > size". It isn't clear what you want to accomplish, and therefore the > full set of requirements and restrictions is not evident, which makes > it hard to provide useful advice. Sorry for that. I want to align text-based tables by pixel size, as in: | header | header | header | | 1 | 1 | 8 | | 2 | 6 | 3 | When the text is displayed in variable-pitch font, the bars aren=E2=80=99t= aligned. I=E2=80=99m using display property (space :align-to) to align = those bars. To know with pixel position to align to, I need to calculate = each column=E2=80=99s pixel width, and met the difficulties mentioned = earlier. Yuan=