0

I use Ben Whitmore's excellent http://benwhitmore.altervista.org/coelacanth-type-family/Coelacanth font in org-mode. The font family is provided in several OTF files.

Setting xfthb:-PfEd-Coelacanth-light-normal-normal-*-22-*-*-*-*-0-iso10646-1 as variable-pitch works well and looks good.

But I'm unable to set the italic face to Coelacanth's Italic. I tried the Customize Face dialogue, I tried Lisp expressions with variations of the xfthb string above, with one or more normals substituted with italic, but the result looks like (and is, by C-u C-x =) the uninitializied version.

3 Answers 3

0

Totally unintuitive, but works:

(create-fontset-from-fontset-spec
    "-PfEd-Coelacanth-normal-italic-normal-*-*-*-*-*-*-0-fontset-custom")
(set-face-attribute 'italic nil :font "fontset-custom")
1
  • I blindly tried the above snippet on GNU Emacs 29.0.50 dtd build date 2022-06-11. Emacs gives me a *Backtrace*. Either we are using a different font files, or we are using different OS-es, or Emacs has moved since . For those looking into generating custom fontsets, a better starting point would be emacs.stackexchange.com/a/70338/31220. Honestly speaking, I don't understand what is being discussed, but I know for sure that strings like "-PfEd-Coelacanth-normal-italic-normal-------0-fontset-custom" is the last thing an ordinary user like me would like to see.
    – user31220
    Commented Jul 2, 2022 at 6:15
0

TLDR:

  1. Emacs gives primacy to the font family name. This is in spite of the fact that the Menu Bar -> Options -> Set Default Font displays the Font Name and NOT the Family Name.
  2. None of the Coelacanth font files, defines slant property. So, it is not surprising that Emacs doesn't honour the italic property requested in slant property.

I installed Coelacanth font from http://benwhitmore.altervista.org/wp-content/uploads/2014/08/Coelacanth20140829.zip. See Coelacanth: a type family inspired by Bruce Rogers' Centaur.

I set the default font using Menu Bar -> Options -> Set Default Font as below

Set Default Font to Coelacanth Italic

The default font wasn't typeset in Italic.

To investigate this behaviour further, I eval-led the following forms

(face-attribute 'default :font)
=> 

   #<font-object "-PfEd-Coelacanth-medium-normal-normal-*-15-*-*-*-*-0-iso10646-1">

(font-info (face-attribute 'default :font))
=> 

   ["-PfEd-Coelacanth-medium-normal-normal-*-15-*-*-*-*-0-iso10646-1"
 "Coelacanth:pixelsize=15:foundry=PfEd:weight=medium:slant=normal:width=normal:scalable=true"
 15 20 0 0 0 17 14 6 3 7 "~/.local/share/fonts/Coelac_R14.otf"
 (opentype
  ...)]

You can see that font file used is Coelac_R14.otf, and the fontspec doesn't have any italic in it.

Then I did this

~$ echo "|%{fullname}| %{file} | %{foundry} | %{family}| %{slant}|\n"; fc-list -f "|%{fullname} |%{file} | %{foundry} | %{family}| %{slant}|\n" | grep 'Coela' 

| %{fullname}             | %{file}        | %{foundry} | %{family}          | %{slant} |
| Coelacanth_Regular 24op | Coelac_R24.otf | PfEd       | Coelacanth         |        0 |
| CoelacanthLight 14op    | Coelac_L14.otf | PfEd       | CoelacanthLight    |        0 |
| CoelacanthSemibold 14op | Coelac_S14.otf | PfEd       | CoelacanthSemibold |        0 |
| CoelacanthLight 4op     | Coelac_L4.otf  | PfEd       | CoelacanthLight    |        0 |
| CoelacanthLight 6op     | Coelac_L6.otf  | PfEd       | CoelacanthLight    |        0 |
| CoelacanthHeavy 14op    | Coelac_H14.otf | PfEd       | CoelacanthHeavy    |        0 |
| Coelacanth_Bold 8op     | Coelac_B8.otf  | PfEd       | Coelacanth         |        0 |
| Coelacanth_Regular 14op | Coelac_R14.otf | PfEd       | Coelacanth         |        0 |
| Coelacanth_Bold 6op     | Coelac_B6.otf  | PfEd       | Coelacanth         |        0 |
| Coelacanth_Bold 4op     | Coelac_B4.otf  | PfEd       | Coelacanth         |        0 |
| CoelacanthLight_8op     | Coelac_L8.otf  | PfEd       | CoelacanthLight    |        0 |
| Coelacanth_Bold 14op    | Coelac_B14.otf | PfEd       | Coelacanth         |        0 |
| CoelacanthSemibold_6op  | Coelac_S6.otf  | PfEd       | CoelacanthSemibold |        0 |
| CoelacanthSemibold_8op  | Coelac_S8.otf  | PfEd       | CoelacanthSemibold |        0 |
| Coelacanth_Regular 60op | Coelac_R60.otf | PfEd       | Coelacanth         |        0 |
| Coelacanth Italic       | Coelac14-I.otf | PfEd       | Coelacanth         |        0 |
| CoelacanthSemibold 4op  | Coelac_S4.otf  | PfEd       | CoelacanthSemibold |        0 |
| Coelacanth_Regular 6op  | Coelac_R6.otf  | PfEd       | Coelacanth         |        0 |
| Coelacanth_Regular 4op  | Coelac_R4.otf  | PfEd       | Coelacanth         |        0 |
| Coelacanth_Regular 8op  | Coelac_R8.otf  | PfEd       | Coelacanth         |        0 |

There are 2 things you can notice in above output

  1. The Coelacanth Italic comes from Coelac14-I.otf. It's family name is Coelacanth
  2. The slant of the font is 0.

The reason that Emacs is not picking up this font file, is because the font file doesn't declare the slant property. (When you set up italic face, Emacs is essentially looking for a font-entity that defines the slant.)

So, what I did was open the font file, which was providing the italic font, but NOT the slant property, and fixed the font family as below.

~$ fontforge ~/.local/share/fonts/Coelac14-I.otf

In Fontforge, change Family Name to Coelacanth Italic

followed by Fontforge -> Menu bar -> File -> Generate Fonts.

Then I updated the font cache with,

$ fc-cache -f -v

I restarted Emacs, set the default font---Menu bar -> Options -> Set Default Font---to one of the Coelacanth fonts.

Then I did, M-x customize-face RET italic as before and I applied the changes.

Use the newly defined Coelocanth Italic family for `italic face


Font configuration - ArchWiki claims the following

Create bold and italic styles for incomplete fonts

FreeType has the ability to automatically create italic and bold styles for fonts that do not have them, but only if explicitly required by the application.

Since Emacs is a very old beast, I wouldn't be surprised if Emacs goes an extra step in creating italic style out of "incomplete" fonts.

0

The solution to original question is here https://emacs.stackexchange.com/a/72415/31220.

This is some supplemental elisp helpers that I used to make some sense of what Emacs is doing underneath ...

Snippets to look at font family and their component fonts


;; See `mouse-generate-font-menu'
(require 'dash)
(->> (font-family-list)
     (--filter (string-match-p "Coelacanth" it)) ; change the family name, if requried
     -uniq
     (--map
      (cons it
        (if nil       ; flip this to t, for simpler result
        (x-family-fonts it)
          (->> (list-fonts (font-spec :family it))
           (--map (list it :name (or (font-get it :name)
                         (mouse-generate-font-name-for-menu it))
                :xlfd-name (font-xlfd-name it))))))))

which gives me


(("CoelacanthSemibold"
  (#<font-entity ftcrhb PfEd CoelacanthSemibold nil iso10646-1 semi-bold normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_S4.otf" . 0))
         > :name "semi-bold" :xlfd-name "-PfEd-CoelacanthSemibold-semibold-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd CoelacanthSemibold nil iso10646-1 semi-bold normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_S6.otf" . 0))
         > :name "semi-bold" :xlfd-name "-PfEd-CoelacanthSemibold-semibold-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd CoelacanthSemibold nil iso10646-1 semi-bold normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_S8.otf" . 0))
         > :name "semi-bold" :xlfd-name "-PfEd-CoelacanthSemibold-semibold-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd CoelacanthSemibold nil iso10646-1 semi-bold normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_S14.otf" . 0))
         > :name "semi-bold" :xlfd-name "-PfEd-CoelacanthSemibold-semibold-normal-normal-*-*-*-*-*-*-0-iso10646-1"))
 ("CoelacanthLight"
  (#<font-entity ftcrhb PfEd CoelacanthLight nil iso10646-1 light normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_L8.otf" . 0))
         > :name "light" :xlfd-name "-PfEd-CoelacanthLight-light-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd CoelacanthLight nil iso10646-1 light normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_L6.otf" . 0))
         > :name "light" :xlfd-name "-PfEd-CoelacanthLight-light-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd CoelacanthLight nil iso10646-1 light normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_L4.otf" . 0))
         > :name "light" :xlfd-name "-PfEd-CoelacanthLight-light-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd CoelacanthLight nil iso10646-1 light normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_L14.otf" . 0))
         > :name "light" :xlfd-name "-PfEd-CoelacanthLight-light-normal-normal-*-*-*-*-*-*-0-iso10646-1"))
 ("Coelacanth Italic"
  (#<font-entity ftcrhb PfEd Coelacanth\ Italic nil iso10646-1 medium normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac-I.ttf" . 0))
         > :name "medium" :xlfd-name "-PfEd-Coelacanth Italic-medium-normal-normal-*-*-*-*-*-*-0-iso10646-1"))
 ("Coelacanth"
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 medium normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_R4.otf" . 0))
         > :name "medium" :xlfd-name "-PfEd-Coelacanth-medium-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 regular normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_R6.otf" . 0))
         > :name "regular" :xlfd-name "-PfEd-Coelacanth-regular-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 regular normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_R24.otf" . 0))
         > :name "regular" :xlfd-name "-PfEd-Coelacanth-regular-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 bold normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_B14.otf" . 0))
         > :name "bold" :xlfd-name "-PfEd-Coelacanth-bold-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 medium normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_R14.otf" . 0))
         > :name "medium" :xlfd-name "-PfEd-Coelacanth-medium-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 regular normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_R8.otf" . 0))
         > :name "regular" :xlfd-name "-PfEd-Coelacanth-regular-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 medium normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac14-I.otf" . 0))
         > :name "medium" :xlfd-name "-PfEd-Coelacanth-medium-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 bold normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_B8.otf" . 0))
         > :name "bold" :xlfd-name "-PfEd-Coelacanth-bold-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 bold normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_B4.otf" . 0))
         > :name "bold" :xlfd-name "-PfEd-Coelacanth-bold-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 bold normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_B6.otf" . 0))
         > :name "bold" :xlfd-name "-PfEd-Coelacanth-bold-normal-normal-*-*-*-*-*-*-0-iso10646-1")
  (#<font-entity ftcrhb PfEd Coelacanth nil iso10646-1 medium normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_R60.otf" . 0))
         > :name "medium" :xlfd-name "-PfEd-Coelacanth-medium-normal-normal-*-*-*-*-*-*-0-iso10646-1"))
 ("CoelacanthHeavy"
  (#<font-entity ftcrhb PfEd CoelacanthHeavy nil iso10646-1 black normal normal 0 nil nil 0
         ((:font-entity "~/.local/share/fonts/Coelac_H14.otf" . 0))
         > :name "black" :xlfd-name "-PfEd-CoelacanthHeavy-black-normal-normal-*-*-*-*-*-*-0-iso10646-1")))

Your Answer

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

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