Holger-Will / barcode-font-generator

a simple way to create your own barcode fonts
GNU General Public License v2.0
15 stars 5 forks source link

font generation not working properly #1

Open festwertspeicher opened 6 years ago

festwertspeicher commented 6 years ago

i'm on a windows 10 machine and used bash on ubuntu on windows to generate a barcode font with your generator. when i try to install the .ttf to the windows font explorer it gives me an error-message "name.ttf is not a valid font". if i use it anyway it just prints out a very squished code similar to this issue. at first I suspected this to be a problem with the linux subsystem i'm using for generating the font - but with your generated font i had the same issue. because i though it might be a problem with the .ttf file i also tried to convert the .svg to a .ttf file format but the problem still occurs. the render engine of firefox and chrome do not have an issue with your font, but internet explorer is crushing up the barcodes too.

festwertspeicher commented 6 years ago

i did some troubleshooting but wasn't able to fix the font yet. i took a look into the generated .svg because it's the most human-readable file format to see whats going on.

while investigationg this problem i soon discovered that the only working glyph is the asterix * and the only working ligature is the double asterix **. and it's kind of strange, that even this ligature is working. because in the svg 1.1 specs it says

When determining the glyph(s) to draw a given character sequence, the ‘font’ element is searched from its first ‘glyph’ element to its last in logical order to see if the upcoming sequence of Unicode characters to be rendered matches the sequence of Unicode characters specified in the ‘unicode’ attribute for the given ‘glyph’ element. The first successful match is used. Thus, the "ffl" ligature needs to be defined in the font before the "f" glyph; otherwise, the "ffl" will never be selected.

so to be precise the double asterix has to be defined before the single asterix in the svg code.

i first though it could be a problem with the svg header and updated it to

<?xml version="1.0" standalone="yes"?>
<svg width="100%" height="100%" version="1.1"
 xmlns = 'http://www.w3.org/2000/svg'>

next i discovered that even without using the -wn, --with-numbres feature there is something strange happening to the _0 - _9 ligature. one example that is produced by your generator is

<glyph unicode = "_8" horiz-adv-x = "700" d = "M322-74q0 7 4 12t10 9q-3 1-7 3t-5 5-3 7-1 7q0 6 3 11t6 8 9 5 11 1q6 0 11-1t10-5 6-8 2-11q0-4-1-7t-3-7-5-5-6-3q3-1 5-4t4-5 3-5 1-7q0-6-2-10t-6-8-8-5-11-2q-6 0-10 2t-9 5-6 8-2 10z m10 42q0-4 1-6t4-6 5-3 7-2q4 0 7 2t6 3 3 6 1 6q0 4-1 7t-3 6-6 3-7 1q-4 0-7-1t-5-3-4-6-1-7z m2-42q0-3 1-6t3-5 5-3 6-1 6 1 5 3 3 5 1 6-1 7-3 5-5 3-6 1q-3 0-6-1t-5-3-3-5-1-7z" />

as you can see in this pen its a path outside the svg object. and this lets the render engine of firefox and chrome print an upsidown digit below the barcode (see picture below). but one should open another issue for this.

firefox

i inserted a glyph for space, hyphen and used the svg <missing-glyph> to complete the font because i heard that it can cause problems in some file formats when space and hyphen are missing. with the missing-glyph you can see, that the ligatures are not working correctly and couldn't be found in the font.

I also tried to refer to the characters of the ligatures in unicode in hexadecimal and decimal notation. and also defined the path inside the glyph-tag. but the ligatures are still failing when not displayed in firefox or chrome.

<glyph unicode = "&#x4C;&#x30;" horiz-adv-x = "700"><path d="M 300, 0 V 6000 h 200 V 0 z M 600, 0 V 6000 h 100 V 0 z"/></glyph>

Holger-Will commented 6 years ago

fist of all thank you very much for reporting this bug and for your investigation. the last "problem" you report is the desired behaviour, because in fonts, the coordinate system is "upside down" compared to how it usualy is in svg. that is why the numbers are upside down.

Holger-Will commented 6 years ago

for debugging, you can open the font in fontforge https://fontforge.github.io/en-US/ and see if there are any errors reported... and try to reexport it from there and see if that helps... i sure did test the generated fonts with fontforge, but who knows if there is a regression somewhere.

Holger-Will commented 6 years ago

you are right with the ordering of the * and ** glyph. Though i don't use svg fonts directly, it might work, becuase glyph selection in ttf and woff is different from svg, i don't know though...

festwertspeicher commented 6 years ago

the last "problem" you report is the desired behaviour, because in fonts, the coordinate system is "upside down" compared to how it usualy is in svg. that is why the numbers are upside down.

but there shouldn't be any numbers at all if i don't use --with-numbres...

for debugging, you can open the font in fontforge https://fontforge.github.io/en-US/ and see if there are any errors reported... and try to reexport it from there and see if that helps... i sure did test the generated fonts with fontforge, but who knows if there is a regression somewhere. mhm, but the error also exists with your generated font. when not displayed in firefox or safari, only * and ** is displayed.

i downloaded fontforge imported, validated and saved your font. there is only this message while saving. problem still existing.... error

you are right with the ordering of the * and ** glyph. Though i don't use svg fonts directly, it might work, becuase glyph selection in ttf and woff is different from svg, i don't know though...

i don't use svg fonts eighter, it was just the only file-format i could actually read and see what might causes problems.

festwertspeicher commented 6 years ago

i somehow managed to get the font working but still asking myself what is wrong with the files generated by your script. i attached a latin character like 'a' and used this online converter converter from .ttf to .ttf 👍 to make a valid font for windows. without any further knowledge about font file formats i can only guess why this is a woking solution...

michaelknigge commented 5 years ago

Holger, thank you for your support so far. Chrome displays the font correctly! My screenshot above was taken on a Windows 10 computer and Internet Explorer...

Okay... I'll give the mentioned font converter a try.... Thank you!

Holger-Will commented 5 years ago

@michaelknigge have a look at https://stackoverflow.com/questions/14145121/ligatures-in-internet-explorer could you try to add this to the @font-face-rule and tell me if that works?

font-feature-settings: "liga" 1; 
 -ms-font-feature-settings: "liga" 1;

and/or this for the text using the font:

text-rendering: optimizeLegibility

(sorry, still no access to a windows machine)

michaelknigge commented 5 years ago

It does not work if I add the font-feature-settings to the @font-face-rule - but it works if the settings are added to the font elements - like this:

.i2of5_S {
    font-family: i2of5_S; 
    font-size:28px; 
    font-feature-settings: "liga" 1; 
    -ms-font-feature-settings: "liga" 1;
}

Thank you!

Holger-Will commented 5 years ago

ahh! great, good to know. I will update the examples. Thanks for testing!

nowzig commented 5 years ago

I have a similar problem. I try to use the ean13 font in Crystal Reports, but I only get image Also the PDF export from Crystal reports looks the same.

I don't know whether this has something to do with it but in Excel 2013 print preview the barcode also looks not normal: image All on Windows 10 with the ttf ean13 font.

Holger-Will commented 5 years ago

can you use the font in other places on windows?

nowzig commented 5 years ago

yes I can, e.g. I can use it in Excel or Word and everything looks fine. Just in the print preview it looks like described, but if I print it out, everything is fine too. So my main problem is Crystal reports right now, where only those lines are visible.

nowzig commented 5 years ago

I tried some other svg to ttf converters and all I got was image Unfortunately I am no font expet at all, so I do not know what information may help.

nowzig commented 5 years ago

just to let you know the code128 font is working fine

Holger-Will commented 5 years ago

have you tried the ttf to ttf converter mentioned by @festwertspeicher ?

nowzig commented 5 years ago

yes, but it did not help. Maybe it is the part

i attached a latin character like 'a'

that actually helped him

But I do not know how to do that