lilypond-devel
[Top][All Lists]
Advanced

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

Re: Define default fonts in fontconfig configuration file (issue 2413400


From: trueroad
Subject: Re: Define default fonts in fontconfig configuration file (issue 241340043 by address@hidden)
Date: Thu, 11 Jun 2015 23:23:04 +0000

Reviewers: J_lowe, lemzwerg,


https://codereview.appspot.com/241340043/diff/1/lily/font-config.cc
File lily/font-config.cc (right):

https://codereview.appspot.com/241340043/diff/1/lily/font-config.cc#newcode62
lily/font-config.cc:62: for (vsize i = 0; i < confs.size (); i++)
On 2015/06/11 22:14:32, lemzwerg wrote:
> ... do we have a loop here?

I mean: *Why* do we have a loop here?

lily/font-config.cc:47: dirs.push_back (lilypond_datadir +
"/fonts/otf");
This line adds one font dir.

https://codereview.appspot.com/241340043/diff/1/lily/font-config.cc#newcode49
lily/font-config.cc:49: for (vsize i = 0; i < dirs.size (); i++)
We have a loop here for one font dir.

Adding .conf file loop is same as adding font dir loop.
If both loops are unnecessary, I'll remove them.

Description:
Define default fonts in fontconfig configuration file

    This commit defines LilyPond default fonts
    in local fontconfig configuration file.
    And, LilyPond uses them.

    It is possible to combine multiple fonts
    with different character sets and glyphs each other.

    e.g. Following fonts can be combined.
    Latin glyphs: from a font without Cyrillic glyphs
    Cyrillic glyphs: from another font with Cyrillic glyphs

Add local fontconfig configuration file loading

    This commit becomes that
    LilyPond local (dedicated) fontconfig configuration file
    `fonts/lilypond-fonts.conf' can be used.

Please review this at https://codereview.appspot.com/241340043/

Affected files (+72, -9 lines):
  M GNUmakefile.in
  M lily/font-config.cc
  M mf/GNUmakefile
  A mf/lilypond-fonts.conf.in
  M scm/font.scm


Index: GNUmakefile.in
diff --git a/GNUmakefile.in b/GNUmakefile.in
index 74f255139382183558ed5e908f092cb137d19eb5..749f27aaee8cceffbef85586a33e274083d1654b 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -253,12 +253,14 @@ $(tree-share-prefix)/mf-link-tree: $(tree-share-prefix)/lilypond-force
        -rm -f $(tree-share-prefix)/fonts/otf/* &&  \
        rm -f $(tree-share-prefix)/fonts/svg/* &&  \
        rm -f $(tree-share-prefix)/fonts/fonts.conf &&  \
+       rm -f $(tree-share-prefix)/fonts/lilypond-fonts.conf &&  \
        rm -f $(tree-share-prefix)/fonts/tfm/* &&  \
        rm -f $(tree-share-prefix)/fonts/type1/* &&  \
                cd $(tree-share-prefix)/fonts/otf && \
                ln -s ../../../../../../mf/$(outconfbase)/*.otf .
        -cd $(tree-share-prefix)/fonts && \
-               ln -s ../../../../../mf/$(outconfbase)/fonts.conf .
+               ln -s ../../../../../mf/$(outconfbase)/fonts.conf . && \
+               ln -s ../../../../../mf/$(outconfbase)/lilypond-fonts.conf .
        -cd $(tree-share-prefix)/fonts/svg && \
                ln -s ../../../../../../mf/$(outconfbase)/*.svg .
        -cd $(tree-share-prefix)/fonts/svg && \
Index: lily/font-config.cc
diff --git a/lily/font-config.cc b/lily/font-config.cc
index 81c0e844c8335bd6aed241d9e49e5715dc381f0f..cb201a6642c8bb29e8db4e6381fe9188d1739997 100644
--- a/lily/font-config.cc
+++ b/lily/font-config.cc
@@ -55,6 +55,23 @@ init_fontconfig ()
         debug_output (_f ("Adding font directory: %s", dir.c_str ()));
     }

+  vector<string> confs;
+
+  confs.push_back (lilypond_datadir + "/fonts/lilypond-fonts.conf");
+
+  for (vsize i = 0; i < confs.size (); i++)
+    {
+      string conf = confs[i];
+      if (!FcConfigParseAndLoad (font_config_global,
+                                 (FcChar8 *)conf.c_str (),
+                                 FcFalse))
+        error (_f ("failed adding fontconfig configuration file: %s",
+                   conf.c_str ()));
+      else
+        debug_output (_f ("Adding fontconfig configuration file: %s",
+                          conf.c_str ()));
+    }
+
   debug_output (_ ("Building font database..."));

   FcConfigBuildFonts (font_config_global);
Index: mf/GNUmakefile
diff --git a/mf/GNUmakefile b/mf/GNUmakefile
index 646234cd071cb9d030c057f56d4e254a45c1bff3..5550eaf06b49a258d8455b795d24ca65970b6d93 100644
--- a/mf/GNUmakefile
+++ b/mf/GNUmakefile
@@ -50,6 +50,8 @@ COUR_OTFS = $(addprefix $(outdir)/,NimbusMonL-ReguObli.otf \
                                   NimbusMonL-Regu.otf \
                                   NimbusMonL-Bold.otf)

+LILYPOND_FONTS_CONF = $(outdir)/lilypond-fonts.conf
+
 LOG_FILES = $(FETA_MF_FILES:%.mf=$(outdir)/%.log)
 LISP_FILES = $(FETA_MF_FILES:%.mf=$(outdir)/%.lisp)
 ENC_FILES = $(FETA_MF_FILES:%.mf=$(outdir)/%.enc)
@@ -88,14 +90,15 @@ ALL_GEN_FILES = $(ENC_FILES) \
                $(COUR_OTFS) \
                $(OTF_FILES) \
                $(SVG_FILES) \
-               $(WOFF_FILES)
+               $(WOFF_FILES) \
+               $(LILYPOND_FONTS_CONF)

 # PRE_INSTALL=$(MAKE) "$(ALL_GEN_FILES)"

 INSTALLATION_DIR = $(local_lilypond_datadir)/fonts/source
 INSTALLATION_FILES = $(MF_FILES)

-INSTALLATION_OUT_SUFFIXES = 1 2
+INSTALLATION_OUT_SUFFIXES = 1 2 3

 INSTALLATION_OUT_DIR1 = $(local_lilypond_datadir)/fonts/otf
 INSTALLATION_OUT_FILES1 = $(OTF_FILES) \
@@ -104,6 +107,9 @@ INSTALLATION_OUT_FILES1 = $(OTF_FILES) \
 INSTALLATION_OUT_DIR2 = $(local_lilypond_datadir)/fonts/svg
 INSTALLATION_OUT_FILES2 = $(SVG_FILES) $(WOFF_FILES)

+INSTALLATION_OUT_DIR3 = $(local_lilypond_datadir)/fonts
+INSTALLATION_OUT_FILES3 = $(LILYPOND_FONTS_CONF)
+
 export MFINPUTS := .:$(MFINPUTS)

 # A few rules here generate multiple files from one command line.  For
Index: mf/lilypond-fonts.conf.in
diff --git a/mf/lilypond-fonts.conf.in b/mf/lilypond-fonts.conf.in
new file mode 100644
index 0000000000000000000000000000000000000000..97a91fc35cd96d49a133a908224085f022166767
--- /dev/null
+++ b/mf/lilypond-fonts.conf.in
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+
+  <alias binding="strong">
+    <family>LilyPond Serif</family>
+    <prefer>
+      <family>Century Schoolbook L</family>
+      <family>DejaVu Serif</family>
+    </prefer>
+    <default>
+      <family>serif</family>
+    </default>
+  </alias>
+
+  <alias binding="strong">
+    <family>LilyPond Sans Serif</family>
+    <prefer>
+      <family>Nimbus Sans L</family>
+      <family>DejaVu Sans</family>
+    </prefer>
+    <default>
+      <family>sans-serif</family>
+    </default>
+  </alias>
+
+  <alias binding="strong">
+    <family>LilyPond Monospace</family>
+    <prefer>
+      <family>Nimbus Mono L</family>
+      <family>DejaVu Sans Mono</family>
+    </prefer>
+    <default>
+      <family>monospace</family>
+    </default>
+  </alias>
+
+</fontconfig>
Index: scm/font.scm
diff --git a/scm/font.scm b/scm/font.scm
index 0582a492a1e18dec33db1c2533e3133b3f16740f..82f6d489901782ef4038977e2c6350827d9941fe 100644
--- a/scm/font.scm
+++ b/scm/font.scm
@@ -252,9 +252,9 @@ used. This is used to select the proper design size for the text fonts.
 (define*-public (set-global-fonts #:key
   (music "emmentaler")
   (brace "emmentaler")
-  (roman "Century Schoolbook L")
-  (sans "Nimbus Sans L")
-  (typewriter "Nimbus Mono L")
+  (roman "LilyPond Serif")
+  (sans "LilyPond Sans Serif")
+  (typewriter "LilyPond Monospace")
   (factor 1))
   (let ((n (make-font-tree-node 'font-encoding 'fetaMusic)))
     (add-music-fonts n 'feta music brace feta-design-size-mapping factor)
@@ -273,9 +273,9 @@ used. This is used to select the proper design size for the text fonts.

 (define-public (make-century-schoolbook-tree factor)
   (make-pango-font-tree
-   "Century Schoolbook L"
-   "Nimbus Sans L"
-   "Nimbus Mono L"
+   "LilyPond Serif"
+   "LilyPond Sans Serif"
+   "LilyPond Monospace"
    factor))

 (define-public all-text-font-encodings





reply via email to

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