%% Generated by lilypond-book
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm,paper-height=845.047\pt,paper-width=597.508\pt,papersize='(cons (* 597.508 pt) (* 845.047 pt))]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************

#(ly:set-option 'eps-box-padding 3.000000)



\paper {
  #(set-paper-size '(cons (* 597.508 pt) (* 845.047 pt)))
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}




% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "/lilypond-2.26.0/input/regression/font-name-add-files.ly"
\sourcefileline 0
\header {

  texidoc = "External fonts may be used without being installed on the
operating system, by loading either a specific font file or a
directory that contains font files.  In this example two logos ('GPL'
and 'GFDL') should be printed, rather than letter glyphs."

  tagline = ##f
}

\version "2.25.5"

%% Create dummy font files in tmp dir (and subdir).

%% Temporarily disable font-export.
%% TODO: This option already seems to be #f at this point when the
%% regression test suite is run, so further explanation would help.
#(ly:set-option 'font-export-dir #f)

%% We want the logo font embedded into output, so we the test result
%% is self-contained.
#(ly:set-option 'gs-load-fonts #f)

gplLogoFont = "
T1RUTwAKAIAAAwAgQ0ZGIE5UIR0AAAUAAAAD2kZGVE2PvFSrAAAI3AAAABxPUy8yV+hiwAAAARAA
AABgY21hcAANAugAAAOcAAABQmhlYWQaNWE/AAAArAAAADZoaGVhCBUFxAAAAOQAAAAkaG10eAm0
AGMAAAj4AAAACG1heHAAAlAAAAABCAAAAAZuYW1lH80HAQAAAXAAAAIrcG9zdP+4ADIAAATgAAAA
IAABAAAAAQAAnX06cV8PPPUACwPoAAAAANqmcOcAAAAA2qetQwAxAAAFmAIwAAAACAACAAAAAAAA
AAEAAAIh//UAWgXMAAAAAAWYAAEAAAAAAAAAAAAAAAAAAAACAABQAAACAAAABAXMAZAABQAAAooC
vAAAAIwCigK8AAA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gaZykmWLTIs5fkhEiwj3lG8VnYuU
i52NCIyPBZDefosFg1gFi4uKih6BhYKKeYt+i32Le4wI94gHi6mMk42PjY6OjZOMCJeMi6AFZImM
i3+LgIuKi2WNCIt2l4oFmomLi4tdCPt1B4t6ioSGhgiAgot/BaGMlYyTi6CLrYmdiwj4aTkVYC9u
IyMwqLYe+GCT/GAHa9tr9vbcq6sei46Kj4mOi/czjvcfi/csCJMGjgRgL24jIzCotrbmqPPz525g
HoMWqzqrICA7a2tr22v29tyrqx6SSRWH/AUFioqKix56dkh5PotSi06VWqSKjIqMi4wIjIyLix7i
9xo390mLjAWNjIyNHowGtH7BgcCL14vVn6LDjIyLjIyLCI2NiokfhH4VbVlGeUOLWItXlGKXCN37
RIuKi4k0+xgFunTGgsGL1YvOm5ueCJL4BBVzUUF3PotVi1SVYpgI4PtKMvsbBbtyyIHDi9eLz52b
nwj7NfhVFX6LfYx7iwhYUoiCH4sHfuCExh69ypqWH4sHnEOxQh6RB9PaZ3Ifiwd2Q4BcVSuNox6L
B5u/jrseoYugi5qKCA4cBZcUixV3n/jviwaNDAqTCo6OjZWNjI+NjPe5DAy4C5GNjYyMj6GMjI0M
DQAAAAEAAAAA2m42gAAAAADapnDnAAAAANqnrLQFlwAyBZcARQ==
"

% TODO: this should be rewritten (e.g. using rnrs bytevectors, see base64
% implementations in guile-gnome and guile-gcrypt) as soon as
% compatibility with Guile v1.8 is no longer needed. -vv

#(define (base64-decode out-port input)
  (let ((base64-decode-table (make-hash-table 64))
        (alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
        (in-port (if (string? input)
                  (open-input-string input)
                  input))
        (current-state 1)
        (current-char '())
        (byte #f)
        (top-bits '())
        (bottom-bits '()))
    (map (lambda (item)
       (hash-set! base64-decode-table item
        (string-index alphabet item)))
     (string->list alphabet))
    ;; inspired by https://sourceware.org/legacy-ml/guile/2000-01/msg00622.html
    ;; looks clunky but gets the job done.
    (while
     (not (eof-object? current-char))
     (set! current-char (read-char in-port))
     (case current-state
       ((1) (begin
             (set! byte
              (hashv-ref base64-decode-table current-char))
             (if byte
              (begin
               (set! top-bits
                (* (logand byte #b00111111) 4))))))
       ((2) (if (eof-object? current-char)
             (begin
              (set! bottom-bits #b00000000)
              (write-char (integer->char
                (logior top-bits bottom-bits))
               out-port))
             (begin
              (set! byte
               (hashv-ref base64-decode-table current-char))
              (if byte
                  (begin
                   (set! bottom-bits
                    (/ (logand byte #b00110000) 16))
                   (write-char (integer->char
                     (logior top-bits bottom-bits))
                    out-port)
                   (set! top-bits
                    (* (logand byte #b00001111) 16)))))))
       ((3) (if (eof-object? current-char)
             (begin
              (set! bottom-bits #b00000000)
              (write-char (integer->char
                (logior top-bits bottom-bits))
               out-port))
             (begin
              (set! byte
               (hashv-ref base64-decode-table current-char))
              (if byte
               (begin
                (set! bottom-bits
                 (/ (logand byte #b00111100) 4))
                (write-char (integer->char
                  (logior top-bits bottom-bits))
                 out-port)
                (set! top-bits
                 (* (logand byte #b00000011) 64)))))))
       ((4) (if (eof-object? current-char)
             (begin
              (set! bottom-bits #b00000000)
              (write-char (integer->char
                (logior top-bits bottom-bits))
               out-port))
             (begin
              (set! byte
               (hashv-ref base64-decode-table current-char))
              (if byte
               (begin
                (set! bottom-bits
                 (logand byte #b00111111))
                (write-char (integer->char
                  (logior top-bits bottom-bits))
                 out-port)))))))
     (if byte
      (begin
       (if (eqv? current-state 4)
           (set! current-state 1)
           (set! current-state (1+ current-state)))
       (set! byte #f))))
    #t))

#(define (dump-base64 name content)
  (let* ((port (open-output-file name)))
   (set-port-encoding! port "ISO-8859-1")
   (base64-decode port content)
   (close port)))

#(define (my-tmpnam)
  "like tmpnam but not deprecated"
  (format
    #f
    "~a/~a"
    (or (getenv "TMPDIR") "/tmp")
    (ly:make-tmpfile-name "font-name-add-file")))

#(define temp-dir (my-tmpnam))
#(define subdir (string-append temp-dir "/subdir"))

#(let*
  ((fontfile (string-append temp-dir "/gpl-logo-font.otf" )))

  (mkdir temp-dir) ;; will error out if it already exists.
  (mkdir subdir)

  (dump-base64 fontfile gplLogoFont)
  (ly:font-config-add-font fontfile)

  (dump-base64 (string-append subdir "/gfdl-logo.otf") gfdlLogoFont)
  (ly:font-config-add-directory subdir))

\book {
  \markup {
    GPL logo: \fontsize #20 \override #'(fonts . ((serif . "DummyGPL"))) "A"
  }
  \markup {
    GFDL logo: \fontsize #20 \override #'(fonts . ((serif . "DummyGFDL"))) "A"
  }
}

#(define (clear-dir dirname)
  (let*
   ((dir (opendir dirname)))
   (do ((f (readdir dir) (readdir dir)))
    ((eof-object? f))
    (or (equal? "." f) (equal? ".." f)
     (delete-file (string-append dirname "/" f))))
   (closedir dir)))

#(begin
  (clear-dir subdir)
  (rmdir subdir)
  (clear-dir temp-dir)
  (rmdir temp-dir))



% ****************************************************************
% end ly snippet
% ****************************************************************
