From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oAO+NIjAY2E+awAAgWs5BA (envelope-from ) for ; Mon, 11 Oct 2021 06:41:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id QJmcL4jAY2FoQgAA1q6Kng (envelope-from ) for ; Mon, 11 Oct 2021 04:41:44 +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 35DD7DD0C for ; Mon, 11 Oct 2021 06:41:44 +0200 (CEST) Received: from localhost ([::1]:55232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZn8B-0002aP-Bq for larch@yhetil.org; Mon, 11 Oct 2021 00:41:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZn7D-0002Zt-1a for emacs-orgmode@gnu.org; Mon, 11 Oct 2021 00:40:43 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:42691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZn7B-00051x-8G for emacs-orgmode@gnu.org; Mon, 11 Oct 2021 00:40:42 -0400 Received: by mail-pl1-x635.google.com with SMTP id l6so10420954plh.9 for ; Sun, 10 Oct 2021 21:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=jnWkkLhYE4V6o4g9gci451efjoitIcvsTwWAzRB26OQ=; b=EnFH+Vh05cC2qBg2/IxFw42kACTIOZodRJVcYIsLAIEs8z2rV1aW8pIZouNVjyEePl eBi74zEHBBY9iaI49H2iRxfnfwqFmcuvoBrjWu6BuSJ9msKZazIH0tM74/axx1UKVuSh SUc2pZTgP1Ur1R9cQ5Faaq2XzjfnqPo0k4YVZpZ4b5ykfFhDGPc03TaCE8ctaXVDHER1 smJo4gjGR2PvT/93p686NVb5N1i5nxnQUklK/puCVqoMFxlrnZqPsLE8rFVxhu0eHxuv QUHZ7XSNUbQ8KEY06gGOJFa+BRJpipmF/vmAvs5uEL5+nVE6671KEPzITD0jGS7OsP1T rMSA== 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:in-reply-to:references:date :message-id:mime-version; bh=jnWkkLhYE4V6o4g9gci451efjoitIcvsTwWAzRB26OQ=; b=bKm1liKCWqOC1EKXll9XG/BDTRnEJ0pmDRladJiD5t3a4hMHzLIXd2pu96kQhZfVcC P2rxAQkO3Om8vhpqBO8AW6Uqf25fS/5neFWuSqX5xQH6rA/dQOfuGebYGH8Y4r7NRdcU Vk3ZU0C/wDKU9nYW5ZvQzRuXKLVSXFokFZ5wemQJf4hKRgvV4VP3go6yo2vgidFOmbg6 RUXZGPV75ecv22dIg52yD40nM4+xFW5GNeN5dsa/YlGBZPiK7szP+CMhkmLPy/OWhtDO rqH+0dOMPVMslZjXn3FKQptfoDCTju7xH3N/Jvg8WB7qc5WAky8AGD4xNncQfaFtb1XU icrA== X-Gm-Message-State: AOAM5333DdCeAvYP0y0s8madwbqrKe941lWh8g+bEl6nU4mLt/MzwnGC f13Pmy86O9zjZIU+5ONnImbxrWrlog8= X-Google-Smtp-Source: ABdhPJyNJWBPOPmKtn8bEMoLciMGnfNHucQPK6Dyp9GezDuWB/7h80+K5PDca2AErjb5zfMEVl0Nwg== X-Received: by 2002:a17:90b:2493:: with SMTP id nt19mr13368571pjb.78.1633927238213; Sun, 10 Oct 2021 21:40:38 -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 qe17sm6265316pjb.39.2021.10.10.21.40.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Oct 2021 21:40:37 -0700 (PDT) From: Matt Huszagh To: "emacs-orgmode@gnu.org" Cc: Subject: Re: Patch to allow adjusting latex fragment display scale factor In-Reply-To: <87sfx8xjte.fsf@gmail.com> References: <87sfx8xjte.fsf@gmail.com> Date: Sun, 10 Oct 2021 21:40:36 -0700 Message-ID: <87pmscxjgb.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=huszaghmatt@gmail.com; helo=mail-pl1-x635.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=1633927304; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=jnWkkLhYE4V6o4g9gci451efjoitIcvsTwWAzRB26OQ=; b=M3o54yNGA8gu4h48sT0M8JH09X+ecwTPsw1onn2urIZiGWMqSpCg+a4wlHp18idqeHKfea IX/Xq/PWD0vKhpvjVAXtl69VtJExBzBlu1RHo0RC+Xpshq4RvXkG+lR7Q56jwmZq1vsJz7 UWkSwiUK33qXG5iiOdmFqwtQRTxxkPvcvLzcbUlFjF6B6pf+j/lRzdY+SWTwaJXf+jir4s 5ccPz37j/SAKeaYU886mhf211FEa8OCBllUW55Xpp0uEsNfBb9Yz4sS+DrW0v+iPW+QhN7 zy4ERU3QmCvx3zBMimZc3y/6OfbHV6twKz73wuAIuqfnm6EaqfWpYDyGiAozpw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633927304; a=rsa-sha256; cv=none; b=b//iy2MkJcHpriSdPlZKgmcVnPad4SHs/rs4nOw9p6uj3S8qfpd7ege58eTuyh783c+r99 pCepsj79L89t1TV2EmgKAKIMKxv9fNrrkbijBnCqcobjXfOqw5nCB6b9xli6CSRt4HczSh /Z1jAIg49tq75eo5g10vQB9wlTd/GkMVnl16s6XGbfIp2ukGAuHp1ZVadi3rTs8rMeLdeJ YF/81cNkiC2c6oreXJHIjmOUkEl+3ftpLzVkzzhZc1K/EquUJd506Xuh7adaOswRWBbo14 n2nG3Zv4f/OeM213XRsq6nzUC06eGPARkPU8dhS6cDZXvK9aguNq5vdeOW5iNg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EnFH+Vh0; 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=EnFH+Vh0; 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: 35DD7DD0C X-Spam-Score: -3.11 X-Migadu-Scanner: scn0.migadu.com X-TUID: Cl86Y8uY5yNp --=-=-= Content-Type: text/plain Matt Huszagh writes: > 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. Apologies, the patch I sent is slightly wrong. The line numbers also reflect an earlier patch I made. Here is a corrected version. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org.el-Allow-customizing-overlay-put-scale-factor.patch >From 3c0e74a8659edb52c1200a02f8a20216b348c4ac 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 405f0f0f9..052212efb 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -320,6 +320,15 @@ identifier." :version "24.1" :group 'org-id) +(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) @@ -15936,7 +15945,13 @@ as a string. It defaults to \"png\"." (delete-overlay o)))) (overlay-put ov 'display - (list 'image :type imagetype :file image :ascent 'center)))) + (list 'image + :type imagetype + :file image + :ascent 'center + :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 --=-=-=--