glutanimate / syntax-highlighting

A fork of Tiago Barroso's Syntax Highlighting add-on with support for Anki 2.1
https://ankiweb.net/shared/info/1463041493
Other
107 stars 27 forks source link

Serif Font when previewing code syntax #11

Open 0xCLARITY opened 4 years ago

0xCLARITY commented 4 years ago

Problem description

Please describe the issue concisely in here. In case of an error: Walk us through the steps you took to get there. What happened? What did you expect to happen?

Previously, code syntax used to be in a monospaced font when creating/editing a card. It now appears to be in Times New Roman or some other serif font.

Perhaps I'm missing the font used for previewing the code syntax on my computer now? This wasn't a problem previously, but something must have changed with my setup recently.

weird-font

Checklist

Please replace the space inside the brackets with an x if the following items apply:

Information about your Anki set-up

Please fill out the section corresponding with your Anki version:

If you are using Anki 2.1

Please open Anki, go to Help → About, click on "Copy Debug Info", and paste the result between the backticks below (if the button does not appear you are using an older version of Anki 2.1 and will need to update first):

Anki 2.1.15 (442df9d6) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Mac 10.15
Flags: frz=True ao=True sv=1

Add-ons:

Search and Replace Tags (disabled)
Deck Stats (disabled)
Syntax Highlighting for Code
Night Mode (disabled)
More Overview Stats (disabled)
Progress Graphs and Stats for Learned and Matured Cards (disabled)
Frozen Fields (disabled)
True Retention (disabled)
If you are using Anki 2.0

Please open Anki, go to Help → About, find the two lines starting with Version: and Qt, and copy-paste them between the backticks below:

Please fill in details about your operating system (Windows/macOS/Linux, which version):

Please open Anki, go to Tools → Add-ons, take a screenshot of your installed add-ons, and paste it below:

Anki-addons

Error message (if any)

If you've received an error message, please copy and paste it between the backticks below:

0xCLARITY commented 4 years ago

Update:

This does not happen on my 2016 Macbook Pro running Mojave (OS X 10.14.6).

Same deck, (mostly) same extensions. Code Highlighting has the expected monospaced font.

I wonder if this is a bug with OS X 10.15?

0xCLARITY commented 4 years ago

This looks like the same bug as: https://github.com/glutanimate/mini-format-pack/issues/9

gcohara commented 4 years ago

I'm having a similar issue, and am also on Catalina. It's this font during reviews as well.

Octemull commented 4 years ago

This looks like the same bug as: glutanimate/mini-format-pack#9

Same problem with mini-format-pack installed, on Catalina.

Octemull commented 4 years ago

This looks like the same bug as: glutanimate/mini-format-pack#9

Same problem with mini-format-pack installed, on Catalina.

I found a temporary solution.

Go to Tools → Add-ons → chosse "synatax highlighting for code" → View Files

Open main.py, then modify the highlight_code function.

# Actual code highlighting
def highlight_code(ed):
    [...]
    pretty_code = process_html(pretty_code) # line 415

    # Add the following line after line 415 (change font type to Menlo)
    pretty_code = pretty_code.replace("style=\"","style=\"font-family: Menlo;")
    [...]

I change the font type to Menlo. You can also change it to other types you like.

Be sure to include the font type in the Styling (shared between cards) part of your card templates. It should be something like this.

.card {
  font-family : Menlo, "PT Mono", Monaco, helvetica, arial, sans-serif; 
  ...
}
rober-m commented 4 years ago

Same problem when I upgraded to MacOS 10.15.4 from 10.14.x (During both editing and reviews)