From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id pmOfAWS/Y2H1aQAAgWs5BA (envelope-from ) for ; Mon, 11 Oct 2021 06:36:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id Be6TNmO/Y2FLFgAAB5/wlQ (envelope-from ) for ; Mon, 11 Oct 2021 04:36:51 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 88A04D8EF for ; Mon, 11 Oct 2021 06:36:50 +0200 (CEST) Received: from localhost ([::1]:45332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZn3Q-00042s-8s for larch@yhetil.org; Mon, 11 Oct 2021 00:36:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZmze-00082I-RE for emacs-orgmode@gnu.org; Mon, 11 Oct 2021 00:32:54 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:37532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZmzc-0003Or-S9 for emacs-orgmode@gnu.org; Mon, 11 Oct 2021 00:32:54 -0400 Received: by mail-pg1-x52b.google.com with SMTP id r201so9662329pgr.4 for ; Sun, 10 Oct 2021 21:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version; bh=9NThWlJsT7UxzXYpchjmYhSHTo9whibB5J7qmwEDw3g=; b=DrAm8BlAXBqQB44j82UoFCqyEBNLEXlBUcaqeNozDVOWD0jaorAD67MEAzt76ocJI9 /ESf/70kwRCc5ew2BnNGOMmRbGUZaMB8zWpxQkugPmb3oE3lnwHHX+OngeyJ9/Z9uFMk oPedZ59thOFS6EjDeMIWR4aVkQ78Mmdkud/UbcuABgKc1XpBSf/aVQn3EMWE4xI/hhnX ao6AWVKnt0SPuoSByaRbxr2WuglVVXvAMUlrMdVHqynpBE9ixItLvF+vhT7Qlfh9944H 8dmyuTGQIFjpp883YD6kpA+G5vlUAqVL98F8p7Jen8zy9JGimdU/sE/hjW7Rq00wu5QV ywXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=9NThWlJsT7UxzXYpchjmYhSHTo9whibB5J7qmwEDw3g=; b=Grm9nSBKrpgmQFUigPNmDExeay6j9J7dEm8pXHWZ2kn4a39xeSKePOtYMQYjG4mwem RNqyt1ZI5asRfDsBXLpSRjjpI7McHlrc/5C2XqE6qAHPbl3OX9AgKVdl6QH0RrVvoEyB NW6hUtmZsP89342y0wTyPH72BNDtDlevTlFIizCLMBhvxUJ7Pmoc5+El5LnGNDb5xmtN nNLqF59bPNYNekSndcD7vc2MLhQDfBkjRRvoGfodvZetnaHrywmsl1bh+xnlFSYkzXH2 eKZw0lNRxzwctk/76orwa7h4WA/jiDNRRmmdtfXMlNgnjXkKSRixlzqTWJ3cd8mTtJtJ oP8w== X-Gm-Message-State: AOAM530+XyLYKd0UYW0xnJUx84HJ2rVlEW0PhEtlBZ+3FDn/pc6oG3dZ pwJ0L542bmu0HzJdhtRhWcTcJV32Epg= X-Google-Smtp-Source: ABdhPJw7lXZV65FaD4J/MNEIgvloHCpW81zWwGTA1K8CIf45qt1jOU0Ki5nC0P8JHXQQ4YOO94jtgQ== X-Received: by 2002:a65:64d7:: with SMTP id t23mr16351783pgv.237.1633926770626; Sun, 10 Oct 2021 21:32:50 -0700 (PDT) Received: from ryzen3950 (c-73-170-21-48.hsd1.ca.comcast.net. [73.170.21.48]) by smtp.gmail.com with ESMTPSA id 1sm5871665pfm.163.2021.10.10.21.32.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Oct 2021 21:32:49 -0700 (PDT) From: Matt Huszagh To: "emacs-orgmode@gnu.org" Cc: Subject: Patch to allow adjusting latex fragment display scale factor Date: Sun, 10 Oct 2021 21:32:45 -0700 Message-ID: <87sfx8xjte.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=huszaghmatt@gmail.com; helo=mail-pg1-x52b.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-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633927011; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=9NThWlJsT7UxzXYpchjmYhSHTo9whibB5J7qmwEDw3g=; b=OI2+K0A7XuBUSuLOa6w7qQMRB7DluU1U6CaY0zuPD2Ewo1wmSCgxsmxhdd19rh+BCLWMLB jqXJ8jrScw/k7vxfnDrJE7QoO1BvY9/DuyQjWrZB4FxNW+oMnsHT2+ETP5B/h3ATyHNW1q B/h7JyszZt1kI7e2CdIN0f5sgWYsv+0F8hwIsCk4YEtVWRg7wp7N+XFYxvsmT7MCVS6xfo Tpm0/O9TuNn8FmyxniHJw3t/wkJ1kXPO8diXPxpLEPawutrHStKiGPSsY2bkWT8KydSBxn kVzZRXvOmfz5HnZfnqulbK4i3zolvpstzbv5/vQ742AyT7+ot1pt51+R+rzjEA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633927011; a=rsa-sha256; cv=none; b=K8IqwB7gasadxxDtYS7AjCIPZmBR1Wh2V6ixNPFvXlAvkg9zZmJq2XFeJtvySM0OmOLhBr KogbEYZ16Wgv/IWOOxaL1fOMVMiEEz8UMivMVehhr+Eb7uP3njxWhpxxF/Xz06QNENh077 0jXUtp1LKC6cp+QbMME/jrrDVDwyeMTkCHkgEJDBbDGOh0N282JmGNO8wZNtKaFg8VoZHM mE8Z4cNr+vduvTyJf7VMfKf/bZ7WMzIQKeTc0SwJ33dFGDjHaw9OXoSe27J5axAj5LIdE3 oy5HFkB1sjJ/C5LzTAgSMhPjDwIxJqJ9Bvm8FFOHWe4QMfU0tnWIx/13orm7zw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=DrAm8BlA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.11 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=DrAm8BlA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 88A04D8EF X-Spam-Score: -3.11 X-Migadu-Scanner: scn0.migadu.com X-TUID: ulCw1uVcKLlr --=-=-= Content-Type: text/plain Hi, I've created a patch to allow adjusting the scale factor used for inline latex image fragments. This involves a customizable variable that can either be set to a scale factor (defaults to 1.0) or a function that evaluates to a scale factor. This feature is in addition to the existing scale factor adjustment capability provided by `org-preview-latex-process-alist' through `:image-size-adjust'. Wherease image-size-adjust performs scaling at the time of image generation, the new change performs it during display. This can lead to significant time saving and suffers no loss of quality for vector graphics. As an example of use, I have several functions for changing frame scaling. I've added (if (eq major-mode 'org-mode) (progn (org-clear-latex-preview) ;; 16 corresponds to the C-u C-u arg prefix. (org-latex-preview 16))) to these functions so that changing the frame scaling also correspondingly changes the latex preview/fragment scaling to match the new size of the surrounding text. Because of this new feature, this change is effectively instantaneous for reasonably numbers of overlays. Obviously, something similar could be done for `text-scale-adjust' (e.g., through `advice-add'). Feedback appreciated. Matt --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org.el-Allow-customizing-overlay-put-scale-factor.patch >From 8247947aa6141cde9c58205e0266f0e674226f95 Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Sun, 10 Oct 2021 21:20:31 -0700 Subject: [PATCH] org.el: Allow customizing overlay-put scale factor * lisp/org.el (org-latex-fragment-scale): Add customizable variable that is equal to or evaluates to a scale factor used to scale inline latex fragments. (org--make-preview-overlay): Adjust latex fragment overlay generation to account for the new custom scale factor. --- lisp/org.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index dbc288a3c..f5e9ff8d1 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -388,6 +388,15 @@ text." :type '(symbol function integer) :group 'org) +(defcustom org-latex-fragment-scale 1.0 + "Scaling factor used for LaTeX image fragments. +This can either be a number or a function that takes the image +data and image type as parameters and evaluates to a number. The +function can be useful for context-aware scaling, such as setting +the scale factor to be consistent with the surrounding text size." + :type '(number function) + :group 'org) + ;;; Version (org-check-version) @@ -16007,7 +16016,13 @@ as a string. It defaults to \"png\"." (delete-overlay o)))) (overlay-put ov 'display - (list 'image :type imagetype :file image :ascent ascent))))) + (list 'image + :type imagetype + :file image + :ascent ascent + :scale (if (functionp org-latex-fragment-scale) + (funcall org-latex-fragment-scale image imagetype) + org-latex-fragment-scale)))))) (defun org-clear-latex-preview (&optional beg end) "Remove all overlays with LaTeX fragment images in current buffer. -- 2.31.1 --=-=-=--