corollari/ankiTab

Using custom Font

Opened this issue · 8 comments

Hello,
i'm using a custom font for my chinese cards.
Unfortunately since the AnkiConnect update, that font doesn't work anymore.
Console output: chrome-extension://ihoaepdiibjbifnhcjoaddgcnfgjmjdk/_gkai00mp.ttf net::ERR_FILE_NOT_FOUND

When I put that font file in C:\Users\<USER>\AppData\Local\Google\Chrome\User Data\Default\Extensions\ihoaepdiibjbifnhcjoaddgcnfgjmjdk\0.4_0 it works for 1 second after Chrome detects an extension corruption.

I kindly ask you to add a function for custom fonts.

First of all, thanks for letting me know of this issue.
About the bug, could you upload the deck that's causing issues or explain how to create one with which I can reproduce the issue?
The problem is that ankiConnect only allows retrieving media files via an API call, so right now the extension is performing these API calls for everything which has a src attribute, which obviously misses stuff like fonts. A way to solve this issue would be to stop all web requests, call the ankiConnect API and encode the answer in binary (ankiConnect returns a base64-encoded answer) before returning it, which is exactly what I'll start working on.

Thanks for your fast response!
Here are the files.
gkai00mp.zip
综合中级1.zip

This weekend I've been working on this and, while I thought this would be pretty straightforward, it seems it will take a bit longer to implement than planned, as, right now, the chrome extensions API doesn't support changing a request body[1][2].
Just wanted to give you a heads up so you know that I haven't forgotten about this.

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=104058
[2] https://bugs.chromium.org/p/chromium/issues/detail?id=487422

It seems I won't have the time needed to look into this (I don't even know if it's possible without submitting a PR to chome&firefox) till a few months later, so it will probably take a while.
Meanwhile, as a temporary fix, I prepared the branch fontissues, which has the font file you needed to get your cards working. You can use this version of ankiTab by downloading it, enabling developer mode in chrome and loading the extension unpacked.
In case you also want it for firefox just leave a comment and I'll sign it for you.

Wow, good job!

Thanks, if you find any issue installing it just let me know :)

Just had to add "_" in front of the file name. "_gkai00mp.ttf"

Hello, I am also kind of getting into same issue with my decks. All the external images, js files and css files in the card returns error in console as file_not_found. I am using the annotation of '_' before each file and it works perfectly fine in Anki. In chrome, only the html part shows up but not the images, js and css those are in collection.media.
Am I missing something here ?