From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.help Subject: Re: How to get the actual face attribute? Date: Mon, 22 Jun 2020 13:21:15 -0400 Message-ID: <41A32155-634A-4D5A-A878-2F92E6761917@gmail.com> References: <60C41409-88B0-4F21-AC6D-2F18394A7C46@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="115662"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org, Stefan Monnier To: Perry Smith Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 22 19:22:14 2020 Return-path: Envelope-to: geh-help-gnu-emacs@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 1jnQ98-000TSD-Kf for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 22 Jun 2020 19:22:14 +0200 Original-Received: from localhost ([::1]:35958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jnQ8n-0006hR-OZ for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 22 Jun 2020 13:21:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jnQ8G-0006fa-7z for help-gnu-emacs@gnu.org; Mon, 22 Jun 2020 13:21:20 -0400 Original-Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:46273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jnQ8E-0005Qu-45 for help-gnu-emacs@gnu.org; Mon, 22 Jun 2020 13:21:19 -0400 Original-Received: by mail-qv1-xf32.google.com with SMTP id cv17so8286177qvb.13 for ; Mon, 22 Jun 2020 10:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=S4iFiGE9p+/2g3f6aBaWn5H3z0ZOsbUEIDCdrNph+1s=; b=KqXpPZnKJGrF54ITTtqeZZF0eKuvoommpACrnQm+SWR2pgIqA2ohWgyhxcpGezSfp8 H7XKJEbKgRNXvrMKbinal0BEVKTqlywRN2rdc89evcCAEwuAzzxTy+eOZTO30hFhdO+R 3OI1rjYaqhvj+K4L44UZFKUQ8G2tkqAGcquI4329GCzNtg/XQpMqvBUZLSUzYrIMh0oA B/HVGPkcdU1wpdqVBSCasjH/Dzo5yUR/WAPHHakZblVvBjzBr3QZcwhnXUT4/QvRA+ZQ VWCVlveF1i++aPqLaZukiLfM++tiZrcWCXRNzqX62cUhexjIVqKy91cnWDN6on7MgXGe H55Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=S4iFiGE9p+/2g3f6aBaWn5H3z0ZOsbUEIDCdrNph+1s=; b=jbtMMVLMrTvw/YcgcWrGQr5DzFJwMd9bvhEsQlXz5f973hUEw7T6JXDsImdU2U9tl4 i0dpN0Z/oqeXeT2NE9EBdMDufXF8tILVj4zQ7Wfx4QXlhAIqt8LydYH3YsCJGJUJOhb5 ZzKtbcIBBhxLNu3y0U3q6MPVD38C0+r56+rbZ1fgDWTy9h2VIVTXN+zQw70jx95pNunS HkZo2RwFMM7363ZBDQqCgX3SevIjaSxvZFm4IOHEF23/AK1IU0YPD61TwImNjDVFNIxn oDQpZP0uaVdQTiheWA8ZItJYxLfJOszEyhSMGQOUNsIKmrfaKBUj4/H/CA4KhS4QCKcX xmng== X-Gm-Message-State: AOAM533S+bXrNrJUFUuWnM+Qp9WSTfkE4aNqx67xaigt5FsDcmuDzlT5 fnAhlgYWKLH4BCs7yu0dluiJe1YeqcLEAg== X-Google-Smtp-Source: ABdhPJwy5nVMjh80M+yIEPco7gN5wIEXGVEP0UayN//ipGl6Nes/OSldD7YLaFIFrLb+EziH5fc6Dw== X-Received: by 2002:a0c:a9db:: with SMTP id c27mr10763296qvb.204.1592846476895; Mon, 22 Jun 2020 10:21:16 -0700 (PDT) Original-Received: from ?IPv6:2601:98a:4200:9210:657c:e0bd:67cd:c97? ([2601:98a:4200:9210:657c:e0bd:67cd:c97]) by smtp.gmail.com with ESMTPSA id c189sm15035455qkb.8.2020.06.22.10.21.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2020 10:21:16 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3608.80.23.2.2) Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=casouri@gmail.com; helo=mail-qv1-xf32.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DC_PNG_UNO_LARGO=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:123419 Archived-At: > On Jun 22, 2020, at 1:15 PM, Perry Smith = wrote: >=20 >=20 >=20 >> On Jun 22, 2020, at 12:00 PM, Yuan Fu > wrote: >>=20 >>=20 >>=20 >>> On Jun 21, 2020, at 11:54 AM, Stefan Monnier = wrote: >>>=20 >>>> When writing my package I need to get height of the face at point. >>>=20 >>> Note that there may be simultaneously several different such heights = if >>> point is shown simultaneously in different frames. >>>=20 >>=20 >> Thanks. Unfortunately I think I asked an x-y question. What I really = want to know is the width of the glyph and I thought I can just multiply = the height factor to the original width of the glyph. It seems not to be = the case. The multiplied result doesn=E2=80=99t match with the width on = glass. More precisely :height * glyph width !=3D posn of point after - = posn of point. Is this expected? >>=20 >> Also I can=E2=80=99t use posn for calculation since sometimes the = text might not be on screen.=20 >=20 > It might help to explain what the bigger objective is. I have a package that aligns org tables even for variable pitch text, = CJK text, images, etc are in the table: Some one reported that when they change the text size with = text-scale-adjust, the alignment are messed up. That=E2=80=99s because = the package aligns by calculating the pixel width of each cell, and when = the text size are adjusted that width is no accurate anymore. I=E2=80=99m = using this function to calculate the width of a glyph (which adds up to = the width of a cell): (let* ((p (or point (point)))) (if (eq (char-after point) ?\t) (valign--tab-width (font-at p)) ;; (font-at 0 nil (buffer-substring p (1+ p))) doesn=E2=80=99t = work, the ;; font is sometimes wrong. (font-at p) doesn=E2=80=99t work, = because ;; it requires the buffer to be visible. (aref (aref (font-get-glyphs (font-at p) p (1+ p)) 0) 4))) Yuan