auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-devel] Re: Fontifying of titles...


From: Reiner Steib
Subject: [AUCTeX-devel] Re: Fontifying of titles...
Date: Fri, 08 Apr 2005 18:47:50 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

On Fri, Apr 08 2005, Ralf Angeli wrote:

> * Reiner Steib (2005-04-07) writes:
>
>> I'm using `height' for `font-latex-fontify-script', but in some
>> situations, I don't like the appearance:
>>
>> - When the number of characters in the line (macro plus title) is
>>   close to my window width.  I.e. with `color', it would fit, but with
>>   `height' it is wrapped.
>
> In such cases I tend to format the lines in concern manually.

This would result in a document which looks nice only with AUCTeX and
specific font settings.  I think we had a discussion about this (WRT
filling with tex-fold or preview-latex) and IIRC we agreed that this
is not a good idea.

>>   The second example isn't fontified correctly.
>
> That's because of the trailing comment character in the first line.
> Should be fixed in CVS.

Yes, thanks.

> I hope `forward-comment' is not a performance hog.
>
>> - The factor 1.2 seems to be appropriate for `Info-title-*-face', but
>>   for `font-latex-title-*-face', a smaller factor (say 1.05-1.1) would
>>   be better.  At least `font-latex-title-1-face' (for \part or
>>   \chapter) are too large, especially because often another \chapter
>>   or \section line follows.
>>
>> Here is a patch that allows `font-latex-title-fontify' to be a number
>> which is used instead as the scaling factor instead of the default
>> value (now: 1.2; my suggestion: 1.05-1.1).  Even with 1.05, the titles
>> stand out enough too make it recognizable easily, I think.
>
> This only holds true if you have scalable fonts or the right bitmap
> fonts in a lot of sizes.

Probably we cannot completely avoid that `font-latex-title-N-face' and
`font-latex-title-(N+1)-face' is the same font on some systems unless
we use a large scale factor resulting in too huge fonts for \part or
\chapter.  But my point was that sectioning font stands out enough
compared to the rest of the text.  This is the aim of
`font-latex-title-fontify', isn't it?

> In my case (yes, I know, my setup is not really standard) this makes
> the levels 2 to 4 indistinguishable.  Here is a list of fonts I get:
>
> With patch:
>
> 1: -Adobe-Helvetica-Bold-R-Normal--24-240-75-75-P-138-ISO8859-1
> 2: -Adobe-Helvetica-Bold-R-Normal--20-140-100-100-P-105-ISO8859-1
> 3: -Adobe-Helvetica-Bold-R-Normal--20-140-100-100-P-105-ISO8859-1
> 4: -Adobe-Helvetica-Bold-R-Normal--18-180-75-75-P-103-ISO8859-1
>
> Without patch:
[ Adding the LaTeX macros: ]
> 1: -Adobe-Helvetica-Bold-R-Normal--34-240-100-100-P-182-ISO8859-1
  \part \chapter

> 2: -Adobe-Helvetica-Bold-R-Normal--25-180-100-100-P-138-ISO8859-1
  \section

> 3: -Adobe-Helvetica-Bold-R-Normal--20-140-100-100-P-105-ISO8859-1
  \subsection

> 4: -Adobe-Helvetica-Bold-R-Normal--18-180-75-75-P-103-ISO8859-1
  \subsubsection \paragraph \subparagraph \subsubparagraph

> The 18 and 20 pixel sizes of the font look nearly identically.  

Maybe because of the different dpi values (20-x-100-100
vs. 18-180-75-75)?

> Oh well, I guess I could live with that (or customize it if I need
> the difference) in case people find this more appealing.

Maybe we get better results for more font constellations if we
introduce more levels: 0 ... 7 for \part ... \subsubparagraph (one
level for each LaTeX section macro), like in the attached patch.  With
a scale factor of 1.05-1.1 this gives acceptable results.  I'd propose
to install it and let cvs/snapshot users experiment with different
values for `font-latex-title-fontify', ask for feedback and change the
default scaling based on it.  I could imagine that some of the users
who complained and switched back to `color', could live or even would
like a small factor.  Therefore, I would recommend to use quite small
factor as default value, e.g. 1.07.

With 1.07 it get:

-Adobe-Helvetica-Bold-R-Normal...
--34-240-100-100-P-182-ISO8859-15 \part
--20-140-100-100-P-105-ISO8859-15 \chapter
--20-140-100-100-P-105-ISO8859-15 \section
--18-180-75-75-P-103-ISO8859-15   \subsection
--17-120-100-100-P-92-ISO8859-15  \subsubsection
--17-120-100-100-P-92-ISO8859-15  \paragraph
--14-100-100-100-P-82-ISO8859-15  \subparagraph
--14-100-100-100-P-82-ISO8859-15  \subsubparagraph

With 1.09:

-Adobe-Helvetica-Bold-R-Normal...
--34-240-100-100-P-182-ISO8859-15 \part           
--24-240-75-75-P-138-ISO8859-15   \chapter        
--20-140-100-100-P-105-ISO8859-15 \section        
--20-140-100-100-P-105-ISO8859-15 \subsection     
--18-180-75-75-P-103-ISO8859-15   \subsubsection  
--17-120-100-100-P-92-ISO8859-15  \paragraph      
--14-100-100-100-P-82-ISO8859-15  \subparagraph   
--14-100-100-100-P-82-ISO8859-15  \subsubparagraph

>> +(defcustom font-latex-title-fontify 'height
>> +  "Whether to fontify LaTeX titles with varying height faces or a color 
>> face.
>> +
>> +If it is a number, use varying height faces scaled with this number.
>> +Setting this variable does not take effect unless you call
>> +\\[font-lock-fontify-buffer]."

BTW, calling `font-lock-fontify-buffer' (and
`font-latex-make-title-faces') is not sufficient to change the
scaling.

> Hm, I don't think many people will have 'height as a customized value,
> so we might just drop this from the defcustom and only provide the
> scale factor with a proper default value.  For backwards compatibility
> the (indirect) check for 'height in `font-latex-make-title-faces'
> could stay.  

Okay.

> BTW, you will have to change the XEmacs-related code as well.

Yes, I saw it.  But as we don't seem to have XEmacs developers on this
list, I though it isn't necessary for a preliminary patch.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/
--- font-latex.el       8 Apr 2005 07:33:10 -0000       5.105
+++ font-latex.el       8 Apr 2005 16:20:34 -0000
@@ -118,15 +118,32 @@
               (regexp-opt (mapcar 'car font-latex-quote-list) t)))
   :group 'font-latex)
 
+(defcustom font-latex-title-fontify 1.07
+  "Whether to fontify LaTeX titles with varying height faces or a color face.
+
+If it is a number, use varying height faces.  The number is used
+for scaling starting from `font-latex-title-7-face'.  Typically
+value from 1.05 to 1.2 give best result, depending on your font
+setup.
+
+If it is `color', use `font-lock-type-face'.
+
+Changing this variable does not take effect unless you call
+\\[font-lock-fontify-buffer] or restart Emacs if you change the
+scaling."
+  :type '(choice (number :tag "Scale factor")
+                 (const color))
+  :group 'font-latex)
+
 ;; The definitions of the title faces were originally taken from
 ;; info.el (Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99,
 ;; 2000, 2001 Free Software Foundation, Inc.) and adapted to the needs
 ;; of font-latex.el.
 (defun font-latex-make-title-faces ()
   "Build the faces used to fontify sectioning commands."
-  (dotimes (i 3)
-    (let* ((num (1+ i))
-          (face-name (intern (concat "font-latex-title-" (number-to-string num)
+  (dotimes (num 7)
+    (let* ((face-name (intern (concat "font-latex-title-"
+                                     (number-to-string num)
                                      "-face"))))
       (if (featurep 'xemacs)
          (let ((size (concat
@@ -152,17 +169,22 @@
                              (number-to-string num) ".")
                     :group 'font-latex-highlighting-faces)))
        (eval `(defface ,face-name
-                '((t (:height 1.2 :inherit ,(intern
-                                             (concat
-                                              "font-latex-title-"
-                                              (number-to-string (1+ num))
-                                              "-face")))))
+                '((t (:height ,(if (numberp font-latex-title-fontify)
+                                   font-latex-title-fontify
+                                 1.1)
+                      :inherit ,(intern (concat "font-latex-title-"
+                                                (number-to-string (1+ num))
+                                                "-face")))))
                 ,(concat "Face for LaTeX titles at level "
-                         (number-to-string num) ".")
+                         (number-to-string num) ".
+
+Probably you don't want to customize this face directly.  Better
+change the face `font-latex-title-7-face' or customize the
+variable `font-latex-title-fontify'.")
                 :group 'font-latex-highlighting-faces))))))
 (font-latex-make-title-faces)
 
-(defface font-latex-title-4-face
+(defface font-latex-title-7-face
   (if (featurep 'xemacs)
       '((((type tty pc) (class color) (background light))
         (:foreground "blue4" :bold t))
@@ -182,15 +204,9 @@
       (((class color) (background dark))
        (:weight bold :inherit variable-pitch :foreground "yellow"))
       (t (:weight bold :inherit variable-pitch))))
-  "Face for LaTeX titles at level 4."
+  "Face for LaTeX titles at level 7."
   :group 'font-latex-highlighting-faces)
 
-(defcustom font-latex-title-fontify 'height
-  "Whether to fontify LaTeX titles with varying height faces or a color face."
-  :type '(choice (const height)
-                 (const color))
-  :group 'font-latex)
-
 
 ;;; Keywords
 
@@ -226,6 +242,9 @@
       "negthinspace" "enspace" "enskip" "quad" "qquad" "nonumber"
       "centering" "TeX" "LaTeX")
      font-lock-function-name-face 2 (command 1 t))
+    ("title-0"
+     ("part")
+     font-latex-title-0-face 2 (title 1 t))
     ("title-1"
      ("part" "chapter")
      font-latex-title-1-face 2 (title 1 t))
@@ -236,8 +255,17 @@
      ("subsection")
      font-latex-title-3-face 2 (title 1 t))
     ("title-4"
-     ("subsubsection" "paragraph" "subparagraph" "subsubparagraph")
+     ("subsubsection")
      font-latex-title-4-face 2 (title 1 t))
+    ("title-5"
+     ("paragraph")
+     font-latex-title-5-face 2 (title 1 t))
+    ("title-6"
+     ("subparagraph")
+     font-latex-title-6-face 2 (title 1 t))
+    ("title-7"
+     ("subsubparagraph")
+     font-latex-title-7-face 2 (title 1 t))
     ("textual"
      ("item" "title" "author" "date" "thanks" "address" "caption"
       "textsuperscript")
@@ -349,9 +377,9 @@
         `(,(intern (concat prefix name))
           (0 'font-lock-keyword-face append t)
           (1 'font-lock-variable-name-face append t)
-          (2 (if (eq font-latex-title-fontify 'height)
-                 ',face
-               'font-lock-type-face)
+          (2 (if (eq font-latex-title-fontify 'color)
+                 'font-lock-type-face
+               ',face)
              append t)))
        ((eq type 'noarg)
         `(,(intern (concat prefix name))
@@ -360,7 +388,7 @@
         `(,(intern (concat prefix name))
           (0 'font-lock-keyword-face append t)
           (1 ',face append t)))))
-  
+
 (defun font-latex-make-built-in-keywords ()
   "Build defuns, defvars and defcustoms for built-in keyword fontification."
   (let ((keyword-specs font-latex-built-in-keyword-classes))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]