Height of input fields when creating cards is too small for Nastaliq fonts

I am using Anki (Version ⁨2.1.65 (aa9a734f)⁩, Python 3.9.15 Qt 6.5.0 PyQt 6.5.0) on Debian 12.
When creating card types, I can select the font. For Urdu, I selected “Noto Nastaliq Urdu”. However, when I create new cards, the input field is too small for Nastaliq fonts - unlike roman fonts or even Nasx (what’s used for Arabic), Nastaliq is written in a sloped manner. This means that longer words also become a bit bigger on the vertical axis. I assume that the height of the input field is somehow calculated using the height of the biggest letter plus some buffer. This approach makes sense for scripts where letters are only connected vertically, but in the case of Nastaliq this doesn’t work.
Could someone tell me if there’s a way to change the height of the input fields?

The font size in the editing screen can be controlled by clicking on the Fields… button.

True, but that will change the size of the font as well as the size of the field, so the problem persists.
The problem is the ratio of the size of the field to the size of the font.

@dae this is how fields look like with this font (notice the scrollbar)

@Acrata I don’t know why this is happening but you can work around it by adding an empty line after the text.

1 Like

Thank you! This is a very practical solution!

@abdo ah, thanks for clarifying. I’m not sure if it’s a bug in Qt/Chromium, the font’s hints are not correct, or we’re making a wrong assumption in Anki.

It’s caused by the line-height: 1.5 style set on body. Reverting it back to normal fixes the issue for this font but that’s not ideal for typical fonts.

Could you tell me how reverting it back to normal works?
And would you say it could make sense to open an issue for this in github?

I’m afraid this is not a change we can apply if it improves this font but makes all others look worse - any potential fix would need to address this without regressions.

You can use the CSS Injector add-on to do that. Simply put the following in field.css:

anki-editable {
    line-height: normal;
}

See the add-on page for more details.

I haven’t had a chance to try and reproduce this, but I’m curious if the issue goes away if you use the Jameel Noori Nastaliq font instead (you can get it from urdu.ca). I don’t recall having any such issue with it.

It does appear there is something specific with that font.

It case it helps someone in the Ankiverse choose an Urdu font (in general, not specific to Anki), I have uploaded to github a spreadsheet (in OpenDocument Spreadsheet Document format) of Urdu ligatures that is based on C. M. Naim’s famous chart. The way it can be used is to install various Urdu fonts, then change the font for the whole sheet one font at a time, and you can see which does the best job of joining the letters (It is helpful to have an Urdu native speaker around when you do this.) I don’t actually remember if I was aware of the Noto Nastaliq Urdu font when I did this initially.

LibreOffice and Excel are both able to open it:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.