Skip to content

Font size is being shrink and causes extra space below paragraphs #415

Open
@Bartolojed11

Description

@Bartolojed11

Font size is being shrink and causes extra space below paragraphs. Please see attatched image.

bug report

Expected Behavior

Font size should not be shrink so that paragraphs should not have extra spaces below

Current Behavior

Font size is being shrink causing paragraphs to have extra spaces below

Possible Solution

On src/clone-node.ts file, cloneCSSStyle function, i think it's better to have an optional parameter for shrinking font-sizes. Thank you
Optional Parameter example

{
shrinkFontSize: false,
shrinkValue: 0,
shrinkAbsolute: false
}

code snippet

if (name === 'font-size' && value.endsWith('px') && shrinkFontsize && shrinkValue) {
        const reducedFont =  shrinkAbsolute ?  Math.floor(parseFloat(value.substring(0, value.length - 2))) - shrinkValue : parseFloat(value.substring(0, value.length - 2)) - shrinkValue;

        value = `${reducedFont}px`
}

Your Environment

  • html-to-image: [e.g. 0.1.0]
  • OS: [e.g. macOS Sierra 10.12.3]
  • Browser: [e.g. chrome 78.0.3904.108]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions