Font size is bidi module

I have been using bidi module for some Urdu text and overall it works really well. However I have hit one small niggle.

The documentation for +bidi-arabic-font says

WARNING: if you specify a size for this font it will hard-lock any usage of this
font to that size. It's rarely a good idea to do so!

and that makes sense and setting a size indeed makes C-+ etc stop working.

However accepting the default font size and then using C-+ and C-- to get to a good size for the font then break the spacing between words and size for the punctuation. This is because +bidi-arabic-face is set using +bidi-arabic-font but at a fixed size so what the documentation of +bidi-arabic-font is warning against happens and after using C-+ and C-- the text looks either too cramped or too spread out?

It seems to be that both +bidi-arabic-font should be a font family name and not a font spec and +bidi-arabic-face should specify the :family and not the :font.

Thanks for the detailed report! I’m a bit busy these days so it might take me a bit of time to look in to this properly (order of magnitude a few weeks), I’ll update you when I do. Or maybe @ymarco might be able to do so sooner.

I experimented a bit but it seems like specifying :family but not :font doesn’t work. So I am actually not sure how to make a face which specifies a font family in such a way that the scaling works.

doom-font manages to set its size and still work with all the scaling stuff.

I looked around a little, and it seems like

  • doom-font uses set-face-attribute to set the default (and faces’) :font,
  • text-scale-mode (the thing behind C-+ and C--) use face-remapping-alist to set the default face’s height.

So, uh, copying doom-font’s method might work. (i.e defining +bidi-mode-*-face with no properties, and binding it to +bidi-*-font through face attributes in after-setting-font-hook.)

I’ll try in in a few days if no one picks this up.

Thanks for this. I tried to make sense of it and the basic issue of punctuation and characters not not sharing the font size can be solved following the current advice of not of using a font size for +bidi-*-font and adding this,

(add-hook 'text-scale-mode-hook
          (defun +bidi-scale ()
            (face-remap--remap-face '+bidi-arabic-face)
            (face-remap--remap-face '+bidi-hebrew-face)))

However it would be nicer if we can specify a font size, since for me at least the default size has no chance of working sensibly. But I don’t know how. One way would be to use +bidi-*-face not only for the punctuation but every character in the fontset. Another can be to use the face-remapping-alist to remap the default face to appropriate size in the +bidi-mode but that will not play well with the mixing of RTL and LTR.