14
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

emacsAdvent Calendar 2021

Day 23

Emacs で全世界の文字を表示・編集可能にする。

Last updated at Posted at 2021-12-29

Emacs で、Noto Fonts を全部使い切る設定です。
ついでに、インストールされていないフォントは警告するよう、set-fontset-font にアドバイスしてみます。

(defun set-fontset-font:around (set-fontset-font name target font-spec &optional frame add)
  "Warn if specified font is not installed."
  (if (stringp font-spec) (setq font-spec (font-spec :family font-spec)))
  (if (and (fontp font-spec)
           (null (find-font font-spec)))
      (warn "set-fontset-font: font %s is not found." (font-get font-spec :family))
    (funcall set-fontset-font name target font-spec frame add)))

(advice-add 'set-fontset-font :around #'set-fontset-font:around)

(defun reset-default-fontset ()
  "Reset current fontset."
  (interactive)
  ;; reset all settings in default fontset
  (if (find-font (font-spec :family "Noto Sans"))
      (set-fontset-font t '(0 . #x3fffff) "Noto Sans"))
  ;; multiple platform
  (set-fontset-font t 'latin "Noto Sans")
  (set-fontset-font t 'greek "Noto Sans")
  (set-fontset-font t 'phonetic "Noto Sans")
  (set-fontset-font t 'coptic "Noto Sans Coptic")
  (set-fontset-font t 'coptic "Noto Sans Symbols2" nil 'append)
  (set-fontset-font t 'cyrillic "Noto Sans")
  (set-fontset-font t 'armenian "Noto Sans Armenian")
  (set-fontset-font t 'hebrew "Noto Sans Hebrew")
  (set-fontset-font t 'arabic "Noto Sans Arabic")
  (set-fontset-font t 'syriac "Noto Sans Syriac")
  (set-fontset-font t 'thaana "Noto Sans Thaana")
  (set-fontset-font t 'nko "Noto Sans N'Ko")
  (set-fontset-font t 'samaritan "Noto Sans Samaritan")
  (set-fontset-font t 'mandaic "Noto Sans Mandaic")
  (set-fontset-font t 'devanagari "Noto Sans Devanagari")
  (set-fontset-font t 'bengali "Noto Sans Bengali")
  (set-fontset-font t 'gurmukhi "Noto Sans Gurmukhi")
  (set-fontset-font t 'gujarati "Noto Sans Gujarati")
  (set-fontset-font t 'oriya "Noto Sans Oriya")
  (set-fontset-font t 'tamil "Noto Sans Tamil")
  (set-fontset-font t 'tamil "Noto Sans Tamil Supplement" nil 'append)
  (set-fontset-font t 'telugu "Noto Sans Telugu")
  (set-fontset-font t 'kannada "Noto Sans Kannada")
  (set-fontset-font t 'malayalam "Noto Sans Malayalam")
  (set-fontset-font t 'sinhala "Noto Sans Sinhala")
  (set-fontset-font t 'thai "Noto Sans Thai")
  (set-fontset-font t 'lao "Noto Sans Lao")
  (set-fontset-font t 'tibetan "Noto Sans Tibetan")
  (set-fontset-font t 'burmese "Noto Sans Myanmar")
  (set-fontset-font t 'georgian "Noto Sans Georgian")
  (set-fontset-font t 'hangul "Noto Sans CJK KR")
  (set-fontset-font t 'ethiopic "Noto Sans Ethiopic")
  (set-fontset-font t 'cherokee "Noto Sans Cherokee")
  (set-fontset-font t 'canadian-aboriginal "Noto Sans Canadian Aboriginal")
  (set-fontset-font t 'ogham "Noto Sans Ogham")
  (set-fontset-font t 'runic "Noto Sans Runic")
  (set-fontset-font t 'tagalog "Noto Sans Tagalog")
  (set-fontset-font t 'hanunoo "Noto Sans Hanunoo")
  (set-fontset-font t 'buhid "Noto Sans Buhid")
  (set-fontset-font t 'tagbanwa "Noto Sans Tagbanwa")
  (set-fontset-font t 'khmer "Noto Sans Khmer")
  (set-fontset-font t 'mongolian "Noto Sans Mongolian")
  (set-fontset-font t 'limbu "Noto Sans Limbu")
  (set-fontset-font t 'tai-le "Noto Sans Tai Le")
  (set-fontset-font t 'tai-lue "Noto Sans NewTaiLue")
  (set-fontset-font t 'buginese "Noto Sans Buginese")
  (set-fontset-font t 'tai-tham "Noto Sans Tai Tham")
  (set-fontset-font t 'balinese "Noto Sans Balinese")
  (set-fontset-font t 'sundanese "Noto Sans Sundanese")
  (set-fontset-font t 'vedic "Noto Sans Devanagari")
  (set-fontset-font t 'symbol "Noto Sans CJK JP")
  (set-fontset-font t 'symbol "Noto Sans Symbols2" nil 'append)
  (set-fontset-font t 'symbol "Noto Sans" nil 'append)
  (set-fontset-font t 'symbol "Noto Sans Math" nil 'append)
  (set-fontset-font t 'symbol "Noto Emoji" nil 'append)
  (set-fontset-font t 'symbol "Noto Sans Symbols" nil 'append)
  (set-fontset-font t 'braille "Noto Sans Symbols2")
  (set-fontset-font t 'batak "Noto Sans Batak")
  (set-fontset-font t 'lepcha "Noto Sans Lepcha")
  (set-fontset-font t 'ol-chiki "Noto Sans Ol Chiki")
  (set-fontset-font t 'glagolitic "Noto Sans Glagolitic")
  (set-fontset-font t 'tifinagh "Noto Sans Tifinagh")
  (set-fontset-font t 'han "Noto Sans CJK JP")
  (set-fontset-font t 'ideographic-description "Noto Sans CJK JP")
  (set-fontset-font t 'cjk-misc "Noto Sans CJK JP")
  (set-fontset-font t 'kana "Noto Sans CJK JP")
  (set-fontset-font t 'bopomofo "Noto Sans CJK TC")
  (set-fontset-font t 'kanbun "Noto Sans CJK JP")
  (set-fontset-font t 'yi "Noto Sans Yi")
  (set-fontset-font t 'lisu "Noto Sans Lisu")
  (set-fontset-font t 'vai "Noto Sans Vai")
  (set-fontset-font t 'bamum "Noto Sans Bamum")
  (set-fontset-font t 'syloti-nagri "Noto Sans Syloti Nagri")
  (set-fontset-font t 'north-indic-number "Noto Sans Devanagari")
  (set-fontset-font t 'phags-pa "Noto Sans Phags Pa")
  (set-fontset-font t 'saurashtra "Noto Sans Saurashtra")
  (set-fontset-font t 'kayah-li "Noto Sans Kayah Li")
  (set-fontset-font t 'rejang "Noto Sans Rejang")
  (set-fontset-font t 'javanese "Noto Sans Javanese")
  (set-fontset-font t 'cham "Noto Sans Cham")
  (set-fontset-font t 'tai-viet "Noto Sans Tai Viet")
  (set-fontset-font t 'meetei-mayek "Noto Sans Meetei Mayek")
  (set-fontset-font t 'vertical-form "Noto Sans CJK JP")
  ;; (set-fontset-font t '(#xfe50 . #xfe6b) "Noto Sans CJK JP") ; symbol
  (set-fontset-font t '(#xfff9 . #xfffb) "Noto Sans Symbols2") ; nil
  (set-fontset-font t 'linear-b "Noto Sans Linear B")
  (set-fontset-font t 'aegean-number "Noto Sans Linear B")
  (set-fontset-font t 'ancient-greek-number "Noto Sans Symbols2")
  (set-fontset-font t 'ancient-symbol "Noto Sans Symbols2")
  (set-fontset-font t 'phaistos-disc "Noto Sans Symbols2")
  (set-fontset-font t 'lycian "Noto Sans Lycian")
  (set-fontset-font t 'carian "Noto Sans Carian")
  (set-fontset-font t 'old-italic "Noto Sans Old Italic")
  (set-fontset-font t 'gothic "Noto Sans Gothic")
  (set-fontset-font t 'old-permic "Noto Sans Old Permic")
  (set-fontset-font t 'ugaritic "Noto Sans Ugaritic")
  (set-fontset-font t 'old-persian "Noto Sans OldPersian")
  (set-fontset-font t 'deseret "Noto Sans Deseret")
  (set-fontset-font t 'shavian "Noto Sans Shavian")
  (set-fontset-font t 'osmanya "Noto Sans Osmanya")
  (set-fontset-font t 'osage "Noto Sans Osage")
  (set-fontset-font t 'elbasan "Noto Sans Elbasan")
  (set-fontset-font t 'caucasian-albanian "Noto Sans CaucAlban")
  (set-fontset-font t 'linear-a "Noto Sans Linear A")
  (set-fontset-font t 'cypriot-syllabary "Noto Sans Cypriot")
  (set-fontset-font t 'aramaic "Noto Sans ImpAramaic")
  (set-fontset-font t 'palmyrene "Noto Sans Palmyrene")
  (set-fontset-font t 'nabataean "Noto Sans Nabataean")
  (set-fontset-font t 'hatran "Noto Sans Hatran")
  (set-fontset-font t 'phoenician "Noto Sans Phoenician")
  (set-fontset-font t 'lydian "Noto Sans Lydian")
  (set-fontset-font t 'meroitic "Noto Sans Meroitic")
  (set-fontset-font t 'kharoshthi "Noto Sans Kharoshthi")
  (set-fontset-font t 'old-south-arabian "Noto Sans OldSouArab")
  (set-fontset-font t 'old-north-arabian "Noto Sans OldNorArab")
  (set-fontset-font t 'manichaean "Noto Sans Manichaean")
  (set-fontset-font t 'avestan "Noto Sans Avestan")
  (set-fontset-font t 'inscriptional-parthian "Noto Sans Inscriptional Parthian")
  (set-fontset-font t 'inscriptional-pahlavi "Noto Sans Inscriptional Pahlavi")
  (set-fontset-font t 'psalter-pahlavi "Noto Sans PsaPahlavi")
  (set-fontset-font t 'old-turkic "Noto Sans Old Turkic")
  (set-fontset-font t 'old-hungarian "Noto Sans OldHung")
  (set-fontset-font t 'hanifi-rohingya "Noto Sans HanifiRohg")
  (set-fontset-font t 'rumi-number "Noto Sans Symbols2")
  (set-fontset-font t 'old-sogdian "Noto Sans OldSogdian")
  (set-fontset-font t 'sogdian "Noto Sans Sogdian")
  (set-fontset-font t 'elymaic "Noto Sans Elymaic")
  (set-fontset-font t 'brahmi "Noto Sans Brahmi")
  (set-fontset-font t 'kaithi "Noto Sans Kaithi")
  (set-fontset-font t 'sora-sompeng "Noto Sans SoraSomp")
  (set-fontset-font t 'chakma "Noto Sans Chakma")
  (set-fontset-font t 'mahajani "Noto Sans Mahajani")
  (set-fontset-font t 'sharada "Noto Sans Sharada")
  (set-fontset-font t 'sinhala-archaic-number "Noto Sans Sinhala")
  (set-fontset-font t 'khojki "Noto Sans Khojki")
  (set-fontset-font t 'multani "Noto Sans Multani")
  (set-fontset-font t 'khudawadi "Noto Sans Khudawadi")
  (set-fontset-font t 'grantha "Noto Sans Grantha")
  (set-fontset-font t 'newa "Noto Sans Newa")
  (set-fontset-font t 'tirhuta "Noto Sans Tirhuta")
  (set-fontset-font t 'siddham "Noto Sans Siddham")
  (set-fontset-font t 'modi "Noto Sans Modi")
  (set-fontset-font t 'takri "Noto Sans Takri")
  (set-fontset-font t 'ahom "Noto Serif Ahom")
  (set-fontset-font t 'dogra "Noto Serif Dogra")
  (set-fontset-font t 'warang-citi "Noto Sans WarangCiti")
  (set-fontset-font t 'zanabazar-square "Noto Sans Zanabazar")
  (set-fontset-font t 'soyombo "Noto Sans Soyombo")
  (set-fontset-font t 'pau-cin-hau "Noto Sans PauCinHau")
  (set-fontset-font t 'bhaiksuki "Noto Sans Bhaiksuki")
  (set-fontset-font t 'marchen "Noto Sans Marchen")
  (set-fontset-font t 'masaram-gondi "Noto Sans Masaram Gondi")
  (set-fontset-font t 'gunjala-gondi "Noto Sans Gunjala Gondi")
  (set-fontset-font t 'cuneiform "Noto Sans Cuneiform")
  (set-fontset-font t 'cuneiform-numbers-and-punctuation "Noto Sans Cuneiform")
  (set-fontset-font t 'egyptian "Noto Sans EgyptHiero")
  (set-fontset-font t 'anatolian "Noto Sans AnatoHiero")
  (set-fontset-font t 'mro "Noto Sans Mro")
  (set-fontset-font t 'bassa-vah "Noto Sans Bassa Vah")
  (set-fontset-font t 'pahawh-hmong "Noto Sans Pahawh Hmong")
  (set-fontset-font t 'miao "Noto Sans Miao")
  (set-fontset-font t 'tangut "Noto Serif Tangut")
  (set-fontset-font t 'tangut-components "Noto Serif Tangut")
  (set-fontset-font t '(#x16fe0 . #x16fe0) "Noto Serif Tangut")
  (set-fontset-font t 'duployan-shorthand "Noto Sans Duployan")
  (set-fontset-font t 'byzantine-musical-symbol "Noto Music")
  (set-fontset-font t 'musical-symbol "Noto Music")
  (set-fontset-font t 'ancient-greek-musical-notation "Noto Music")
  (set-fontset-font t 'mayan-numeral "Noto Sans Mayan Numerals")
  (set-fontset-font t 'tai-xuan-jing-symbol "Noto Sans Symbols2")
  (set-fontset-font t 'counting-rod-numeral "Noto Sans Symbols2")
  (set-fontset-font t 'mathematical "Noto Sans Math")
  (set-fontset-font t 'wancho "Noto Sans Wancho")
  (set-fontset-font t 'mende-kikakui "Noto Sans Mende Kikakui")
  (set-fontset-font t 'adlam "Noto Sans Adlam")
  (set-fontset-font t 'indic-siyaq-number "Noto Sans Indic Siyaq Numbers")
  (set-fontset-font t '(#x1ee00 . #x1eeff) "Noto Sans Math") ; arabic
  (set-fontset-font t 'mahjong-tile "Noto Sans Symbols2")
  (set-fontset-font t 'domino-tile "Noto Sans Symbols2")
  (set-fontset-font t 'playing-cards "Noto Sans Symbols2")
  ;; non Noto fonts
  (set-fontset-font t 'kana "UniHentaiKana" nil 'append)
  (set-fontset-font t 'latin "Iosevka" nil 'append)
  (set-fontset-font t 'symbol "Iosevka" nil 'append)
  ;; Nerd Font (defined thru -#xfd46)
  (set-fontset-font t '( #xe000 .  #xf136) "Inconsolata Nerd Font")
  ;;
  (when (eq window-system 'w32)
    (set-fontset-font t 'bengali    "Nirmala UI" nil 'prepend)
    (set-fontset-font t 'gurmukhi   "Nirmala UI" nil 'prepend)
    (set-fontset-font t 'gujarati   "Nirmala UI" nil 'prepend)
    (set-fontset-font t 'telugu     "Nirmala UI" nil 'prepend)
    (set-fontset-font t 'kannada    "Nirmala UI" nil 'prepend)
    (set-fontset-font t 'malayalam  "Nirmala UI" nil 'prepend)
    (set-fontset-font t 'vedic      "Nirmala UI" nil 'prepend)
    (set-fontset-font t 'devanagari "Nirmala UI" nil 'prepend)
    (set-fontset-font t 'brahmi     "Segoe UI Historic" nil 'prepend)
    (set-fontset-font t 'georgian   "Segoe UI" nil 'prepend)
    (set-fontset-font t '( #x0300 .  #x1cff) "Arial" nil 'append) 
    (set-fontset-font t '( #x2000 .  #x27bf) "Segoe UI Symbol" nil 'append)
    (set-fontset-font t '( #x2e00 .  #xdfff) "花園明朝 A Regular" nil 'append)
    (set-fontset-font t '( #xfe0e .  #xfe0f) "Segoe UI Emoji")
    (set-fontset-font t '( #xf137 .  #xf69d) "花園明朝 A Regular")
    (set-fontset-font t '(#x1b000 . #x1b000) "Meiryo UI")
    (set-fontset-font t '(#x1f300 . #x1f9ff) "Segoe UI Emoji" nil 'append)
    (set-fontset-font t '(#x1fa70 . #x1fbff) "Segoe UI Emoji" nil 'append)
    (set-fontset-font t '(#x1f900 . #x1f9e0) "Segoe UI Emoji" nil 'append)
    (set-fontset-font t '(#x20000 . #x2a6ff) "花園明朝 B Regular")
    (set-fontset-font t '(#x2a700 . #x2fffd) "花園明朝 C Regular"))
  (when (not (eq system-type 'windows-nt))
    (set-fontset-font t '( #x2e00 .  #xdfff) "Hanazono Mincho A Regular" nil 'append)
    (set-fontset-font t '( #xf137 .  #xf69d) "Hanazono Mincho A Regular")
    (set-fontset-font t '(#x20000 . #x2a6ff) "Hanazono Mincho B Regular")
    (set-fontset-font t '(#x2a700 . #x2fffd) "Hanazono Mincho C Regular")
    ))

【追記】

  • Unicode は、連続符号領域をブロックとして定義しており、Emacs Lisp でも、これに準じた文字符号ブロック名シンボルを、set-fontset-font 関数の第二引数に指定できます。
  • しかしながら、歴史的経緯により、同じ符号化集合やデザインの文字、そして1つのフォントがカバーする文字が、複数の異なるブロックに跨がることがあります。
  • Noto Fonts は、Google が中心となって作成している、全世界の文字をカバーする (NO TOfu) ことを目的としたフォント群ですが、上記の事情により、必ずしも各フォントは各ブロックと対応しません。
  • 本設定は、可能な限りUnicodeで定義されている文字を、Notoフォントファミリーでカバーできるよう、 set-fontset-font 関数で設定したものです。
  • Noto 以外の部分、特にラテン文字と日本語に使う文字については、各人が好みで自分のフォントを指定してください。
14
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?