]> git.donarmstrong.com Git - lilypond.git/blob - debian/patches/add_set-global-fonts_function
Cherry-pick set-global-fonts function from upstream to scm/font.scm
[lilypond.git] / debian / patches / add_set-global-fonts_function
1 Description: Add set-global-fonts function to scm/font.scm
2  Allow changing of notation fonts
3  .
4  This commit changes the behaviour of make-pango-font-tree in the
5  following ways:
6  .
7  - Make all arguments optional key/value pairs
8    keeping the current default values (emmentaler/Century Schoolbook)
9  - Allow changing of music fonts too.
10  .
11  Currently alternative music fonts have to be present in the font
12  directory besides Emmentaler fonts, and they have to be manually installed.
13  But now there are a number of alternative and compatible fonts available.
14  .
15  See also:
16  - https://sites.google.com/site/tisimst/lilypond-fonts/docs
17  - http://lilypondblog.org/2015/03/managing-alternative-fonts-with-lilypond/
18 Author: Abraham Lee <tisimst.lilypond@gmail.com>
19 Date:   Sat Aug 2 18:17:01 2014 +0200
20 Origin: upstream
21 Applied-Upstream: 2.19.12, http://git.savannah.gnu.org/cgit/lilypond.git/commit/?id=a7b6efba453f6bec916d3908cd83bcb825b2a1a8
22 Reviewed-by: Urs Liska <ul@openlilylib.org>
23 Reviewed-by: Anthony Fok <foka@debian.org>
24 Last-Update: 2017-01-25
25 ---
26 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
27 --- a/scm/font.scm
28 +++ b/scm/font.scm
29 @@ -1,6 +1,6 @@
30  ;;;; This file is part of LilyPond, the GNU music typesetter.
31  ;;;;
32 -;;;; Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
33 +;;;; Copyright (C) 2004--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
34  ;;;;
35  ;;;; LilyPond is free software: you can redistribute it and/or modify
36  ;;;; it under the terms of the GNU General Public License as published by
37 @@ -147,7 +147,7 @@
38  
39  ;; Each size family is a vector of fonts, loaded with a delay.  The
40  ;; vector should be sorted according to ascending design size.
41 -(define-public (add-music-fonts node name family design-size-alist factor)
42 +(define-public (add-music-fonts node family name brace design-size-alist factor)
43    "Set up music fonts.
44  
45  Arguments:
46 @@ -156,12 +156,15 @@
47  @var{node} is the font tree to modify.
48  
49  @item
50 +@var{family} is the family name of the music font.
51 +
52 +@item
53  @var{name} is the basename for the music font.
54  @file{@var{name}-<designsize>.otf} should be the music font,
55 -@file{@var{name}-brace.otf} should have piano braces.
56  
57  @item
58 -@var{family} is the family name of the music font.
59 +@var{brace} is the basename for the brace font.
60 +@file{@var{brace}-brace.otf} should have piano braces.
61  
62  @item
63  @var{design-size-alist} is a list of @code{(rounded . designsize)}.
64 @@ -199,7 +202,7 @@
65                         )))
66       (fetaBraces ,(ly:pt 20.0)
67                   #(,(delay (ly:system-font-load
68 -                            (format #f "~a-brace" name)))))
69 +                            (format #f "~a-brace" brace)))))
70       )))
71  
72  (define-public (add-pango-fonts node lily-family family factor)
73 @@ -229,9 +232,40 @@
74    (add-node 'italic 'normal)
75    (add-node 'italic 'bold))
76  
77 +; This function allows the user to change the specific fonts, leaving others
78 +; to the default values. This way, "make-pango-font-tree"'s syntax doesn't
79 +; have to change from the user's perspective.
80 +;
81 +; Usage:
82 +;   \paper {
83 +;     #(define fonts
84 +;       (set-global-fonts
85 +;        #:music "gonville"  ; (the main notation font)
86 +;        #:roman "FreeSerif" ; (the main/serif text font)
87 +;       ))
88 +;   }
89 +;
90 +; Leaving out "#:brace", "#:sans", and "#:typewriter" leave them at 
91 +; "emmentaler", "sans-serif", and "monospace", respectively. All fonts are
92 +; still accesible through the usual scheme symbols: 'feta, 'roman, 'sans, and
93 +; 'typewriter.
94 +(define*-public (set-global-fonts #:key 
95 +  (music "emmentaler")
96 +  (brace "emmentaler")
97 +  (roman "Century Schoolbook L")
98 +  (sans "sans-serif")
99 +  (typewriter "monospace")
100 +  (factor 1))
101 +  (let ((n (make-font-tree-node 'font-encoding 'fetaMusic)))
102 +    (add-music-fonts n 'feta music brace feta-design-size-mapping factor)
103 +    (add-pango-fonts n 'roman roman factor)
104 +    (add-pango-fonts n 'sans sans factor)
105 +    (add-pango-fonts n 'typewriter typewriter factor)
106 +    n))
107 +    
108  (define-public (make-pango-font-tree roman-str sans-str typewrite-str factor)
109    (let ((n (make-font-tree-node 'font-encoding 'fetaMusic)))
110 -    (add-music-fonts n "emmentaler" 'feta feta-design-size-mapping factor)
111 +    (add-music-fonts n 'feta "emmentaler" "emmentaler" feta-design-size-mapping factor)
112      (add-pango-fonts n 'roman roman-str factor)
113      (add-pango-fonts n 'sans sans-str factor)
114      (add-pango-fonts n 'typewriter typewrite-str factor)
115 @@ -240,7 +274,9 @@
116  (define-public (make-century-schoolbook-tree factor)
117    (make-pango-font-tree
118     "Century Schoolbook L"
119 -   "sans-serif" "monospace" factor))
120 +   "sans-serif"
121 +   "monospace"
122 +   factor))
123  
124  (define-public all-text-font-encodings
125    '(latin1))