Reputation: 1495
I have an HTML document that includes this line of text:
<div style="margin:5px"><span style="font-family: 'Libre Barcode 128'; font-size: 30px;">Ì1234560Î</span></div>
This is code128 encoded string being passed to the Libre Barcode 128 font which is installed and linked in the html.
However it is rendering in the HTML Displayed file as:
�1234560�
I have the HTML encoded to UTF-8, but that doesn't seem to be working.
Any suggestions are welcome.
Upvotes: 0
Views: 35
Reputation: 1766
Try adding cursive to your font-family declaration:
<div style="margin:5px"><span style="font-family: 'Libre Barcode 128', cursive; font-size: 30px;">Ì1234560Î</span></div>
var x = '123456';
var j, intWeight, intLength, intWtProd = 0, arrayData = [];
var arraySubst = [ "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê" ];
/*
* Checksum Calculation for Code 128 B
*/
intLength = x.length;
arrayData[0] = 104;
intWtProd = 104;
for (j = 0; j < intLength; j += 1) {
arrayData[j + 1] = x.charCodeAt(j) - 32; // Have to convert to Code 128 encoding
intWeight = j + 1; // to generate the checksum
intWtProd += intWeight * arrayData[j + 1]; // Just a weighted sum
}
arrayData[j + 1] = intWtProd % 103; // Modulo 103 on weighted sum
arrayData[j + 2] = 106; // Code 128 Stop character
chr = parseInt(arrayData[j + 1], 10); // Gotta convert from character to a number
if (chr > 94) {
chrString = arraySubst[chr - 95];
} else {
chrString = String.fromCharCode(chr + 32);
}
document.getElementById("check").innerHTML = 'Chksum (' + chr + '), char (' + chrString + ') for text = "' + x + '"';
document.getElementById("test").innerHTML = 'Ì' + x + chrString + 'Î';
<head>
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+128" rel="stylesheet">
</head>
<body>
<div id="check"></div>
<br />
<span id="test"
style="font-family: 'Libre Barcode 128', cursive;
font-size: 30px;"> </span><br />
</body>
Upvotes: 0