From 6256f8751859a9c37ecb786b49b29b81532596d0 Mon Sep 17 00:00:00 2001 From: Dmitry Kuzin Date: Tue, 29 Oct 2024 18:28:11 +0400 Subject: [PATCH] Use internal font for radio item check mark --- src/pdf_render/pdf_radioitem.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pdf_render/pdf_radioitem.ts b/src/pdf_render/pdf_radioitem.ts index 073b1e2..652412f 100644 --- a/src/pdf_render/pdf_radioitem.ts +++ b/src/pdf_render/pdf_radioitem.ts @@ -46,8 +46,9 @@ export interface IRadioGroupItemBrickContext { } export class RadioItemBrick extends PdfBrick { - private static readonly RADIOMARKER_READONLY_SYMBOL: string = '•'; - private static readonly RADIOMARKER_READONLY_FONT_SIZE_SCALE: number = 1.575; + private static readonly RADIOMARKER_READONLY_SYMBOL: string = 'l'; + private static readonly RADIOMARKER_READONLY_FONT: string = 'zapfdingbats'; + public static readonly RADIOMARKER_READONLY_FONT_SIZE_SCALE: number = 1.0 - ((2.0 + Math.E) / 10.0); public constructor(controller: DocController, rect: IRect, private context: IRadioGroupItemBrickContext, private radioGroupWrap: RadioGroupWrap) { @@ -99,20 +100,23 @@ export class RadioItemBrick extends PdfBrick { public async renderReadOnly(): Promise { SurveyHelper.renderFlatBorders(this.controller, this); if (this.context.checked) { - let radiomarkerPoint: IPoint = SurveyHelper.createPoint(this, true, true); - let oldFontSize: number = this.controller.fontSize; + const radiomarkerPoint: IPoint = SurveyHelper.createPoint(this, true, true); + const oldFontSize: number = this.controller.fontSize; + const oldFontName: string = this.controller.fontName; + this.controller.fontName = RadioItemBrick.RADIOMARKER_READONLY_FONT; this.controller.fontSize = oldFontSize * RadioItemBrick.RADIOMARKER_READONLY_FONT_SIZE_SCALE; let radiomarkerSize: ISize = this.controller.measureText( RadioItemBrick.RADIOMARKER_READONLY_SYMBOL); radiomarkerPoint.xLeft += this.width / 2.0 - radiomarkerSize.width / 2.0; - radiomarkerPoint.yTop += this.height / 2.0 - radiomarkerSize.height / 1.925; + radiomarkerPoint.yTop += this.height / 2.0 - radiomarkerSize.height / 2.0; let radiomarkerFlat: IPdfBrick = await SurveyHelper.createTextFlat( radiomarkerPoint, this.question, this.controller, RadioItemBrick.RADIOMARKER_READONLY_SYMBOL, TextBrick); (radiomarkerFlat.unfold()[0]).textColor = this.textColor; - this.controller.fontSize = oldFontSize; await radiomarkerFlat.render(); + this.controller.fontSize = oldFontSize; + this.controller.fontName = oldFontName; } } } \ No newline at end of file