LaTeXTools icon indicating copy to clipboard operation
LaTeXTools copied to clipboard

Transparent background in equation inline preview

Open dniku opened this issue 9 years ago • 13 comments

image

I think the problem is self-evident — the preview looks very ugly on a transparent background. Sublime build 3126, LaTeXTools 3.12.11.

(Completely unrelated note: I found the LaTeXTools version in a Package Control tab with an update notification that I haven't closed. How could I find the version if I had closed it?)

dniku avatar Dec 10 '16 23:12 dniku

This appears to be just about the quality of the rendering as in #901. I'm not sure where the transparent background enters into things. If it's about rendering quality, there may be something we can do. Could you please clarify?

Regarding the version number, you can use the Package Control: List Packages command to find the version of any package installed through Package Control.

ig0774 avatar Dec 11 '16 13:12 ig0774

The background is not bound to the generated image. We always create an image with a transparent background and add the color via css in the phantom. Therefore if the image only looks bad with transparent backgrounds the problem is more in ST and we can't do something about it.

r-stein avatar Dec 11 '16 13:12 r-stein

@ig0774 the problem is that equation preview is unreadable. It could probably be fixed if it was rendered with a non-transparent background, or, better, with the background color equal to the editor background color (and text color adjusted accordingly).

dniku avatar Jan 02 '17 22:01 dniku

@Pastafarianist you could try out #985, this should increase the quality.

r-stein avatar Jan 02 '17 22:01 r-stein

v3.12.12 should result in higher-quality PNGs, which, hopefully, resolves this issue.

ig0774 avatar Jan 06 '17 17:01 ig0774

@ig0774 I've just updated, and the quality doesn't seem significantly superior.

image

In fact, only the tips of the arrows are rendered. Furthermore, the equation is cut on the right (there should be a closing parenthesis after X, then another arrow...).

Here is another example:

image

I am on v3.12.13.

Can we reopen the issue?

dniku avatar Jan 07 '17 18:01 dniku

@pastafarianist: I've re-opened, but I'm not entirely sure what we can do. What version of Ghostscript are you running? Are you running in HiDPI mode? What OS and version are you running? This might be helpful in tracking down the issue.

Another thing that might be useful is to empty the image cache. To do so:

  1. Open the ST Console (View -> Console}
  2. In the console type sublime.cache_path() and press enter. Note the displayed path.
  3. In you file manager (Explorer / Finder / Nautilus / etc) browse to the folder you noted above.
  4. Open the LaTeXTools folder and then the preview_math subfolder. Delete all the contents of this folder.
  5. For good measure, exit and restart ST.

ig0774 avatar Jan 07 '17 21:01 ig0774

$ uname -a
Linux desktop 4.4.39-1-MANJARO #1 SMP PREEMPT Thu Dec 15 21:29:27 UTC 2016 x86_64 GNU/Linux
$ gs --version
9.20
$ subl --version
Sublime Text Build 3126

I am not running in HiDPI. I am using a 27" monitor with 1920x1080 resolution.

Cleaning the cache changed nothing for me. Here is an example of an image from the preview_math folder I generated after cleaning it:

cf55686b7793e58433924dece6b0fb0c

Is there any other diagnostic information I can provide?

dniku avatar Jan 07 '17 21:01 dniku

If you could upload one or more of the generated PNGs it'd be helpful. It should be in the same cache folder you cleared out.

ig0774 avatar Jan 07 '17 21:01 ig0774

@ig0774 just edited the post above.

dniku avatar Jan 07 '17 21:01 dniku

@Pastafarianist: One thing that may help is to adjust the preview_math_density and preview_math_scale_quotient settings. In older versions, they were by default 300 and 2 respectively, but I noticed that (on Windows and Linux) this seems to add unnecessary distortion. Given the size of the PNG, it seems you still have these settings in place. You may want to attempt adjusting them to the new defaults of 150 and 1, respectively, which seem to cause less distortion (at least for me).

If that still isn't good enough and you can tolerate the equation previews being a bit bigger, you can update the preview_math_density setting without proportionally changing the preview_math_scale_quotient (I'd recommend leaving this latter at 1). Essentially, the higher the density is the more pixels are rendered and the fewer anti-aliasing artefacts are produced.

Apart from those two things itself, I'm not sure what else can be done in terms of image rendering. I strongly suspect the distortion you're still seeing is primarily due to ST's internal PNG rendering rather than anything LaTeXTools can control.

ig0774 avatar Jan 08 '17 17:01 ig0774

Thank you for the suggestions. Just to be sure, I deleted the user config file (which was created when I installed LaTeXTools) and created a fresh one. Here is what the same formula looks like with the settings you mentioned set to 150 and 1:

image

Even if there is nothing that can be done on LaTeXTools's side, perhaps the issue can still be kept open, since Sublime may provide the necessary APIs at some point.

dniku avatar Jan 09 '17 01:01 dniku

@Pastafarianist: I'm happy to leave this open.

ig0774 avatar Jan 09 '17 14:01 ig0774