Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle variations of Font size attribute values #15

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/helpers/xml-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,24 @@ const fixupLineHeight = (lineHeight, fontSize) => {

// eslint-disable-next-line consistent-return
const fixupFontSize = (fontSizeString, docxDocumentInstance) => {
if (fontSizeString === 'xx-small') {
K-Kumar-01 marked this conversation as resolved.
Show resolved Hide resolved
fontSizeString = '9px';
} else if (fontSizeString === 'x-small') {
fontSizeString = '10px';
} else if (fontSizeString === 'small') {
fontSizeString = '13px';
} else if (fontSizeString === 'medium') {
fontSizeString = '16px';
} else if (fontSizeString === 'large') {
fontSizeString = '18px';
} else if (fontSizeString === 'x-large') {
fontSizeString = '24px';
} else if (fontSizeString === 'xx-large') {
fontSizeString = '32px';
} else if (fontSizeString === 'xxx-large') {
fontSizeString = '48px';
}

if (pointRegex.test(fontSizeString)) {
const matchedParts = fontSizeString.match(pointRegex);
// convert point to half point
Expand All @@ -298,6 +316,7 @@ const fixupFontSize = (fontSizeString, docxDocumentInstance) => {
}
};


// eslint-disable-next-line consistent-return
const fixupRowHeight = (rowHeightString, parentHeight = 0) => {
if (pointRegex.test(rowHeightString)) {
Expand Down