unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* `font-spec` unable to retrieve :name of font
@ 2015-10-13  2:13 Alexis
  2015-10-22  8:48 ` Ping! " Alexis
  0 siblings, 1 reply; 9+ messages in thread
From: Alexis @ 2015-10-13  2:13 UTC (permalink / raw)
  To: emacs-devel


Hi all,

Having tried various alternatives, i now use Inconsolata-g as my 
preferred general Emacs font:

    http://leonardo-m.livejournal.com/77079.html

using Xft as my Emacs font backend.

In trying to use the `company-quickhelp` package, however, i 
discovered that it wasn't working due to a call to `pos-tip-show`, 
which in turn essentially calls:

    (font-spec :name (frame-parameter (window-frame 
    (selected-window)) 'font))

This call results in:

    (error "Invalid font name: 
    -unknown-Inconsolata-g-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1")

which is, of course, due to the dash in the font name; the X 
Logical Font Description Conventions:

    http://www.x.org/releases/X11R7.6/doc/xorg-docs/specs/XLFD/xlfd.html#fontname_syntax

exclude the dash/hyphen as a valid in-field character.

What, if anything, can be done about this? Should this be 
considered a bug, or "working as intended"?


Alexis.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Ping! Re: `font-spec` unable to retrieve :name of font
  2015-10-13  2:13 `font-spec` unable to retrieve :name of font Alexis
@ 2015-10-22  8:48 ` Alexis
  2015-10-22 14:59   ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Alexis @ 2015-10-22  8:48 UTC (permalink / raw)
  To: emacs-devel


Ping! Does anyone have any thoughts on the below? TIA!

Alexis <flexibeast@gmail.com> writes:

> Hi all,
>
> Having tried various alternatives, i now use Inconsolata-g as my 
> preferred general Emacs font:
>
>     http://leonardo-m.livejournal.com/77079.html
>
> using Xft as my Emacs font backend.
>
> In trying to use the `company-quickhelp` package, however, i 
> discovered that it wasn't working due to a call to 
> `pos-tip-show`,  which in turn essentially calls:
>
>     (font-spec :name (frame-parameter (window-frame 
>     (selected-window)) 'font))
>
> This call results in:
>
>     (error "Invalid font name: 
>     -unknown-Inconsolata-g-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1")
>
> which is, of course, due to the dash in the font name; the X 
> Logical Font Description Conventions:
>
>     http://www.x.org/releases/X11R7.6/doc/xorg-docs/specs/XLFD/xlfd.html#fontname_syntax
>
> exclude the dash/hyphen as a valid in-field character.
>
> What, if anything, can be done about this? Should this be 
> considered a bug, or "working as intended"?
>
>
> Alexis.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ping! Re: `font-spec` unable to retrieve :name of font
  2015-10-22  8:48 ` Ping! " Alexis
@ 2015-10-22 14:59   ` Eli Zaretskii
  2015-10-23  9:55     ` Alexis
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2015-10-22 14:59 UTC (permalink / raw)
  To: Alexis; +Cc: emacs-devel

> From: Alexis <flexibeast@gmail.com>
> Date: Thu, 22 Oct 2015 19:48:09 +1100
> 
> Ping! Does anyone have any thoughts on the below? TIA!

Sorry for not responding earlier.

> Having tried various alternatives, i now use Inconsolata-g as my preferred general Emacs font:
> 
>    http://leonardo-m.livejournal.com/77079.html
> 
> using Xft as my Emacs font backend.

Using such fonts is unwise, see below.

> In trying to use the `company-quickhelp` package, however, i discovered that it wasn't working due to a call to `pos-tip-show`, which in turn essentially calls:
> 
> (font-spec :name (frame-parameter (window-frame (selected-window)) 'font))
> 
> This call results in:

> (error "Invalid font name: -unknown-Inconsolata-g-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1")
> 
> which is, of course, due to the dash in the font name; the X Logical Font Description Conventions:
> 
> http://www.x.org/releases/X11R7.6/doc/xorg-docs/specs/XLFD/xlfd.html#fontname_syntax
> 
> exclude the dash/hyphen as a valid in-field character.
> 
> What, if anything, can be done about this? Should this be considered a bug, or "working as intended"?

Emacs's font handling is deeply entrenched in the XLFD spec.  That is
true even on platforms that don't support XLFD, such as MS-Windows.
So this is not a bug, it's the intended behavior, the code is working
as designed.

That said, I had a similar problem with fonts named like Foobar-12,
see commit 7d5a7a4 which solved that.  (The original problem is
described in the discussion that started in
http://lists.gnu.org/archive/html/help-emacs-windows/2015-06/msg00001.html.)
That problem could be solved because the part after the dash was a
number, and a font's family cannot be a number.  I don't know if we
can do the same with this case.  Which "family" names are we allowed
to reject, exactly?  Don't forget that the weight field of the XLFD
spec, which follows the family, uses single-letter codes (although
AFAIK "g" is not one of them); we ought not to trick ourselves into
accidentally treating weight as part of the font name.

I guess we need advice from some expert on fonts, but I don't know if
we have such a person on board.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ping! Re: `font-spec` unable to retrieve :name of font
  2015-10-22 14:59   ` Eli Zaretskii
@ 2015-10-23  9:55     ` Alexis
  2015-10-24 17:45       ` Nix
  0 siblings, 1 reply; 9+ messages in thread
From: Alexis @ 2015-10-23  9:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


Eli Zaretskii <eliz@gnu.org> writes:

> Sorry for not responding earlier.

That's okay!

> Emacs's font handling is deeply entrenched in the XLFD spec. 
> That is true even on platforms that don't support XLFD, such as 
> MS-Windows.  So this is not a bug, it's the intended behavior, 
> the code is working as designed.

*nod* Fair enough.

> That said, I had a similar problem with fonts named like 
> Foobar-12, see commit 7d5a7a4 which solved that.  (The original 
> problem is described in the discussion that started in 
> http://lists.gnu.org/archive/html/help-emacs-windows/2015-06/msg00001.html.) 
> That problem could be solved because the part after the dash was 
> a number, and a font's family cannot be a number.  I don't know 
> if we can do the same with this case. Which "family" names are 
> we allowed to reject, exactly?  Don't forget that the weight 
> field of the XLFD spec, which follows the family, uses 
> single-letter codes (although AFAIK "g" is not one of them); we 
> ought not to trick ourselves into accidentally treating weight 
> as part of the font name.

Yes, i gave some thought to possible heuristics that could be used 
in instances such as this, but didn't come up with anything 
practical .... i might see if i can use FontForge to change the 
name to something XLFD-friendly (e.g. 'InconsolataG').

Thanks!


Alexis.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ping! Re: `font-spec` unable to retrieve :name of font
  2015-10-23  9:55     ` Alexis
@ 2015-10-24 17:45       ` Nix
  2015-10-24 17:57         ` Eli Zaretskii
  2015-10-24 18:04         ` Drew Adams
  0 siblings, 2 replies; 9+ messages in thread
From: Nix @ 2015-10-24 17:45 UTC (permalink / raw)
  To: Alexis; +Cc: Eli Zaretskii, emacs-devel

On 23 Oct 2015, Alexis told this:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> That said, I had a similar problem with fonts named like Foobar-12, see commit 7d5a7a4 which solved that.  (The original problem
>> is described in the discussion that started in http://lists.gnu.org/archive/html/help-emacs-windows/2015-06/msg00001.html.) That
>> problem could be solved because the part after the dash was a number, and a font's family cannot be a number.  I don't know if we
>> can do the same with this case. Which "family" names are we allowed to reject, exactly?  Don't forget that the weight field of the
>> XLFD spec, which follows the family, uses single-letter codes (although AFAIK "g" is not one of them); we ought not to trick
>> ourselves into accidentally treating weight as part of the font name.
>
> Yes, i gave some thought to possible heuristics that could be used in instances such as this, but didn't come up with anything
> practical .... i might see if i can use FontForge to change the name to something XLFD-friendly (e.g. 'InconsolataG').

This seems like a transformation Emacs should be doing itself. It
doesn't need to be a *pretty* transformation: after all, the XLFD
variant is never going to be displayed to the user, nor passed to
Fontconfig: it's just an internal thing for parts of Emacs expecting
XLFDs.

-- 
NULL && (void)



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ping! Re: `font-spec` unable to retrieve :name of font
  2015-10-24 17:45       ` Nix
@ 2015-10-24 17:57         ` Eli Zaretskii
  2015-10-24 18:04         ` Drew Adams
  1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2015-10-24 17:57 UTC (permalink / raw)
  To: Nix; +Cc: flexibeast, emacs-devel

> From: Nix <nix@esperi.org.uk>
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> Emacs: the Swiss Army of Editors.
> Date: Sat, 24 Oct 2015 18:45:24 +0100
> 
> > i might see if i can use FontForge to change the name to something XLFD-friendly (e.g. 'InconsolataG').
> 
> This seems like a transformation Emacs should be doing itself.

That's a chicken-and-egg problem: Emacs gets the XLFD name from a font
back-end, so it cannot change the name unless it has a means to deduce
that the -g part is not an XLFD field, but part of the name.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Ping! Re: `font-spec` unable to retrieve :name of font
  2015-10-24 17:45       ` Nix
  2015-10-24 17:57         ` Eli Zaretskii
@ 2015-10-24 18:04         ` Drew Adams
  2015-10-26 14:10           ` Nix
  1 sibling, 1 reply; 9+ messages in thread
From: Drew Adams @ 2015-10-24 18:04 UTC (permalink / raw)
  To: Nix, Alexis; +Cc: Eli Zaretskii, emacs-devel

> after all, the XLFD variant is never going to be displayed to the user,
> nor passed to Fontconfig: it's just an internal thing for parts of
> Emacs expecting XLFDs.

Just a comment on this part of what you wrote.

XLFD format _is_ visible to users.  And it can be used by them.

I use it, for example, to transform a font to another of a
different size, resulting also in a frame of a different size.
This use case is quite important to my use of Emacs, FWIW.

----

(defun frcmds-enlarged-font-name (fontname frame increment)
  "FONTNAME, after enlarging font size of FRAME by INCREMENT.
FONTNAME is the font of FRAME."
  (when (query-fontset fontname)
    (let ((ascii  (assq 'ascii (aref (fontset-info fontname frame) 2))))
      (when ascii (setq fontname  (nth 2 ascii)))))
  (let ((xlfd-fields  (x-decompose-font-name fontname)))
    (unless xlfd-fields (error "Cannot decompose font name"))
    (let ((new-size  (+ (string-to-number
                          (aref xlfd-fields
                                xlfd-regexp-pixelsize-subnum))
                        increment)))
      (unless (> new-size 0) (signal 'font-too-small (list new-size)))
      (aset xlfd-fields xlfd-regexp-pixelsize-subnum
            (number-to-string new-size)))
    ;; Set point size & width to "*", so frame width will adjust to
    ;; new font size
    (aset xlfd-fields xlfd-regexp-pointsize-subnum "*")
    (aset xlfd-fields xlfd-regexp-avgwidth-subnum "*")
    (x-compose-font-name xlfd-fields)))



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ping! Re: `font-spec` unable to retrieve :name of font
  2015-10-24 18:04         ` Drew Adams
@ 2015-10-26 14:10           ` Nix
  2015-10-27  2:32             ` Stephen J. Turnbull
  0 siblings, 1 reply; 9+ messages in thread
From: Nix @ 2015-10-26 14:10 UTC (permalink / raw)
  To: Drew Adams; +Cc: Eli Zaretskii, Alexis, emacs-devel

On 24 Oct 2015, Drew Adams said:

>> after all, the XLFD variant is never going to be displayed to the user,
>> nor passed to Fontconfig: it's just an internal thing for parts of
>> Emacs expecting XLFDs.
>
> Just a comment on this part of what you wrote.
>
> XLFD format _is_ visible to users.  And it can be used by them.
>
> I use it, for example, to transform a font to another of a
> different size, resulting also in a frame of a different size.
> This use case is quite important to my use of Emacs, FWIW.

In that case we need an escaping mechanism even more :) it just needs to
gain an additional requirement: not to be pig ugly.

-- 
NULL && (void)



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Ping! Re: `font-spec` unable to retrieve :name of font
  2015-10-26 14:10           ` Nix
@ 2015-10-27  2:32             ` Stephen J. Turnbull
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen J. Turnbull @ 2015-10-27  2:32 UTC (permalink / raw)
  To: Nix; +Cc: Eli Zaretskii, Alexis, Drew Adams, emacs-devel

Nix writes:

 > In that case we need an escaping mechanism even more :) it just
 > needs to gain an additional requirement: not to be pig ugly.

A tall order, when you start with XLFD.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-10-27  2:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13  2:13 `font-spec` unable to retrieve :name of font Alexis
2015-10-22  8:48 ` Ping! " Alexis
2015-10-22 14:59   ` Eli Zaretskii
2015-10-23  9:55     ` Alexis
2015-10-24 17:45       ` Nix
2015-10-24 17:57         ` Eli Zaretskii
2015-10-24 18:04         ` Drew Adams
2015-10-26 14:10           ` Nix
2015-10-27  2:32             ` Stephen J. Turnbull

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).