@nagwa-limited/kashida-engine
Version:
An engine to unify array of Arabic strings to the same width using Kashidas
13 lines (12 loc) • 578 B
TypeScript
/**
* Uses `canvas.measureText` to compute and return the width of the given text of given font in pixels.
* @param { String } text The text to be rendered.
* @param { String } font The css font descriptor that text is to be rendered with (e.g. "bold 14px verdana").
* @returns { Number } The width of the text inputted.
* @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393
*/
export declare const getTextWidth: {
(text: string, font: string): number;
canvas?: HTMLCanvasElement;
};
export default getTextWidth;