syntax-highlighting icon indicating copy to clipboard operation
syntax-highlighting copied to clipboard

Serif Font when previewing code syntax

Open 0xCLARITY opened this issue 6 years ago • 6 comments

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:

  • [x] I've restarted Anki to see if it helps
  • [x] I've verified that I use the latest version of the add-on by redownloading it from AnkiWeb
  • [x] I've verified that I use the latest version of Anki by checking at https://apps.ankiweb.net#download
  • [x] I've tried to disable other add-ons to see if there are any interactions present
  • [ ] My issue disappears when I hold shift while starting Anki. (It does not)
  • [x] I've checked if anyone else reported this problem before by looking through the issue reports. I also checked to see if there is a section about known issues in the add-on description, documentation, or README.

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):

  • OS: macOS
  • version: 10.15

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 avatar Oct 16 '19 07:10 0xCLARITY

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 avatar Oct 16 '19 14:10 0xCLARITY

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

0xCLARITY avatar Oct 16 '19 14:10 0xCLARITY

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

gcohara avatar Nov 13 '19 17:11 gcohara

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

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

Octemull avatar Mar 18 '20 09:03 Octemull

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; 
  ...
}

Octemull avatar Apr 12 '20 06:04 Octemull

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

rober-m avatar May 22 '20 00:05 rober-m