expo-barcode-generator
Version:
A React Native barcode generator compatible with Expo
16 lines (12 loc) • 321 B
JavaScript
export function messureText(string, options, context) {
let ctx;
if (context) {
ctx = context;
} else {
return 0;
}
ctx.font = options.fontOptions + ' ' + options.fontSize + 'px ' + options.font;
// Calculate the width of the encoding
const size = ctx.measureText(string).width;
return size;
}