Requesting support for Google's barcode font
igauravsehrawat opened this issue · comments
Hi,
Great project.
Would it be good to consider adding support for Libre Barcode 128(Google font) and similar fonts?
Somehow the encoded output from code-128-encoder
does not work, which can you check here.
Is it about standard/conventions? Is it possible to make it work with other barcode fonts?
Thanks
That is a common mistake on part of the font author. The reason for that is that there is a faulty encoder library which was widely used many many years ago, and as a consequence there are a lot of broken fonts and encoders out there.
As this encoder is explicitly standards compliant, i do not want to change its behaviour.
You do have some options though.
- use my code-128-font https://github.com/Holger-Will/code-128-font
- create your own font with the barcode-font-generator https://github.com/Holger-Will/barcode-font-generator
- or you can replace the correct codes with the wrong ones.
as for option 3: i might just implement some kind of quirks mode...
for now here is a patch function which should do the trick ;-)
function patch(x){
var st=x
st=st.replace(/È/g,"Ã")
st=st.replace(/É/g,"Ä")
st=st.replace(/Ê/g,"Å")
st=st.replace(/Ë/g,"Æ")
st=st.replace(/Ì/g,"Ç")
st=st.replace(/Í/g,"È")
st=st.replace(/Î/g,"É")
st=st.replace(/Ï/g,"Ê")
st=st.replace(/Ð/g,"Ë")
st=st.replace(/Ñ/g,"Ì")
st=st.replace(/Ò/g,"Í")
st=st.replace(/Ó/g,"Î")
return st
}
and then
patch(encoder.encode("Test"))
the resulting string should be compatible with the broken fonts you find on the net.
the bug for the broke google font is here: graphicore/librebarcode#9
Wow, thanks for such an elaborated reply.
Listening to conversation on librebarcode, are you going to change the barcode mappings on this repo now?
Thanks
probably yes. depends on the time i find on the weekend.