unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Text scale mode and additional fonts
@ 2023-12-30 11:10 Rahguzar
  2023-12-30 17:47 ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Rahguzar @ 2023-12-30 11:10 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,
I sometimes write documents with a mix of Urdu and English. For Urdu I
have this in my config:

(setq +bidi-arabic-font (font-spec :family "Mehr Nastaliq Web"))

(set-fontset-font t 'arabic +bidi-arabic-font)

The font can be found here
https://mehrtype.com/product/mehr-nastaliq-web/

This works but Urdu text is too small. I can use `text-scale-increase`
but that also makes the English text bigger. So I tried this snippet
instead:

(setq +bidi-arabic-font (font-spec :family "Mehr Nastaliq Web" :size 28))

(set-fontset-font t 'arabic +bidi-arabic-font)

this makes the initial situation better but now the Urdu text is not
affected by the `text-scale-mode` commands.

To overcome this I have added a hook to `text-scale-mode-hook` to
manually adjust the font size. This improves the situation but feels
wrong since the `text-scale-mode` uses face remapping machinery which is
buffer local but the font sizes are global.

Is there a way to set a different size for my Urdu font that makes it
work seamlessly with `text-scale-mode`?

Thanks,
Rahguzar



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

* Re: Text scale mode and additional fonts
  2023-12-30 11:10 Text scale mode and additional fonts Rahguzar
@ 2023-12-30 17:47 ` Eli Zaretskii
  2023-12-30 18:12   ` [External] : " Drew Adams
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2023-12-30 17:47 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rahguzar <rahguzar@zohomail.eu>
> Date: Sat, 30 Dec 2023 12:10:31 +0100
> 
> (setq +bidi-arabic-font (font-spec :family "Mehr Nastaliq Web" :size 28))
> 
> (set-fontset-font t 'arabic +bidi-arabic-font)
> 
> this makes the initial situation better but now the Urdu text is not
> affected by the `text-scale-mode` commands.

That's because the :size attribute is absolute: 28.  Instead, use a
relative value, a float such as 1.5, then it should scale with the
rest of the text.



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

* RE: [External] : Re: Text scale mode and additional fonts
  2023-12-30 17:47 ` Eli Zaretskii
@ 2023-12-30 18:12   ` Drew Adams
  2023-12-30 18:54     ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Drew Adams @ 2023-12-30 18:12 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs@gnu.org

> > (set-fontset-font t 'arabic +bidi-arabic-font)
> >
> > this makes the initial situation better but now the Urdu text is not
> > affected by the `text-scale-mode` commands.
> 
> That's because the :size attribute is absolute: 28.  Instead, use a
> relative value, a float such as 1.5, then it should scale with the
> rest of the text.

Very useful info.  But I don't see that spelled
out clearly in the doc.  There I find only
statements such as these.  Do they perhaps imply
what you stated? 

`:size'

VALUE must be a non-negative integer or a floating point number
specifying the font size.  It specifies the font size in pixels (if
VALUE is an integer), or in points (if VALUE is a float).
___

':size'
  The font size-either a non-negative integer that specifies the
  pixel size, or a floating-point number that specifies the
  point size.
___

Is such info already documented somewhere?
If not, should it be?  An explicit statement
about point-size being scalable might help.



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

* Re: [External] : Re: Text scale mode and additional fonts
  2023-12-30 18:12   ` [External] : " Drew Adams
@ 2023-12-30 18:54     ` Eli Zaretskii
  2023-12-30 21:17       ` Drew Adams
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2023-12-30 18:54 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Drew Adams <drew.adams@oracle.com>
> Date: Sat, 30 Dec 2023 18:12:08 +0000
> 
> > > (set-fontset-font t 'arabic +bidi-arabic-font)
> > >
> > > this makes the initial situation better but now the Urdu text is not
> > > affected by the `text-scale-mode` commands.
> > 
> > That's because the :size attribute is absolute: 28.  Instead, use a
> > relative value, a float such as 1.5, then it should scale with the
> > rest of the text.
> 
> Very useful info.  But I don't see that spelled
> out clearly in the doc.  There I find only
> statements such as these.  Do they perhaps imply
> what you stated? 
> 
> `:size'
> 
> VALUE must be a non-negative integer or a floating point number
> specifying the font size.  It specifies the font size in pixels (if
> VALUE is an integer), or in points (if VALUE is a float).

Sorry, I was confused.  What I wrote is true for the :height
attribute of a face, not about :size in a font-spec.  IOW, to get what
he wants, the OP should define a face with :height attribute a float.



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

* RE: [External] : Re: Text scale mode and additional fonts
  2023-12-30 18:54     ` Eli Zaretskii
@ 2023-12-30 21:17       ` Drew Adams
  2023-12-31  0:58         ` Po Lu
  0 siblings, 1 reply; 13+ messages in thread
From: Drew Adams @ 2023-12-30 21:17 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs@gnu.org

> > > > (set-fontset-font t 'arabic +bidi-arabic-font)
> > > >
> > > > this makes the initial situation better but now the Urdu text is not
> > > > affected by the `text-scale-mode` commands.
> > >
> > > That's because the :size attribute is absolute: 28.  Instead, use a
> > > relative value, a float such as 1.5, then it should scale with the
> > > rest of the text.
> >
> > Very useful info.  But I don't see that spelled
> > out clearly in the doc.  There I find only
> > statements such as these.  Do they perhaps imply
> > what you stated?
> >
> > `:size'
> >
> > VALUE must be a non-negative integer or a floating point number
> > specifying the font size.  It specifies the font size in pixels (if
> > VALUE is an integer), or in points (if VALUE is a float).
> 
> Sorry, I was confused.  What I wrote is true for the :height
> attribute of a face, not about :size in a font-spec.  IOW, to get what
> he wants, the OP should define a face with :height attribute a float.

Thanks for clarifying.  That makes sense.




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

* Re: [External] : Re: Text scale mode and additional fonts
  2023-12-30 21:17       ` Drew Adams
@ 2023-12-31  0:58         ` Po Lu
  0 siblings, 0 replies; 13+ messages in thread
From: Po Lu @ 2023-12-31  0:58 UTC (permalink / raw)
  To: Drew Adams; +Cc: Eli Zaretskii, help-gnu-emacs@gnu.org

Drew Adams <drew.adams@oracle.com> writes:

> Thanks for clarifying.  That makes sense.

It's also worth mentioning that face-font-rescale-alist frees you from
providing a scale factor in every place the font to be scaled is
specified.



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

* Re: [External] : Re: Text scale mode and additional fonts
@ 2023-12-31 10:41 Rahguzar
  2024-01-01 12:09 ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Rahguzar @ 2023-12-31 10:41 UTC (permalink / raw)
  To: luangruo; +Cc: help-gnu-emacs

Hi Po,

> It's also worth mentioning that face-font-rescale-alist frees you from
> providing a scale factor in every place the font to be scaled is
> specified.

Thank you so much face-font-rescale-alist is exactly what I wanted. But
it seems like there is bug or at least a problem with doc string. It
mentions that FONT-PATTERN can be a font-spec but when I try to pass a
font spec in my config I get an error:

string-match-p: Wrong type argument: stringp, #<font-spec nil nil Mehr\ Nastaliq\ Web nil nil nil nil nil nil nil nil nil nil>

Using the font name for FONT-PATTERN works as expected, so I have used
that.

Thanks again,
Rahguzar



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

* Re: [External] : Re: Text scale mode and additional fonts
  2023-12-31 10:41 Rahguzar
@ 2024-01-01 12:09 ` Eli Zaretskii
  0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2024-01-01 12:09 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rahguzar <rahguzar@zohomail.eu>
> Cc: help-gnu-emacs@gnu.org
> Date: Sun, 31 Dec 2023 11:41:32 +0100
> 
> Thank you so much face-font-rescale-alist is exactly what I wanted. But
> it seems like there is bug or at least a problem with doc string. It
> mentions that FONT-PATTERN can be a font-spec but when I try to pass a
> font spec in my config I get an error:
> 
> string-match-p: Wrong type argument: stringp, #<font-spec nil nil Mehr\ Nastaliq\ Web nil nil nil nil nil nil nil nil nil nil>

Which font-spec did you try to pass?  IOW, please show a recipe that
fails as above.



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

* Re: [External] : Re: Text scale mode and additional fonts
@ 2024-01-01 13:11 Rahguzar
  2024-02-13  9:02 ` Rahguzar
  0 siblings, 1 reply; 13+ messages in thread
From: Rahguzar @ 2024-01-01 13:11 UTC (permalink / raw)
  To: eliz; +Cc: help-gnu-emacs

Hi Eli,

> Which font-spec did you try to pass?  IOW, please show a recipe that
> fails as above.

I see the error in the echo area of the Emacs frame that pops us when I
execute e.g.

emacs -Q --eval="(add-to-list 'face-font-rescale-alist `(,(font-spec :family \"Mehr Nastaliq Web\") . ,(/ 28.0 24)))"

The name of the family is not important and to me if happens for all names.

If I do `C-h v face-font-rescale-alist RET` the value of
face-font-rescale-alist includes a key for the font-spec but the error
stops loading of the config in normal use.

Thanks,
Rahguzar



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

* Re: [External] : Re: Text scale mode and additional fonts
  2024-01-01 13:11 Rahguzar
@ 2024-02-13  9:02 ` Rahguzar
  2024-02-13 13:02   ` Eli Zaretskii
  2024-02-15 10:07   ` Eli Zaretskii
  0 siblings, 2 replies; 13+ messages in thread
From: Rahguzar @ 2024-02-13  9:02 UTC (permalink / raw)
  To: Rahguzar; +Cc: eliz, help-gnu-emacs

Hi Eli,

Can you reproduce error on startup with the emacs -Q invocations I
posted? It can slightly simplified to,

emacs -Q --eval="(add-to-list 'face-font-rescale-alist `(,(font-spec :family \"monospace\") . 1.2))"

Should I file a bug report about it?

Thanks,
Rahguzar

Rahguzar <rahguzar@zohomail.eu> writes:

> Hi Eli,
>
>> Which font-spec did you try to pass?  IOW, please show a recipe that
>> fails as above.
>
> I see the error in the echo area of the Emacs frame that pops us when I
> execute e.g.
>
> emacs -Q --eval="(add-to-list 'face-font-rescale-alist `(,(font-spec :family \"Mehr Nastaliq Web\") . ,(/ 28.0 24)))"
>
> The name of the family is not important and to me if happens for all names.
>
> If I do `C-h v face-font-rescale-alist RET` the value of
> face-font-rescale-alist includes a key for the font-spec but the error
> stops loading of the config in normal use.
>
> Thanks,
> Rahguzar



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

* Re: [External] : Re: Text scale mode and additional fonts
  2024-02-13  9:02 ` Rahguzar
@ 2024-02-13 13:02   ` Eli Zaretskii
  2024-02-15 10:07   ` Eli Zaretskii
  1 sibling, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2024-02-13 13:02 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rahguzar <rahguzar@zohomail.eu>
> Cc: eliz@gnu.org, help-gnu-emacs@gnu.org
> Date: Tue, 13 Feb 2024 10:02:28 +0100
> 
> Can you reproduce error on startup with the emacs -Q invocations I
> posted? It can slightly simplified to,
> 
> emacs -Q --eval="(add-to-list 'face-font-rescale-alist `(,(font-spec :family \"monospace\") . 1.2))"

I don't have this family of fonts installed, so I cannot try that.

> Should I file a bug report about it?

Feel free.



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

* Re: [External] : Re: Text scale mode and additional fonts
  2024-02-13  9:02 ` Rahguzar
  2024-02-13 13:02   ` Eli Zaretskii
@ 2024-02-15 10:07   ` Eli Zaretskii
  1 sibling, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2024-02-15 10:07 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rahguzar <rahguzar@zohomail.eu>
> Cc: eliz@gnu.org, help-gnu-emacs@gnu.org
> Date: Tue, 13 Feb 2024 10:02:28 +0100
> 
> Can you reproduce error on startup with the emacs -Q invocations I
> posted? It can slightly simplified to,
> 
> emacs -Q --eval="(add-to-list 'face-font-rescale-alist `(,(font-spec :family \"monospace\") . 1.2))"
> 
> Should I file a bug report about it?

I eventually found some time to look into this.  It turned out this
was a bug in the Emacs startup code, now fixed in what will eventually
become Emacs 30.1.

Thanks.



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

* Re: [External] : Re: Text scale mode and additional fonts
@ 2024-02-19 17:11 Rahguzar
  0 siblings, 0 replies; 13+ messages in thread
From: Rahguzar @ 2024-02-19 17:11 UTC (permalink / raw)
  To: eliz; +Cc: help-gnu-emacs

Hi Eli,

> I eventually found some time to look into this.  It turned out this
> was a bug in the Emacs startup code, now fixed in what will eventually
> become Emacs 30.1.

I tested and the error is gone now.

As always, thanks a lot!
Rahguzar



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

end of thread, other threads:[~2024-02-19 17:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-30 11:10 Text scale mode and additional fonts Rahguzar
2023-12-30 17:47 ` Eli Zaretskii
2023-12-30 18:12   ` [External] : " Drew Adams
2023-12-30 18:54     ` Eli Zaretskii
2023-12-30 21:17       ` Drew Adams
2023-12-31  0:58         ` Po Lu
  -- strict thread matches above, loose matches on Subject: below --
2023-12-31 10:41 Rahguzar
2024-01-01 12:09 ` Eli Zaretskii
2024-01-01 13:11 Rahguzar
2024-02-13  9:02 ` Rahguzar
2024-02-13 13:02   ` Eli Zaretskii
2024-02-15 10:07   ` Eli Zaretskii
2024-02-19 17:11 Rahguzar

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).