The function is correct for the IDAutomation fonts which use codes that are a little different from the standard Code 128. I've updated the function to allow for a smaller barcode using Code C (numeric only symbols) when the rest of the barcode is numbers: