bug-lilypond
[Top][All Lists]
Advanced

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

Using -dshow-available-fonts with LilyPond v2.25.12 throws error with no


From: Nate Whetsell
Subject: Using -dshow-available-fonts with LilyPond v2.25.12 throws error with non–UTF-8 encoded font info
Date: Sun, 7 Jan 2024 07:43:30 -0500

Hi there,

At commit c3f2dddaa2b16231bc2f786fba7421f03f7da7af 
<https://gitlab.com/lilypond/lilypond/-/commit/c3f2dddaa2b16231bc2f786fba7421f03f7da7af>,
 All_font_metrics::display_fonts was changed 
<https://gitlab.com/lilypond/lilypond/-/commit/c3f2dddaa2b16231bc2f786fba7421f03f7da7af#7fb3cfef7bafee6e934d11ca21b4dcae87f773e0>
 to use ly_string2scm instead of  progress_indication. Unlike 
progress_indication (which uses print_message 
<https://gitlab.com/lilypond/lilypond/-/blob/c3f2dddaa2b16231bc2f786fba7421f03f7da7af/flower/warn.cc#L155-160>
 and does no string encoding), ly_string2scm is a wrapper 
<https://gitlab.com/lilypond/lilypond/-/blob/c3f2dddaa2b16231bc2f786fba7421f03f7da7af/lily/lily-guile.cc#L112-113>
 around scm_from_utf8_stringn 
<https://www.gnu.org/software/guile/manual/html_node/Conversion-to_002ffrom-C.html#index-scm_005ffrom_005futf8_005fstringn>.
 That function throws an error when conversion fails (that is, when the C 
string passed to scm_from_utf8_stringn is not actually encoded as UTF-8).

On macOS Ventura v13.6.3 (and almost certainly other versions), the string 
produced when using -dshow-available-fonts need not be encoded as UTF-8. 
Consequently, using -dshow-available-fonts with LilyPond v2.25.12 results in

GNU LilyPond 2.25.12 (running Guile 3.0)
ERROR: In procedure ly:font-config-display-fonts:
Throw to key `decoding-error' with args `("scm_from_utf8_stringn" "input locale 
conversion error" 22 #vu8([very long bytevector])

It seems like the most straightforward solution is to, in 
All_font_metrics::display_fonts, use scm_from_stringn 
<https://www.gnu.org/software/guile/manual/html_node/Conversion-to_002ffrom-C.html#index-scm_005ffrom_005fstringn>
 with one of the character replacement conversion handlers 
<https://www.gnu.org/software/guile/manual/html_node/Conversion-to_002ffrom-C.html#index-scm_005ft_005fstring_005ffailed_005fconversion_005fhandler>
 (not tested):

scm_write_line (scm_from_stringn (str.c_str (), str.length (), "UTF-8", 
SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE), port);

Best,
Nate

reply via email to

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