Itâs hard to tell what exactly is going on without inspecting the source, and Iâm not sure if Anki Mobile has tools for that, but Iâll take a guess that it might be using some predefined styles for .tag class for displaying Anki own tags somewhere and that interferes with the styles you are trying to define.
There is a couple of things to try:
You can simply add !important to your color rule to try and make it take precedence over potential built-in styles:
...
color: white !important;
...
You can try choosing a different class name, like .mytags or something else that is unlikely to be used by Anki Mobile itself, and update both the styles and the HTML code accordingly.
thanks so much for your help, i tried your suggestions but they donât work
I did some testing and found that deleting this font-family:emoji;, which is actually Microsoftâs Segui Emoji.tff, makes the font color display normally, but I do want to use this font.
I guess a missing font can cause this as well, if the default substitute Anki Mobile falls back to somehow has colored characters. In that case, you can try installing your font into your collection:
the font isnât missing, itâs already synced in the collection
as you can see in the picture above, the emoji is rendered correctly using the font segui emoji, the problem is about the color of the text followed
sorryïŒmy previous explanation might not be clear.
The font was already included in my code from the very beginning â I just didnât post that part.
Could you share your card and the font file in some way? I have one more idea, but it would probably be faster to check myself and write here if I find anything than to describe the whole process.
Since the font families for the text in the tags themselves are not explicitly set anywhere, this still leaves them open to be automatically selected by the platform, based on what is available in the system. I suppose one more thing to try is adding a rule for that in the style for .tag itself, making sure you are using font faces that include the required characters and are available on your phone (and also using !important during the tests for good measure).
Although I am beginning to wonder if this might be a bug:
I see that the emoji font is not used anywhere except that ::before pseudo-element, so the presence of that rule should not affect other elements regardless.
It looks almost as if the unwarranted color of the text was inherited from the last color used in rendering of the preceding emoji:
The colors being picked up by itself is a wild guess, so who knows? Because the colors there are the same in text and its background, it might be that the âN3â text is not rendered at all for some completely different reason. But the fact that in both tags the potential color of the text is present in the emojis says that inheritence of the color is at least a possibility.
It might be that this is simply the color of the last layer in the emoji vector image, and it does not get reset after the rendering is finished, resulting in it continuing being used in the next rendering until a new color is explicitly selected.
It would be interesting to test other emojis and see if any of their colors appear in rendering of text to check if this wild hypothesis holds any water at all.
âN3â is actually rendered as you can long-press and copy the text.
After testing some other emojis with this font, it turns out that the text color is indeed linked to the colors within the emojis.
If you use the Segoe UI Emoji font in CSS .tag, even when you manually specify the text color as shown below, the color still doesnât appear correctly.
I guess itâs time to tag @dae ?
Although, if it is a rendering issue, itâs likely the problem is not in Anki Mobile itself, but in the iOS web engine. How does your card look when viewed on ankiweb from your mobile browser?
In the meantime, there are still a few things to try to avoid this bug:
I donât think this font specification is working for two reasons:
Arial is not typically a system font on iOS, so the âN3â part would still get rendered by a different font autopicked by the system
Arial does not have Chinese characters, so âćœąćŒćèŻâ is still rendered with a different font on either system.
As I suggested previously, try using a font, that youâre sure you have on your mobile device and/or try including the font file for this into anki collection the same way you did emoji file. (also keep in mind that you can use several font families in CSS rule to serve as fallbacks and have a better chance of enforcing the directive.)
Since the bug is not widely known (at least a quick search did not reveal anything similar), and also because you say the fonts are rendered fine with a default iOS emoji font, the font file you are using might be partially to blame. If it is corrupted, finding a different source file for Segoe UI might help. You can also try repairing the file you have by opening it in a font editor (e.g. https://www.glyphrstudio.com/), making some minor change, like deleting a character you wonât need, and exporting it as a new file.
You can try putting an empty <span> into each tag and attach the ::before style with the emoji to it instead of the whole .tag container. Maybe it will encapsulate the emoji character and prevent it from affecting the text
You can try changing ::before to ::after. This way, the text should render first, which might save it from being affected by the emoji font. If it works, some other modifications to CSS would have to be made to make the pseudo-element appear to the left of the text as intended, but that should be doable.
I donât get the impression that this is an Anki related bug, since the flashcards are rendered within a webview based on your predefined OS browser, but rather a difference in how your CSS styles are declared or rendered.
However, I was not able to reproduce the same error youâre experiencing with the file you shared above, so I suggest using one of these following options so you can easily investigate on your devices:
If you set the QTWEBENGINE_REMOTE_DEBUGGING environment variable to 8080 prior to starting Anki, you can navigate to http://localhost:8080 to debug the visible webpages, alternatively, you can try to install this add-on to open the inspector inside the main app.
If the problem is exclusively on your smartphone, enable HTML inspection in Ankidroid and then navigate to chrome://inspect to open a remote debug window.
EDIT: I just noticed that youâre using AnkiMobile for iOS and not AnkiDroid, which might explain why I couldnât reproduce your error; however, I believe you can achieve the same results through Eruda console for mobile browsers.
However, even if this doesnât allow you to reach a satisfactory solution, I agree with @eltaurus that it may be possible to achieve the same aesthetics by slightly modifying your cardâs markup.
Iâm looking forward to seeing if we can help you with that.
It looks like that this is an IOS bug since AnkiWeb has the same problem
After further investigation, i found that any text specified as white(#ffffff) and preceded by an emoji âeven if the emoji and the text are not on the same levelâ ends up being rendered in a strange color.
Finally the very weird solution, if I set the .tag color to something close to white and assign a different color to .tag::before (i donât know why, but this step is necessaryâotherwise, the text color still ends up being affected by the emoji), then the text renders in the color I specified.
I tried the Eruda console on IOS AnkiMobile, the console did pop up, swiping works, clicking the button shows a shadow effect, but other than that, the consoleâs buttons donât respond at all.
As I said before, this bug likely comes from your OS browser which is why we were not able to reproduce and further debug it. Safari on iOS is widely known for having many rendering quirks and inconsistencies, especially compared to other major browsers like Chrome and Firefox.
Nevertheless, even though I donât understand how it works, Iâm glad you found a proper fix that works for you.