corollari / ankiTab

Browser extension that replaces the new tab page with Anki flashcards
https://ankitab.com
The Unlicense
187 stars 16 forks source link

Using custom Font #5

Open Zwiebelmettwurst opened 6 years ago

Zwiebelmettwurst commented 6 years ago

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.

corollari commented 6 years ago

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.

Zwiebelmettwurst commented 6 years ago

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

corollari commented 6 years ago

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

corollari commented 6 years ago

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.

Zwiebelmettwurst commented 5 years ago

Wow, good job!

corollari commented 5 years ago

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

Zwiebelmettwurst commented 5 years ago

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

itsmepvr commented 4 years ago

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_notfound. 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 ?