How can I get :size from font-spec using Elisp?

1 Answer 1


What about the function font-get? For example:

(font-get (font-spec :size 10) :size) ; => 10

Quoth its docstring:

font-get is a built-in function in `C source code'.

(font-get FONT KEY)

  Probably introduced at or before Emacs version 23.1.

Return the value of FONT's property KEY.
FONT is a font-spec, a font-entity, or a font-object.
KEY is any symbol, but these are reserved for specific meanings:
  :family, :weight, :slant, :width, :foundry, :adstyle, :registry,
  :size, :name, :script, :otf
See the documentation of `font-spec' for their meanings.
In addition, if FONT is a font-entity or a font-object, values of
:script and :otf are different from those of a font-spec as below:

The value of :script may be a list of scripts that are supported by the font.

The value of :otf is a cons (GSUB . GPOS) where GSUB and GPOS are lists
representing the OpenType features supported by the font by this form:
  ((SCRIPT (LANGSYS FEATURE ...) ...) ...)
SCRIPT, LANGSYS, and FEATURE are all symbols representing OpenType
Layout tags.

In addition to the keys listed abobe, the following keys are reserved
for the specific meanings as below:

The value of :combining-capability is non-nil if the font-backend of
FONT supports rendering of combining characters for non-OTF fonts.

Quoth (info "(elisp) Low-Level Font"):

   The following functions can be used to obtain information about a
font.  For these functions, the FONT argument can be a font object, a
font entity, or a font spec.

 -- Function: font-get font property
     This function returns the value of the font property PROPERTY for

     If FONT is a font spec and the font spec does not specify PROPERTY,
     the return value is ‘nil’.  If FONT is a font object or font
     entity, the value for the :SCRIPT property may be a list of scripts
     supported by the font.

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.