1

I use this function in init.el file so that I can switch to Arabic language when writing code in Arabic and select an Arabic font for that:

(defun arabic-input-font ()
  "changes the set-input-method to Arabic and selects another font"
  (interactive)
  (set-input-method "arabic")
  (face-remap-add-relative 'default :family "Droid Arabic Naskh" :height 110))  

When I use any other Arabic font there is no problem. Problem arises only when I choose this font Droid Arabic Naskh, source of this font. I like this font for its clarity in writing.

Scratch buffer before switching to this font:
enter image description here

Scratch buffer after: enter image description here

I want to use the following fonts for the three languages as fallback fonts for their respective languges: English - consolas Arabic - Droid Arabic Naskh Hebrew - SBL Hebrew

I will be very grateful for fixing this issue and let English script appears along with the Arabic one using this font.

Notes

Emacs version: GNU Emacs 24.4.1 (i686-pc-mingw32)
Windows platform

3
  • What's wrong with just using Droid Arabic Naskh as explicit fallback font instead of changing the default font?
    – wasamasa
    Apr 28, 2015 at 11:17
  • How to set this font as an explicit fallback font? can you please provide a code for that? thanks for your suggestion.
    – doctorate
    Apr 28, 2015 at 11:20
  • this might solve another puzzle for me: why the fallback Arabic font was changed lately to another font after installing some fonts on my machine.
    – doctorate
    Apr 28, 2015 at 11:23

1 Answer 1

5

Emacs is stuck somewhere between not supporting font fallback at all and supporting fully automatic fallback. As soon as you tell it to use a specific font, it will make use of this font's glyphs only, requiring you to explicitly set up fallback fonts with a fontset to display any extra glyphs not covered by it. Your arabic font for example doesn't have any non-arabic glyphs, I assume that's why you get to see these funny boxes.

If your main font doesn't have the extra glyphs you wish to cover, it's possible to modify the default fontset of the current frame by appending the font covering the extra glyphs to it:

(set-fontset-font "fontset-default" nil "Droid Arabic Naskh" nil 'append))

If you wish to override a certain set of glyphs with your other font, you need to specify it explicitly:

(set-fontset-font "fontset-default" 'arabic "Droid Arabic Naskh" nil)

Note that if you're creating extra frames or use the Emacs daemon, you'll need to apply this invocation on both the initial frame and every subsequent one. I recommend wrapping the invocation into a function using an optional argument and adding it to after-make-frame-functions. Here's an example lifted from my own config that adds support for Emoji:

(setq default-frame-alist '((font . "DejaVu Sans Mono-10.5")))
(defun my-fix-emojis (&optional frame)
  (set-fontset-font "fontset-default" nil "Symbola" frame 'append))
(my-fix-emojis)
(add-hook 'after-make-frame-functions 'my-fix-emojis)
2
  • many many thanks. You solved the puzzle for me. But the first line was not required in my case. your second line did the job right. So for Hebrew and any other language I have to only change arabic to hebrew (I guess these are the same names of the input-method) and so on using its relevant font, right?
    – doctorate
    Apr 28, 2015 at 11:59
  • no these are just names of the char sets not related to the input-method.
    – doctorate
    Apr 28, 2015 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.