From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.bugs Subject: bug#67533: SVG images confound position pixel measurements Date: Wed, 29 Nov 2023 15:31:43 -0500 Message-ID: <9B9C683E-B951-406E-98AA-32F4539B3FF7@gmail.com> References: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.200.91.1.1\)) 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="12913"; mail-complaints-to="usenet@ciao.gmane.io" To: 67533@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 29 21:33:07 2023 Return-path: Envelope-to: geb-bug-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 1r8RF3-0003Be-EM for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Nov 2023 21:33:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8REu-0005kM-46; Wed, 29 Nov 2023 15:32:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8REs-0005jz-PJ for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 15:32:54 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r8REs-0002pG-H8 for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 15:32:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r8REz-0007fM-Vt for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 15:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: JD Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Nov 2023 20:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67533 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170128993429397 (code B ref -1); Wed, 29 Nov 2023 20:33:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Nov 2023 20:32:14 +0000 Original-Received: from localhost ([127.0.0.1]:51542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8REE-0007e3-9t for submit@debbugs.gnu.org; Wed, 29 Nov 2023 15:32:14 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:52758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8REB-0007dp-Nz for submit@debbugs.gnu.org; Wed, 29 Nov 2023 15:32:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8RDy-0005XO-9N for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 15:31:58 -0500 Original-Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r8RDw-0002ke-MU for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 15:31:58 -0500 Original-Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5cce5075bd6so1871877b3.0 for ; Wed, 29 Nov 2023 12:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701289914; x=1701894714; darn=gnu.org; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=OOd53gl5399BOzBJSkbwDcJyiwOTLjm0t//bELvITtk=; b=b6uLp9xthbAHfOwaTlzi5eK431N1obNBgFXxkV8rYqDIwm79457CEOgaLPQ3FBE60m qipw9+9hSjG/YNHbCKqnoxsQRLBFNzvhkGyj5ruK7MR3+rW4Tb1OgeVRHwegYKErlJgN 62v3nh93EUq3kPYRcjKcd+1xVi6WmKCaKVI+sJrIz9W4rMDTdqEXATr3Kme04FslJ8x6 aNUD7WqSmuu0H5MbBw0RNkb8UQuUGWpeyBh8J1WdUz1wel7V2Ex0mfPnIxEhILJgCBXB NdFZyJErTZFoswz13jg7+RzF3bk3jXhk2LEx+KBQ4o36tH96dhN28nOsszqM64SKwJrO /sUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701289914; x=1701894714; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OOd53gl5399BOzBJSkbwDcJyiwOTLjm0t//bELvITtk=; b=wR3k3yjOomK7Os5824qY8ppyXZTyvN4iHNxl8tpfLxbMKO0C3RvNAAJ94E210P8IM3 zN43Fe2sxm2Zb2Z/FgFS5smZLP8fs3DD52rpVNd8+meAB0Ee5lYMu3M7erHKfSG5lL7t Ypl5kJRGW4nKbbOLNDyIOKPdRZ+3lQxcZC6qFQKDLf6ldJjywBT96hsmGXZEOTuzXEs4 9w3/+QCxg6wfaq7nmubenK9w6zA5fdPn1Z2NOXws3WX256YLWieMIL2t96EohwDiqLGw o9zzKk8y8NfcmyT2QyDaR68QZt0KyT2hZoY1td0EchdONzSwAfrKpZFgJMlSmlU07nDh eeKA== X-Gm-Message-State: AOJu0YyyZhZJUgim/t4r0KlsX8q1VrIEawXU14jKFdL8rfwosCDdttnF tMBgeow36tCrKg1FYj02qBoegOCV51I= X-Google-Smtp-Source: AGHT+IEIJeGjnkKvYFo+KluxjFHuSPNAJ/yt6VtvI41G3n+KeFldpVQATeBKXKgU/IXKhxyqw1zIOw== X-Received: by 2002:a81:ae26:0:b0:5ce:16cb:b709 with SMTP id m38-20020a81ae26000000b005ce16cbb709mr12964277ywh.25.1701289914631; Wed, 29 Nov 2023 12:31:54 -0800 (PST) Original-Received: from smtpclient.apple ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id dy19-20020a05690c271300b005ce039bf1ecsm4140347ywb.7.2023.11.29.12.31.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2023 12:31:54 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3774.200.91.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::112e; envelope-from=jdtsmith@gmail.com; helo=mail-yw1-x112e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275255 Archived-At: (As posted on emacs-devel) ++++++++++++++++++++++ In developing a new pixel-precise smooth scrolling mode, I=E2=80=99ve = noticed that inline SVG images confuse Emacs regarding pixel positions = of surrounding elements. You sometimes also experience this while = visiting SVG image-rich files (think org-latex-preview) while in visual = line mode. In this case, previous/next-line sometimes jump from one = side of the window to the other. =20 But it=E2=80=99s easiest to reproduce with line-truncation in effect. = Run the snippet below with your frame either expanded wide enough to = accommodate the full width of the 1st line of text, or too narrow = (eliciting truncation). While truly truncated and with point on the = SVG, pixel text measurements above are erroneous (reporting zero pixel = height above), as if it thinks it=E2=80=99s on the prior line. At other = points in line 2, the pixel-size values are correct. =20 This erroneous pixel size/position result occurs whether the image = appears via an overlay or a text-property. Tested in Emacs 29.1 NS and Mac ports. Small update: this only occurs when the image is at the start of the = line. And PNG images exhibit the same issue. +++++++ ;;; test-svg-pixel-position --- test pixel position for SVG images ;;; This small code creates a buffer with two lines, the first of ;;; which is long, and the second of which has an SVG image at start. ;;; Line truncation is turned on. `window-text-pixel-size` returns ;;; differing results depending on whether truncation is actually in ;;; effect (alter the frame width to see this). ;;; Code: (require 'svg) (let ((buf "svg-pixel-demo") (svg (svg-create 50 25))) (svg-circle svg 25 25 25 :stroke-color "green") (with-current-buffer (get-buffer-create buf) (erase-buffer) (insert "Pellentesque condimentum, magna ut suscipit hendrerit, ipsum = augue ornare nulla, non luctus diam neque sit amet urna.\n") (insert (propertize "THISISACIRCLE" 'display (svg-image svg))) (insert " Aliquam posuere.\n") (pop-to-buffer buf) (goto-char (point-max)) (forward-line -1) (toggle-truncate-lines 1) (message "PIXEL SIZE OF LINE ABOVE IMAGE: %S" (window-text-pixel-size nil (cons (point) -1) (point) nil = nil nil t))))=