Skip to content

Commit 4a6f979

Browse files
authored
Merge pull request #454 from surveyjs/bug/451
Fix html content is misaligned on Node
2 parents 8571d72 + 2778851 commit 4a6f979

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/helper_survey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class SurveyHelper {
154154
return controller.useCustomFontInHtml ? controller.fontName : this.STANDARD_FONT;
155155
}
156156
public static generateCssTextRule(fontSize: number, fontStyle: string, fontName: string): string {
157-
return `"font-size: ${fontSize}pt; font-weight: ${fontStyle}; font-family: ${fontName}; color: ${this.TEXT_COLOR};"`;
157+
return `"font-size: ${fontSize}pt; font-weight: ${fontStyle}; font-family: ${fontName}; color: ${this.TEXT_COLOR}; margin: 0"`;
158158
}
159159
public static createHtmlContainerBlock(html: string, controller: DocController, renderAs: IHTMLRenderType): string {
160160
const font = this.chooseHtmlFont(controller);

tests/survey_helper.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,11 @@ test('check getCorrectedImageSize works incorrectly if image could not be loaded
406406
imageSize = await SurveyHelper.getCorrectedImageSize(controller, { imageLink: '', defaultImageWidth: 300, defaultImageHeight: 400 });
407407
expect(imageSize.width).toBe(225);
408408
expect(imageSize.height).toBe(300);
409+
});
410+
411+
test('check SurveyHelper.generateCssTextRule method', () => {
412+
let css = SurveyHelper.generateCssTextRule(12, 'bold', 'MyFont');
413+
expect(css).toBe('"font-size: 12pt; font-weight: bold; font-family: MyFont; color: #404040; margin: 0"');
414+
css = SurveyHelper.generateCssTextRule(8, 'normal', 'Arial');
415+
expect(css).toBe('"font-size: 8pt; font-weight: normal; font-family: Arial; color: #404040; margin: 0"');
409416
});

0 commit comments

Comments
 (0)