-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xenops renders svg images in wrong background color #51
Comments
Hi @wang1zhen Xenops honors the |
Hi @dandavison , thanks for your reply. I have tried
However, it did not help, the image is still rendered incorrectly This only happens when the background color of emacs is set to purely black, as tested in protesilaos/modus-themes#36 , I do not know if this piece of information helps? |
Have you checked that xenops is not using the cached version of the image? For example, enter LaTeX code that you have never entered before. You can also delete the files in |
OK, thanks for confirming. If you simply open that SVG in emacs, without using xenops, does it render correctly? Can you give me instructions to reproduce the problem you are experiencing? |
This seems to be the issue! The SVG generated is simply "white on black", and the rendering is perfect on default theme: When I simply switch to another theme, it seems that the rendering mechanism for svg is not working as expected, for example, here is what I got in tango-dark theme: which is kink of "white on grey", and for wheatgrass theme: I think you can reproduce it with any dark built-in themes for emacs. |
Any news of this? I get the same issue. I don't see the white border when I open the SVG in firefox and Emacs... When I don't use any theme, the preview looks like The value of My emacs version is: And the issue does not exists in Updated: I seem to find the cause of the issue. I have the following face setting in my config
How can I fixed this while keeping the setting? |
Hi @liebkne , it seems we are not facing the same problem, but I have a not quite elegant fix that maybe works for you, try set |
Hi @liebkne, would it be possible / convenient for you to create a minimal reproducible example of an emacs.el and an org file that results in this problem? The example init.el doesn't have to install any packages; just the org/xenops config. (I'm slightly worried that image quality will be degraded if you switch to PNG but if that's not the case then great. I use a Mac laptop and have struggled to get crisp PNGs; this was actually one of the reasons I first wrote xenops, because the PNGs produced by auctex didn't look right on a mac retina screen, whereas SVGs looked great, but auctex didn't support SVGs) |
@dandavison Hi, thanks for the quick response. It took me sometime to extract reproducible config from my (setq straight-use-package-by-default t)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(straight-use-package
'(org :type git
:repo "https://code.orgmode.org/bzg/org-mode.git"
:branch "release_9.5.4"
:local-repo "org"
:depth full
:pre-build (straight-recipes-org-elpa--build)
:build (:not autoloads)
:files (:defaults "lisp/*.el"
("etc/styles/" "etc/styles/*")
("etc/csl/" "etc/csl/*"))))
(use-package xenops
:hook (org-mode . xenops-mode))
(setq org-highlight-latex-and-related '(native script entities))
(custom-set-faces
'(org-block ((t (:background "red" :extend))))) Running
results in The strange part is: the issue is fixed by commenting out either of the last two s-exp of the config. |
Can confirm this still exists in current release |
Did you mean this issue
or the one by @liebkne ? |
Hi all, I'm sorry I don't have a lot of time to investigate right now. Could you clarify whether the issues you're facing occur when using org-mode, or plain |
It is both true for org-mode and latex-mode. |
@liebkne I also face the same issue and solve it by
It is caused by the theme setting which will make the background colour of source block darker. This setting can make the background color of latex blocks as default. |
As far as I can tell the issue lies with how emacs renders svg One possible fix would be to modify the svg generated by To achieve this I modified the function Since the color black is now hard-coded as transparent. I also "fixed" xenops behaviour when the background in Both functions can be found in diff --git a/lisp/xenops-math-latex.el b/lisp/xenops-math-latex.el
index d998ae6..f7ec296 100644
--- a/lisp/xenops-math-latex.el
+++ b/lisp/xenops-math-latex.el
@@ -112,7 +112,8 @@ containing the foreground and background colors."
"\n\\begin{document}\n"
"\\definecolor{fg}{rgb}{" fg "}\n"
"\\definecolor{bg}{rgb}{" bg "}\n"
- "\n\\pagecolor{bg}\n"
+ (unless (--every (= (string-to-number it) 0) (split-string bg ","))
+ "\n\\pagecolor{bg}\n")
"\n{\\color{fg}\n"
latex
"\n}\n"
@@ -261,7 +262,7 @@ format the commands."
(bg (if (eq bg 'default)
(org-latex-color :background)
(org-latex-color-format
- (if (string= bg "Transparent") "white" bg)))))
+ (if (string= bg "Transparent") "black" bg)))))
(list fg bg)))
(defvar xenops-math-latex-preamble-cache nil It is more of a workaround than a fix but I hope it can help someone. |
thanks a lot |
When the background color of the default font is "black", the svg image would be rendered in wrong background color instead of the black background, see the following screenshots:
xenops rendering properly:
xenops rendering imporperly
(set-face-attribute 'default nil :background "black")
:Discussion here also confirms this.
The text was updated successfully, but these errors were encountered: