verovio-humdrum-viewer icon indicating copy to clipboard operation
verovio-humdrum-viewer copied to clipboard

Problems with character encoding

Open WolfgangDrescher opened this issue 2 years ago • 4 comments

Probably related to https://github.com/humdrum-tools/verovio-humdrum-viewer/issues/765. Figured bass symbols are currently not displayed in VHV. Check this link for reproduction: https://verovio.humdrum.org/?file=https://raw.githubusercontent.com/WolfgangDrescher/humdrum-figured-bass-filter-demo/master/kern/06.krn. There should be a 6-5-chord on the first beat in measure 3. I checked the same file with verovio version 3.12.1-1 and everything worked fine there.

The figured bass get into the svg as tspan tag but a wrong symbol is displayed instead of the numbers. Seems like non UTF-8 chars are displayed on a UTF-8 encoded page.

Bildschirm­foto 2022-11-05 um 17 48 40

Similar to this I also have this problem the other way around. When I use the old high german character in the lyrics VHV will display the character correctly (reproduction link) but using verovio directly a wrong character is displayed:

Bildschirm­foto 2022-11-05 um 18 23 19

Is there anything encoding related VHV does that is not already included in verovio to support these characters?

WolfgangDrescher avatar Nov 05 '22 18:11 WolfgangDrescher

A new music-glyph-embedded-with-text system was added to verovio this summer. This system embeds a reduced-glyph TTF within the SVG image. The problem is that there is no fall-back system for using a glyph from another music font if a glyph is not available in the current music font.

You can test this out in VHV by changing the music font in the menu view → music font:

Screen Shot 2022-11-07 at 2 16 52 PM

https://verovio.humdrum.org/?file=https://raw.githubusercontent.com/WolfgangDrescher/humdrum-figured-bass-filter-demo/master/kern/06.krn

Here is Bravura:

Screen Shot 2022-11-07 at 2 18 04 PM

Gootville (not showing):

Screen Shot 2022-11-07 at 2 18 17 PM

Leipzig:

Screen Shot 2022-11-07 at 2 19 27 PM

Leland (not showing):

Screen Shot 2022-11-07 at 2 19 57 PM

Petaluma:

Screen Shot 2022-11-07 at 2 20 23 PM

So the problem is that you are (1) using the Leland font, which is the default font in VHV if you do not select a music font, and (2) the figured bass characters are not in the reduced-glyph TTF font for Leland that is appended to the SVG image.

The cause of (2) can be either (3a) that there is no figured bass glyphs in the full Leland font (possible, although the original SCORE font it is based on has figured bass symbols), or (3b) the figured-bass glyphs were not included into the reduced-glyph TTF font embedded in the SVG for Leland.

The fastest solution would be to use a music font that displays the figured bass (Bravura, Leipzig, or Petaluma) by changing the music font in the view → music font menu. This would need to be done by individual users, so not ideal if you have a publically accessible score.

To fix for everyone, in theory you should be able to add a line such as:

!!!verovio: font Leipzig

to the Humdrum file to force it to display in Leipzig, but this currently does not seem to be working (probably the music-font selection is overriding that option setting).


To fixing Leland, either have the figured-bass glyphs added to the font if they are missing in the full font set, or add them explicitly to the reduced-glyph set that is embedded by verovio into the SVG image. I thing that @rettinghaus mentions basically how to do this in the post: https://github.com/rism-digital/verovio/issues/3075#issuecomment-1285181824

This is somewhat related to the discussion about elisions: https://github.com/rism-digital/verovio/discussions/3084

An ideal solution would be to create a dynamic TTF font for only the music-font glyphs used in text portions of the SVG. This would allow for the original glyph fallback system to be done before creating the TTF content.

An intermediate solution would be to use the standard music font system when all characters in a text-like element are music-font characters, and only used embedded music-font TTF system when there is a mixture of text and musical symbols.

craigsapp avatar Nov 07 '22 22:11 craigsapp

For the old-fashioned ö, this is probably related to the text font being used.

In a plain SVG image output from verovio, the font is a generic "Times", and the box where the e should be is not a wrong glyph, but rather the browser's (annoying) way of telling you that the glyph is undefined:

Screen Shot 2022-11-07 at 2 50 15 PM

In VHV the e is visible (but not centered, which is probably due to the font metrics):

Screen Shot 2022-11-07 at 2 52 28 PM

Notice that the two text fonts are not the same. VHV is using EB Garamond: https://fonts.google.com/specimen/EB+Garamond

This is controlled by these CSS instructions:

https://github.com/humdrum-tools/verovio-humdrum-viewer/blob/4f3e62/styles/styles.css#L413-L439

Where Times is mapped to EB Garamond:

@font-face {
	font-family: "Times";
	src: url("../scripts/pdfkit/EBGaramond-Regular.ttf");
	font-style: normal;
	font-weight: normal
}

I presume that the "Times" font used to render generic SVG images does not have the superscript e accent, while EB Garamond does.

You can insert a similar instruction into the SVG within a <style> element, or on the webpage where the SVG is displayed to do the same with EB Garamond, or a similar font that includes the e accent glyph. On the Google font webpages, you can set up an @import instruction to download the font directly from Google (on VHV, the font is being accessed from the VHV website files). Here is the @import I created on the page: https://fonts.google.com/specimen/EB+Garamond

<style>
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,700;1,400;1,700&display=swap');
</style>

This includes regular, italic, bold and bold italic versions of EB Garamond.

When I try to print the verovio SVG output to a PDF file, the e accent is not printing for some reason (despite EB Garamond being used for the PDF output).

Screen Shot 2022-11-07 at 3 00 33 PM

The PDF is also using EB Garamond, so I do not know exactly why it is not displaying (maybe an interaction between "Times" and EB Garamond, where the printing system says that there is no e in "Times" so it gets suppressed).


When I try typing the e on Google fonts test page for EB Garamond, it is also not displaying for some reason:

Screen Shot 2022-11-07 at 3 06 13 PM

https://fonts.google.com/specimen/EB+Garamond/tester

Test text: boͤsen

craigsapp avatar Nov 07 '22 23:11 craigsapp

In a plain SVG image output from verovio, the font is a generic "Times", and the box where the e should be is not a wrong glyph, but rather the browser's (annoying) way of telling you that the glyph is undefined

I see, thank you for this hint. It seems like "EB Garamond" from Google Fonts ist not the same font like the one you are using in VHV.

Hotlinking to the font VHV is using does work:

@font-face {
    font-family: "Times";
    src: url("https://verovio.humdrum.org/scripts/pdfkit/EBGaramond-Regular.ttf");
    font-style: normal;
    font-weight: normal
}

Embedding "EB Garamond" from google fonts does not:

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,700;1,400;1,700&display=swap');

svg g {
    font-family: 'EB Garamond';
}

Probably the glyph is not present in this version of the font.

But also other fonts that should support the e accent glyph do not work in the verovio output. See this list to find supported fonts: https://fonts.google.com/?category=Serif,Sans+Serif&preview.text=bo%CD%A4sen&preview.text_type=custom

On the left is the verovio output with the JS toolkit, the the right the screenshot from google fonts.

Noto Sans:

Bildschirm­foto 2022-11-08 um 13 46 40

Noto Serif:

Bildschirm­foto 2022-11-08 um 13 47 44

Arimo:

Bildschirm­foto 2022-11-08 um 13 48 33

EB Garamond:

Bildschirm­foto 2022-11-08 um 13 49 56

However, since it works with the VHV font, it doesn't seem to be a problem with the coding. I will switch back to normal ö umlauts for now.

WolfgangDrescher avatar Nov 08 '22 13:11 WolfgangDrescher

To fixing Leland, either have the figured-bass glyphs added to the font if they are missing in the full font set, or add them explicitly to the reduced-glyph set that is embedded by verovio into the SVG image. I thing that @rettinghaus mentions basically how to do this in the post: https://github.com/rism-digital/verovio/issues/3075#issuecomment-1285181824

Having a brief look into supported.xml without knowing any of the verovio font logic it looks like this glyphs should be active: https://github.com/rism-digital/verovio/blob/dec17c8ba4e1938b6b27f49b5f6e43bf30fe9ebc/fonts/supported.xml#L2463-L2498

And using the link from the verovio book for the symbol set and checking for the Leland font it looks like the figured bass numbers should be included: https://torinak.com/font/lsfont.html#https://raw.githubusercontent.com/rism-digital/verovio/develop/fonts/Leland/Leland.otf

Should I open a new issue for this in the verovio repository?

WolfgangDrescher avatar Nov 08 '22 13:11 WolfgangDrescher