Melodeon.net Forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the new melodeon.net forum

Pages: [1] 2 3   Go Down

Author Topic: EasyABC - exporting as SVG - fonts used  (Read 10032 times)

0 Members and 1 Guest are viewing this topic.

Stiamh

  • Old grey C#/D pest
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3611
    • Packie Manus Byrne
EasyABC - exporting as SVG - fonts used
« on: March 29, 2020, 10:33:41 PM »

When I export a single tune as an SVG, the output disregards formatting commands such as %%titlefont, %%composerfont, etc. Everything is in what looks like Times Roman.

This does not happen when exporting to PDF, when fonts are displayed as specified.

Any ideas? Thanks in advance.

EasyABC 1.3.7.7 2017-08-31, Windows 10.

Mike Hirst

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1433
  • Black Dot B/C, Bastardo C#/D, Corona II GCF
Re: EasyABC - exporting as SVG - fonts used
« Reply #1 on: March 30, 2020, 09:18:21 AM »

I have had problems with this in the past. After much struggling and experimentation I did manage to get things to work using a very limited set of fonts. iirc this was limited by those fonts that I had installed on my computer and knowing the correct location. Any recommendations I make may not work on your system.

In my experience the best way to deal with this is to export the SVG then edit using either a dedicated GUI vector package such as inkscape or Adobe Illustrator, or by opening the svg/xml file using a plain text editor and making the necessary adjustments by hand.
Logged
Semper idem, sed non eodem modo

Mike Hirst

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1433
  • Black Dot B/C, Bastardo C#/D, Corona II GCF
Re: EasyABC - exporting as SVG - fonts used
« Reply #2 on: March 30, 2020, 11:01:03 AM »

As an example of the process I have described above, the attached PDF was made made by exporting the musical notation from abc to SVG using abcm2ps. The resulting SVG was then imported to Inkscape where text was added and layout defined. If I can find them, i have some examples where i have used a set of unusual fonts to replicate 18thC chapbooks.
Logged
Semper idem, sed non eodem modo

Stiamh

  • Old grey C#/D pest
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3611
    • Packie Manus Byrne
Re: EasyABC - exporting as SVG - fonts used
« Reply #3 on: March 30, 2020, 01:40:07 PM »

Thanks Mike. I confess I was hoping for a less labour-intensive solution, since the project I am working on involves creating upwards of 500 SVG files. But thank you for the link to Inkscape, which looks like a very fine initiative.

Presumably EasyABC uses an external component to convert scores to SVG, but poking about in the settings I can't find an indication as to what that might be. Somewhere in that component these fonts must be specified. I suppose the next step is a question to the ABC users Yahoo group, which I was hoping to avoid...
 

Gena Crisman

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1108
  • 🇬🇧
Re: EasyABC - exporting as SVG - fonts used
« Reply #4 on: March 30, 2020, 02:21:42 PM »

Hi,

Easy abc is (most likely) using abcm2ps to output to svg

What are you using to view your svg files, and, can you provide some examples.
Logged

Tone Dumb Greg

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 4955
    • Dartmoor Border Morris
Re: EasyABC - exporting as SVG - fonts used
« Reply #5 on: March 30, 2020, 02:25:52 PM »

or, import into musescore then export as SVG, maybe?
Logged
Greg Smith
DG/GC Pokerwork, DG 2.4 Saltarelle, pre-war CF Hohner, Hohner 1040 Vienna style, old  BbEb Hohner that needs a lot of work.

ACCORDION, n. An instrument in harmony with the sentiments of an assassin. Ambrose Bierce

Stiamh

  • Old grey C#/D pest
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3611
    • Packie Manus Byrne
Re: EasyABC - exporting as SVG - fonts used
« Reply #6 on: March 30, 2020, 02:59:01 PM »

Easy abc is (most likely) using abcm2ps to output to svg. What are you using to view your svg files, and, can you provide some examples.

Viewing in a browser - the intended purpose. Can't attach svg files - example here.

or, import into musescore then export as SVG, maybe?

I had a hunch this suggestion would be forthcoming... Thanks, but I really don't want to add another step in the process, 500 files and all that. :|glug

Steve_freereeder

  • Content Manager
  • Hero Member
  • ***
  • Offline Offline
  • Posts: 7511
  • MAD is inevitable. Keep Calm and Carry On
    • Lizzie Dripping
Re: EasyABC - exporting as SVG - fonts used
« Reply #7 on: March 30, 2020, 03:04:54 PM »

or, import into musescore then export as SVG, maybe?

Yes - MuseScore export to SVG works nicely, and preserves fonts.

Just being curious though: what is the advantage in this instance of converting ABC to SVG? Why not stick with exporting to PDF, seeing as it preserves all the fonts, etc., that Stiamh (the OP) wants? As far as I can see, unless you are going to perform complex or sophisticated graphics manipulation on the resulting file, it seems a slightly odd thing to want to do to a music file.

Edit - have just seen Stiamh's last post.
I thought that PDF files can be viewed in a browser quite happily, or am I wrong?
« Last Edit: March 30, 2020, 03:07:58 PM by Steve_freereeder »
Logged
Steve
Sheffield, UK.
www.lizziedripping.org.uk

Anahata

  • This mind intentionally left blank
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 6767
  • Oakwood D/G, C/F Club, 1-rows in C,D,G
    • Treewind Music
Re: EasyABC - exporting as SVG - fonts used
« Reply #8 on: March 30, 2020, 04:18:13 PM »

PDFs view directly in Chrome and its many relatives, but not in Firefox, in my recent experience.
SVG is an image format like jpeg and PNG that can be simply inserted in any HTML document. PDF is not, so all you can do is display the whole PDF in the browser window by itself.
Logged
Слава Україні !
Music recording and web hosting: www.treewind.co.uk
Mary Humphreys and Anahata: www.maryanahata.co.uk
Ceilidh band: www.barleycoteband.co.uk

Mike Hirst

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1433
  • Black Dot B/C, Bastardo C#/D, Corona II GCF
Re: EasyABC - exporting as SVG - fonts used
« Reply #9 on: March 30, 2020, 04:43:10 PM »

SVG is an image format like jpeg and PNG
SVG (scalar vector graphic) is an XML format which can be styled using CSS. The attached PDF was produced by applying an external CSS file to SVG exported from abcm2ps.

The two line CSS instruction show below was used to style the tune title.

Code: [Select]
g:first-of-type {
font-family: Milkmoustachio !important;
font-size: 60px !important;
}
« Last Edit: March 30, 2020, 04:46:35 PM by Mike Hirst »
Logged
Semper idem, sed non eodem modo

Gena Crisman

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1108
  • 🇬🇧
Re: EasyABC - exporting as SVG - fonts used
« Reply #10 on: March 30, 2020, 04:49:37 PM »

Viewing in a browser - the intended purpose. Can't attach svg files - example here.

There is more than one browser, on more than one platform. Also, what is it supposed to look like.

Your SVG file has:
Code: [Select]
<title> page 1</title>
<!-- Creator: abcm2ps-8.14.7 -->
<!-- CreationDate: Mar 29, 2020 17:20 -->
<!-- CommandLine: - -O TQ002.svg -v -->
<g stroke-width="0.70">
<!-- title: Berceuse pour Hannah -->
</g>
<g stroke-width="0.70" style="font:22.00px Helvetica,">
<text x="396.90" y="45.60" text-anchor="middle">Berceuse pour Hannah</text>
</g>
<g stroke-width="0.70" style="font:14.00px Helvetica,16">
<text x="774.90" y="70.00" text-anchor="end">Réjean Brunet, Richard Forest, Sabin Jacques (Québec)</text>
</g>
<g stroke-width="0.70" style="font:20.00px Arial,">
<text x="18.90" y="78.00">ABA</text>
</g>
<g stroke-width="0.70" style="font:20.00px Arial,">
<text x="86.90" y="106.00">A</text>

At the start, meaning that it did not render the fonts out as vector images, so, you will be depending on the ability of a browser/platform to render the fonts, which is fine and normal but is a real consideration one might make. I can also see that it's going to try and use Helvetica and Arial?

What font is it supposed to be using? I'm assuming you're using the commas and such from this thread http://forum.melodeon.net/index.php?topic=21378.0 ?

Most likely, there is a more correct way to style these fonts than what is happening here.

edit I suspect this is going to be useful (to me) https://stackoverflow.com/a/7742345

Also I noticed you're using 8.14.7 - are you able to compile abcm2ps from source?
« Last Edit: March 30, 2020, 05:33:54 PM by Gena Crisman »
Logged

Stiamh

  • Old grey C#/D pest
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3611
    • Packie Manus Byrne
Re: EasyABC - exporting as SVG - fonts used
« Reply #11 on: March 30, 2020, 05:50:37 PM »

There is more than one browser, on more than one platform. Also, what is it supposed to look like.

What font is it supposed to be using? I'm assuming you're using the commas and such from this thread http://forum.melodeon.net/index.php?topic=21378.0 ?

Most likely, there is a more correct way to style these fonts than what is happening here.

edit I suspect this is going to be useful (to me) https://stackoverflow.com/a/7742345

Also I noticed you're using 8.14.7 - are you able to compile abcm2ps from source?

Duh, I never realised you could open an SVG in a text editor...

The fonts and sizes are actually those specified in the formatting commands I used! So the browser is ignoring them?

Checking all my browsers: Opera, Chrome, Firefox and MS Edge all show a Times-type serif font. But the dreaded IE 11 (which I am obliged to keep to connect with a particular customer) is showing a Helvetica/Arial sans-serif font, and displaying the relative sizes.  ::)

I have never got into compiling stuff. I just downloaded the latest version of abcm2ps and pointed EasyABC to it.

Edited to add: Firefox  :(
« Last Edit: March 30, 2020, 06:15:16 PM by Stiamh »
Logged

Gena Crisman

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1108
  • 🇬🇧
Re: EasyABC - exporting as SVG - fonts used
« Reply #12 on: March 30, 2020, 06:25:55 PM »

May I have the ABC styling commands, please?

At some point, abcm2ps switched to using css invoking style to set the font and size. At the very least as a result of this, trailing commas are bad and may cause the whole font code to be ignored. This may however mean it can use webfonts, but, I'm no expert. I haven't updated my abcm2ps binary and it uses a different method to set the font.

Otherwise, if you're using Helvetica, you should know that basically only mac users will have that font.

If you need to use a font for some particular reason, and want everyone to see it no matter what, it turns out it's possible to use Inkscape via command line (and thus, easily batchable across 500 files) to convert text to paths, which will basically render the text on your PC (which has the font) and convert it to vectors so everyone else's computer will always know how to render it. However this is kinda the same as taking a screen shot of text? It will remain crisp because vectors, but, it will cease to actually be text. It will also make your files significantly larger and may create some minor differences when compared side by side. My test file was 10x larger.

Advice #1) Try making sure no trailing commas are being invoked.
Advice #2) Consider rendering text-to-path via inkscape cli, inkscape in.svg --export-text-to-path --export-plain-svg out.svg worked for me.
Logged

Stiamh

  • Old grey C#/D pest
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3611
    • Packie Manus Byrne
Re: EasyABC - exporting as SVG - fonts used
« Reply #13 on: March 30, 2020, 06:45:44 PM »

May I have the ABC styling commands, please?

%%titlefont Helvetica, 22
%%subtitlefont Helvetica,16
%%composerfont Helvetica,16
%%wordsfont Helvetica,16
%%partsfont Arial, 20
%%partsbox
%%gchordfont Arial, 16
%%barnumbers 0
%%printtempo 0
%%writefields S

I'm feeling pretty silly now. I think I inherited the formatting commands from a Mac-using collaborator on the project, hence the Helvetica specification.

Strangely enough, the partsfont was Arial, but that wasn't working.

However, I just changed the titlefont to Arial and for fun the composerfont to Courier New and they worked. Font size respected, too.

CSS allows you to specify a series of possible fonts such as

   {font: bold 11pt/12pt Verdana, Arial, Helvetica, sans-serif}

I wonder if abc2mps and SVG do? More experiments coming up.

Thanks for pointing me down the right path, as you have done before  :|glug

Quote
At some point, abcm2ps switched to using css invoking style to set the font and size. At the very least as a result of this, trailing commas are bad and may cause the whole font code to be ignored. This may however mean it can use webfonts, but, I'm no expert. I haven't updated my abcm2ps binary and it uses a different method to set the font.

Otherwise, if you're using Helvetica, you should know that basically only mac users will have that font.

If you need to use a font for some particular reason, and want everyone to see it no matter what, it turns out it's possible to use Inkscape via command line (and thus, easily batchable across 500 files) to convert text to paths, which will basically render the text on your PC (which has the font) and convert it to vectors so everyone else's computer will always know how to render it. However this is kinda the same as taking a screen shot of text? It will remain crisp because vectors, but, it will cease to actually be text. It will also make your files significantly larger and may create some minor differences when compared side by side. My test file was 10x larger.

Advice #1) Try making sure no trailing commas are being invoked.
Advice #2) Consider rendering text-to-path via inkscape cli, inkscape in.svg --export-text-to-path --export-plain-svg out.svg worked for me.

I'll investigate using CSS and style, and will bear all the rest in mind if I can't get things to work with simpler remedies! Thanks.

Gena Crisman

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1108
  • 🇬🇧
Re: EasyABC - exporting as SVG - fonts used
« Reply #14 on: March 30, 2020, 07:03:24 PM »

I wouldn't feel silly - there's a good chance that at some point one of the many rendering pathways required the presence of such a comma. There's a good chance that may still be the case. People in that other thread found it was necessary, for whatever reason.

Odds are, yes, abcm2ps will take whatever you type in and will pass it through to the outputted svg without thinking too much about it. The exact code that's used is here: https://github.com/leesavide/abcm2ps/blob/master/svg.c#L1278 and you can see it doesn't do much except attempt to fix capital letters in 'Bold' 'Italic' and 'Oblique', then after that I'm guessing prints whatever wasn't interpreted as the font size out after the size (as a 2 decimal point float for some reason).

Worst case you can put some placeholder word in there and find/replace, again as a batch operation with a powerful text editor, and replace it with the font instructions you would like to be present. In theory you should be able to suggest several fonts exactly as you describe, however, should that list of fonts end in a comma (and it was getting sent 'Helvetica,', css is most likely going to say 'you did a bad' and ignore the whole list, size and all.

So hopefully the fix is:

%%titlefont Helvetica, 22
->
%%titlefont Helvetica 22
->
%%titlefont Helvetica, Some_Other_Font 22


But idk maybe it's going to split on the first space and explode, I'm not sure.

Best of luck.
Logged

Steve_freereeder

  • Content Manager
  • Hero Member
  • ***
  • Offline Offline
  • Posts: 7511
  • MAD is inevitable. Keep Calm and Carry On
    • Lizzie Dripping
Re: EasyABC - exporting as SVG - fonts used
« Reply #15 on: March 30, 2020, 07:33:38 PM »

PDFs view directly in Chrome and its many relatives, but not in Firefox, in my recent experience.
SVG is an image format like jpeg and PNG that can be simply inserted in any HTML document. PDF is not, so all you can do is display the whole PDF in the browser window by itself.
Thanks for the explanation! I can upload and view PDFs in Firefox with no trouble, but I take your point about insertion in an HTML document.
Logged
Steve
Sheffield, UK.
www.lizziedripping.org.uk

Stiamh

  • Old grey C#/D pest
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3611
    • Packie Manus Byrne
Re: EasyABC - exporting as SVG - fonts used
« Reply #16 on: March 30, 2020, 09:02:07 PM »

@Gena, I was feeling silly because of Helvetica being only available on Macs.

But I needn't have because

Quote from: Guido Gonzato's ABC Plus Bible
Formatting  commands specify the character fonts used in various parts of a score. Please note that the common True Type fonts used by the operating system are not the fonts used by abcm2ps. In fact, abcm2ps uses the PostScript fonts provided for and managed by Ghostscript. Standard fonts are shown in Appendix A.4 (p. 134). I remind you that indications for adding new fonts are given in Section 4.3.5 (p. 82).

These standard fonts include Helvetica.  (:)

And yes, it was the bleeding comma.

Thanks to all for the helpful comments and interesting avenues to explore - and especially to Gena (as usual!).

Gena Crisman

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1108
  • 🇬🇧
Re: EasyABC - exporting as SVG - fonts used
« Reply #17 on: March 30, 2020, 09:57:46 PM »

Right but in this case we are only using abcm2ps as a conduit to write svg code, we're not actually using ghostscript to render the text at the time of creating the svg, so, that job is left for the end user's browser, and it most likely becomes the standard problem of fonts-on-the-internet.
Logged

Stiamh

  • Old grey C#/D pest
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3611
    • Packie Manus Byrne
Re: EasyABC - exporting as SVG - fonts used
« Reply #18 on: March 30, 2020, 10:47:48 PM »

Right but in this case we are only using abcm2ps as a conduit to write svg code, we're not actually using ghostscript to render the text at the time of creating the svg, so, that job is left for the end user's browser, and it most likely becomes the standard problem of fonts-on-the-internet.

Ah shite  :D

David Summers

  • Regular debater
  • ***
  • Offline Offline
  • Posts: 159
Re: EasyABC - exporting as SVG - fonts used
« Reply #19 on: March 31, 2020, 11:07:43 AM »

Yes if you want to inline a score into a web page, svg works well, but pdf don't natively inline. E.g. see:

http://davidjohnsummers.uk/music/CastletonCarol/CastletonCarol.html

These were transcribed in lilypond, a text file method of typsetting music. And its a thought, would going via lilypond work better e.g. the lilypond command "abc2ly" converts abc files into lilypond.

svg support in browsers should be solid, it was available natively in html 4.0, and as most browsers aim to support most standards, it should be supported.
« Last Edit: March 31, 2020, 11:45:00 AM by David Summers »
Logged
Pages: [1] 2 3   Go Up
 


Melodeon.net - (c) Theo Gibb; Clive Williams 2010. The access and use of this website and forum featuring these terms and conditions constitutes your acceptance of these terms and conditions.
SimplePortal 2.3.5 © 2008-2012, SimplePortal