refactor: moves font size and type to a constant
This commit is contained in:
parent
651d576eea
commit
0ba3ae14a4
@ -10,6 +10,18 @@ PDFJS.GlobalWorkerOptions.workerSrc = 'node_modules/pdfjs-dist/build/pdf.worker.
|
|||||||
* @constant {number}
|
* @constant {number}
|
||||||
*/
|
*/
|
||||||
const SCALE: number = 3;
|
const SCALE: number = 3;
|
||||||
|
/**
|
||||||
|
* Defined font size used when generating a PDF. Currently it is difficult to fully
|
||||||
|
* correlate font size used at the time of filling in / drawing on the PDF
|
||||||
|
* because it is dynamically rendered, and the final size.
|
||||||
|
* This should be fixed going forward.
|
||||||
|
* Switching to PDF-Lib will most likely make this problem redundant.
|
||||||
|
*/
|
||||||
|
const FONT_SIZE: number = 40;
|
||||||
|
/**
|
||||||
|
* Current font type used when generating a PDF.
|
||||||
|
*/
|
||||||
|
const FONT_TYPE: string = 'Arial';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a PDF ArrayBuffer to a generic PDF File
|
* Converts a PDF ArrayBuffer to a generic PDF File
|
||||||
@ -162,7 +174,8 @@ const hasValue = (mark: Mark): boolean => !!mark.value;
|
|||||||
*/
|
*/
|
||||||
const draw = (mark: Mark, ctx: CanvasRenderingContext2D) => {
|
const draw = (mark: Mark, ctx: CanvasRenderingContext2D) => {
|
||||||
const { location } = mark;
|
const { location } = mark;
|
||||||
ctx!.font = '20px Arial';
|
|
||||||
|
ctx!.font = FONT_SIZE + 'px ' + FONT_TYPE;
|
||||||
ctx!.fillStyle = 'black';
|
ctx!.fillStyle = 'black';
|
||||||
const textMetrics = ctx!.measureText(mark.value!);
|
const textMetrics = ctx!.measureText(mark.value!);
|
||||||
const textX = location.left + (location.width - textMetrics.width) / 2;
|
const textX = location.left + (location.width - textMetrics.width) / 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user