@pdfme/schemas 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +31 -0
- package/dist/cjs/__tests__/barcode.test.js +341 -0
- package/dist/cjs/__tests__/barcode.test.js.map +1 -0
- package/dist/cjs/__tests__/text.test.js +318 -0
- package/dist/cjs/__tests__/text.test.js.map +1 -0
- package/dist/cjs/src/barcodes/constants.js +19 -0
- package/dist/cjs/src/barcodes/constants.js.map +1 -0
- package/dist/cjs/src/barcodes/helper.js +147 -0
- package/dist/cjs/src/barcodes/helper.js.map +1 -0
- package/dist/cjs/src/barcodes/index.js +11 -0
- package/dist/cjs/src/barcodes/index.js.map +1 -0
- package/dist/cjs/src/barcodes/pdfRender.js +37 -0
- package/dist/cjs/src/barcodes/pdfRender.js.map +1 -0
- package/dist/cjs/src/barcodes/propPanel.js +69 -0
- package/dist/cjs/src/barcodes/propPanel.js.map +1 -0
- package/dist/cjs/src/barcodes/types.js +3 -0
- package/dist/cjs/src/barcodes/types.js.map +1 -0
- package/dist/cjs/src/barcodes/uiRender.js +92 -0
- package/dist/cjs/src/barcodes/uiRender.js.map +1 -0
- package/dist/cjs/src/image/constants.js +3 -0
- package/dist/cjs/src/image/constants.js.map +1 -0
- package/dist/cjs/src/image/helper.js +3 -0
- package/dist/cjs/src/image/helper.js.map +1 -0
- package/dist/cjs/src/image/index.js +8 -0
- package/dist/cjs/src/image/index.js.map +1 -0
- package/dist/cjs/src/image/pdfRender.js +34 -0
- package/dist/cjs/src/image/pdfRender.js.map +1 -0
- package/dist/cjs/src/image/propPanel.js +9 -0
- package/dist/cjs/src/image/propPanel.js.map +1 -0
- package/dist/cjs/src/image/types.js +3 -0
- package/dist/cjs/src/image/types.js.map +1 -0
- package/dist/cjs/src/image/uiRender.js +108 -0
- package/dist/cjs/src/image/uiRender.js.map +1 -0
- package/dist/cjs/src/index.js +13 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/cjs/src/renderUtils.js +65 -0
- package/dist/cjs/src/renderUtils.js.map +1 -0
- package/dist/cjs/src/text/constants.js +22 -0
- package/dist/cjs/src/text/constants.js.map +1 -0
- package/dist/cjs/src/text/helper.js +270 -0
- package/dist/cjs/src/text/helper.js.map +1 -0
- package/dist/cjs/src/text/index.js +8 -0
- package/dist/cjs/src/text/index.js.map +1 -0
- package/dist/cjs/src/text/pdfRender.js +111 -0
- package/dist/cjs/src/text/pdfRender.js.map +1 -0
- package/dist/cjs/src/text/propPanel.js +122 -0
- package/dist/cjs/src/text/propPanel.js.map +1 -0
- package/dist/cjs/src/text/types.js +3 -0
- package/dist/cjs/src/text/types.js.map +1 -0
- package/dist/cjs/src/text/uiRender.js +118 -0
- package/dist/cjs/src/text/uiRender.js.map +1 -0
- package/dist/esm/__tests__/barcode.test.js +336 -0
- package/dist/esm/__tests__/barcode.test.js.map +1 -0
- package/dist/esm/__tests__/text.test.js +293 -0
- package/dist/esm/__tests__/text.test.js.map +1 -0
- package/dist/esm/src/barcodes/constants.js +16 -0
- package/dist/esm/src/barcodes/constants.js.map +1 -0
- package/dist/esm/src/barcodes/helper.js +137 -0
- package/dist/esm/src/barcodes/helper.js.map +1 -0
- package/dist/esm/src/barcodes/index.js +9 -0
- package/dist/esm/src/barcodes/index.js.map +1 -0
- package/dist/esm/src/barcodes/pdfRender.js +33 -0
- package/dist/esm/src/barcodes/pdfRender.js.map +1 -0
- package/dist/esm/src/barcodes/propPanel.js +65 -0
- package/dist/esm/src/barcodes/propPanel.js.map +1 -0
- package/dist/esm/src/barcodes/types.js +2 -0
- package/dist/esm/src/barcodes/types.js.map +1 -0
- package/dist/esm/src/barcodes/uiRender.js +88 -0
- package/dist/esm/src/barcodes/uiRender.js.map +1 -0
- package/dist/esm/src/image/constants.js +2 -0
- package/dist/esm/src/image/constants.js.map +1 -0
- package/dist/esm/src/image/helper.js +2 -0
- package/dist/esm/src/image/helper.js.map +1 -0
- package/dist/esm/src/image/index.js +6 -0
- package/dist/esm/src/image/index.js.map +1 -0
- package/dist/esm/src/image/pdfRender.js +30 -0
- package/dist/esm/src/image/pdfRender.js.map +1 -0
- package/dist/esm/src/image/propPanel.js +6 -0
- package/dist/esm/src/image/propPanel.js.map +1 -0
- package/dist/esm/src/image/types.js +2 -0
- package/dist/esm/src/image/types.js.map +1 -0
- package/dist/esm/src/image/uiRender.js +104 -0
- package/dist/esm/src/image/uiRender.js.map +1 -0
- package/dist/esm/src/index.js +7 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/renderUtils.js +56 -0
- package/dist/esm/src/renderUtils.js.map +1 -0
- package/dist/esm/src/text/constants.js +19 -0
- package/dist/esm/src/text/constants.js.map +1 -0
- package/dist/esm/src/text/helper.js +237 -0
- package/dist/esm/src/text/helper.js.map +1 -0
- package/dist/esm/src/text/index.js +6 -0
- package/dist/esm/src/text/index.js.map +1 -0
- package/dist/esm/src/text/pdfRender.js +107 -0
- package/dist/esm/src/text/pdfRender.js.map +1 -0
- package/dist/esm/src/text/propPanel.js +119 -0
- package/dist/esm/src/text/propPanel.js.map +1 -0
- package/dist/esm/src/text/types.js +2 -0
- package/dist/esm/src/text/types.js.map +1 -0
- package/dist/esm/src/text/uiRender.js +114 -0
- package/dist/esm/src/text/uiRender.js.map +1 -0
- package/dist/types/__tests__/barcode.test.d.ts +1 -0
- package/dist/types/__tests__/text.test.d.ts +1 -0
- package/dist/types/src/barcodes/constants.d.ts +3 -0
- package/dist/types/src/barcodes/helper.d.ts +20 -0
- package/dist/types/src/barcodes/index.d.ts +4 -0
- package/dist/types/src/barcodes/pdfRender.d.ts +3 -0
- package/dist/types/src/barcodes/propPanel.d.ts +3 -0
- package/dist/types/src/barcodes/types.d.ts +9 -0
- package/dist/types/src/barcodes/uiRender.d.ts +3 -0
- package/dist/types/src/image/constants.d.ts +1 -0
- package/dist/types/src/image/helper.d.ts +1 -0
- package/dist/types/src/image/index.d.ts +4 -0
- package/dist/types/src/image/pdfRender.d.ts +3 -0
- package/dist/types/src/image/propPanel.d.ts +3 -0
- package/dist/types/src/image/types.d.ts +3 -0
- package/dist/types/src/image/uiRender.d.ts +3 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/renderUtils.d.ts +16 -0
- package/dist/types/src/text/constants.d.ts +19 -0
- package/dist/types/src/text/helper.d.ts +29 -0
- package/dist/types/src/text/index.d.ts +4 -0
- package/dist/types/src/text/pdfRender.d.ts +3 -0
- package/dist/types/src/text/propPanel.d.ts +3 -0
- package/dist/types/src/text/types.d.ts +26 -0
- package/dist/types/src/text/uiRender.d.ts +3 -0
- package/package.json +86 -0
- package/src/barcodes/constants.ts +17 -0
- package/src/barcodes/helper.ts +161 -0
- package/src/barcodes/index.ts +16 -0
- package/src/barcodes/pdfRender.ts +29 -0
- package/src/barcodes/propPanel.ts +133 -0
- package/src/barcodes/types.ts +11 -0
- package/src/barcodes/uiRender.ts +116 -0
- package/src/image/constants.ts +1 -0
- package/src/image/helper.ts +1 -0
- package/src/image/index.ts +8 -0
- package/src/image/pdfRender.ts +24 -0
- package/src/image/propPanel.ts +8 -0
- package/src/image/types.ts +3 -0
- package/src/image/uiRender.ts +118 -0
- package/src/index.ts +7 -0
- package/src/renderUtils.ts +74 -0
- package/src/text/constants.ts +22 -0
- package/src/text/helper.ts +317 -0
- package/src/text/index.ts +9 -0
- package/src/text/pdfRender.ts +155 -0
- package/src/text/propPanel.ts +148 -0
- package/src/text/types.ts +29 -0
- package/src/text/uiRender.ts +153 -0
- package/tsconfig.cjs.json +10 -0
- package/tsconfig.esm.json +10 -0
- package/tsconfig.json +6 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
+
});
|
33
|
+
};
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
+
exports.calculateDynamicFontSize = exports.getSplittedLines = exports.getFontKitFont = exports.widthOfTextAtSize = exports.heightOfFontAtSize = exports.getFontDescentInPt = exports.getBrowserVerticalFontAdjustments = void 0;
|
36
|
+
const fontkit = __importStar(require("fontkit"));
|
37
|
+
const common_1 = require("@pdfme/common");
|
38
|
+
const buffer_1 = require("buffer");
|
39
|
+
const constants_1 = require("./constants");
|
40
|
+
const getBrowserVerticalFontAdjustments = (fontKitFont, fontSize, lineHeight, verticalAlignment) => {
|
41
|
+
const { ascent, descent, unitsPerEm } = fontKitFont;
|
42
|
+
// Fonts have a designed line height that the browser renders when using `line-height: normal`
|
43
|
+
const fontBaseLineHeight = (ascent - descent) / unitsPerEm;
|
44
|
+
// For vertical alignment top
|
45
|
+
// To achieve consistent positioning between browser and PDF, we apply the difference between
|
46
|
+
// the font's actual height and the font size in pixels.
|
47
|
+
// Browsers middle the font within this height, so we only need half of it to apply to the top.
|
48
|
+
// This means the font renders a bit lower in the browser, but achieves PDF alignment
|
49
|
+
const topAdjustment = (fontBaseLineHeight * fontSize - fontSize) / 2;
|
50
|
+
if (verticalAlignment === constants_1.VERTICAL_ALIGN_TOP) {
|
51
|
+
return { topAdj: (0, common_1.pt2px)(topAdjustment), bottomAdj: 0 };
|
52
|
+
}
|
53
|
+
// For vertical alignment bottom and middle
|
54
|
+
// When browsers render text in a non-form element (such as a <div>), some of the text may be
|
55
|
+
// lowered below and outside the containing element if the line height used is less than
|
56
|
+
// the base line-height of the font.
|
57
|
+
// This behaviour does not happen in a <textarea> though, so we need to adjust the positioning
|
58
|
+
// for consistency between editing and viewing to stop text jumping up and down.
|
59
|
+
// This portion of text is half of the difference between the base line height and the used
|
60
|
+
// line height. If using the same or higher line-height than the base font, then line-height
|
61
|
+
// takes over in the browser and this adjustment is not needed.
|
62
|
+
// Unlike the top adjustment - this is only driven by browser behaviour, not PDF alignment.
|
63
|
+
let bottomAdjustment = 0;
|
64
|
+
if (lineHeight < fontBaseLineHeight) {
|
65
|
+
bottomAdjustment = ((fontBaseLineHeight - lineHeight) * fontSize) / 2;
|
66
|
+
}
|
67
|
+
return { topAdj: 0, bottomAdj: (0, common_1.pt2px)(bottomAdjustment) };
|
68
|
+
};
|
69
|
+
exports.getBrowserVerticalFontAdjustments = getBrowserVerticalFontAdjustments;
|
70
|
+
const getFontDescentInPt = (fontKitFont, fontSize) => {
|
71
|
+
const { descent, unitsPerEm } = fontKitFont;
|
72
|
+
return (descent / unitsPerEm) * fontSize;
|
73
|
+
};
|
74
|
+
exports.getFontDescentInPt = getFontDescentInPt;
|
75
|
+
const heightOfFontAtSize = (fontKitFont, fontSize) => {
|
76
|
+
const { ascent, descent, bbox, unitsPerEm } = fontKitFont;
|
77
|
+
const scale = 1000 / unitsPerEm;
|
78
|
+
const yTop = (ascent || bbox.maxY) * scale;
|
79
|
+
const yBottom = (descent || bbox.minY) * scale;
|
80
|
+
let height = yTop - yBottom;
|
81
|
+
height -= Math.abs(descent * scale) || 0;
|
82
|
+
return (height / 1000) * fontSize;
|
83
|
+
};
|
84
|
+
exports.heightOfFontAtSize = heightOfFontAtSize;
|
85
|
+
const calculateCharacterSpacing = (textContent, textCharacterSpacing) => {
|
86
|
+
return (textContent.length - 1) * textCharacterSpacing;
|
87
|
+
};
|
88
|
+
const widthOfTextAtSize = (text, fontKitFont, fontSize, characterSpacing) => {
|
89
|
+
const { glyphs } = fontKitFont.layout(text);
|
90
|
+
const scale = 1000 / fontKitFont.unitsPerEm;
|
91
|
+
const standardWidth = glyphs.reduce((totalWidth, glyph) => totalWidth + glyph.advanceWidth * scale, 0) *
|
92
|
+
(fontSize / 1000);
|
93
|
+
return standardWidth + calculateCharacterSpacing(text, characterSpacing);
|
94
|
+
};
|
95
|
+
exports.widthOfTextAtSize = widthOfTextAtSize;
|
96
|
+
const getFallbackFont = (font) => {
|
97
|
+
const fallbackFontName = (0, common_1.getFallbackFontName)(font);
|
98
|
+
return font[fallbackFontName];
|
99
|
+
};
|
100
|
+
const fontKitFontCache = {};
|
101
|
+
const getFontKitFont = (textSchema, font) => __awaiter(void 0, void 0, void 0, function* () {
|
102
|
+
const fontName = textSchema.fontName || (0, common_1.getFallbackFontName)(font);
|
103
|
+
if (fontKitFontCache[fontName]) {
|
104
|
+
return fontKitFontCache[fontName];
|
105
|
+
}
|
106
|
+
const currentFont = font[fontName] || getFallbackFont(font) || (0, common_1.getDefaultFont)()[common_1.DEFAULT_FONT_NAME];
|
107
|
+
let fontData = currentFont.data;
|
108
|
+
if (typeof fontData === 'string') {
|
109
|
+
fontData = fontData.startsWith('http')
|
110
|
+
? yield fetch(fontData).then((res) => res.arrayBuffer())
|
111
|
+
: (0, common_1.b64toUint8Array)(fontData);
|
112
|
+
}
|
113
|
+
const fontKitFont = fontkit.create(fontData instanceof buffer_1.Buffer ? fontData : buffer_1.Buffer.from(fontData));
|
114
|
+
fontKitFontCache[fontName] = fontKitFont;
|
115
|
+
return fontKitFont;
|
116
|
+
});
|
117
|
+
exports.getFontKitFont = getFontKitFont;
|
118
|
+
const isTextExceedingBoxWidth = (text, calcValues) => {
|
119
|
+
const { font, fontSize, characterSpacing, boxWidthInPt } = calcValues;
|
120
|
+
const textWidth = (0, exports.widthOfTextAtSize)(text, font, fontSize, characterSpacing);
|
121
|
+
return textWidth > boxWidthInPt;
|
122
|
+
};
|
123
|
+
/**
|
124
|
+
* Incrementally checks the current line for its real length
|
125
|
+
* and returns the position where it exceeds the box width.
|
126
|
+
* Returns `null` to indicate if textLine is shorter than the available box.
|
127
|
+
*/
|
128
|
+
const getOverPosition = (textLine, calcValues) => {
|
129
|
+
for (let i = 0; i <= textLine.length; i++) {
|
130
|
+
if (isTextExceedingBoxWidth(textLine.slice(0, i + 1), calcValues)) {
|
131
|
+
return i;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
return null;
|
135
|
+
};
|
136
|
+
/**
|
137
|
+
* Gets the position of the split. Splits the exceeding line at
|
138
|
+
* the last whitespace prior to it exceeding the bounding box width.
|
139
|
+
*/
|
140
|
+
const getSplitPosition = (textLine, calcValues) => {
|
141
|
+
const overPos = getOverPosition(textLine, calcValues);
|
142
|
+
if (overPos === null)
|
143
|
+
return textLine.length; // input line is shorter than the available space
|
144
|
+
let overPosTmp = overPos;
|
145
|
+
while (textLine[overPosTmp] !== ' ' && overPosTmp >= 0) {
|
146
|
+
overPosTmp--;
|
147
|
+
}
|
148
|
+
// For very long lines with no whitespace use the original overPos
|
149
|
+
return overPosTmp > 0 ? overPosTmp : overPos;
|
150
|
+
};
|
151
|
+
/**
|
152
|
+
* Recursively splits the line at getSplitPosition.
|
153
|
+
* If there is some leftover, split the rest again in the same manner.
|
154
|
+
*/
|
155
|
+
const getSplittedLines = (textLine, calcValues) => {
|
156
|
+
const splitPos = getSplitPosition(textLine, calcValues);
|
157
|
+
const splittedLine = textLine.substring(0, splitPos);
|
158
|
+
const rest = textLine.substring(splitPos).trimStart();
|
159
|
+
if (rest === textLine) {
|
160
|
+
// if we went so small that we want to split on the first char
|
161
|
+
// then end recursion to avoid infinite loop
|
162
|
+
return [textLine];
|
163
|
+
}
|
164
|
+
if (rest.length === 0) {
|
165
|
+
// end recursion if there is no leftover
|
166
|
+
return [splittedLine];
|
167
|
+
}
|
168
|
+
return [splittedLine, ...(0, exports.getSplittedLines)(rest, calcValues)];
|
169
|
+
};
|
170
|
+
exports.getSplittedLines = getSplittedLines;
|
171
|
+
/**
|
172
|
+
* If using dynamic font size, iteratively increment or decrement the
|
173
|
+
* font size to fit the containing box.
|
174
|
+
* Calculating space usage involves splitting lines where they exceed
|
175
|
+
* the box width based on the proposed size.
|
176
|
+
*/
|
177
|
+
const calculateDynamicFontSize = ({ textSchema, font, value, startingFontSize, }) => __awaiter(void 0, void 0, void 0, function* () {
|
178
|
+
var _a;
|
179
|
+
const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, width: boxWidth, height: boxHeight, lineHeight = constants_1.DEFAULT_LINE_HEIGHT, } = textSchema;
|
180
|
+
const fontSize = startingFontSize || schemaFontSize || constants_1.DEFAULT_FONT_SIZE;
|
181
|
+
if (!dynamicFontSizeSetting)
|
182
|
+
return fontSize;
|
183
|
+
if (dynamicFontSizeSetting.max < dynamicFontSizeSetting.min)
|
184
|
+
return fontSize;
|
185
|
+
const characterSpacing = schemaCharacterSpacing !== null && schemaCharacterSpacing !== void 0 ? schemaCharacterSpacing : constants_1.DEFAULT_CHARACTER_SPACING;
|
186
|
+
const fontKitFont = yield (0, exports.getFontKitFont)(textSchema, font);
|
187
|
+
const paragraphs = value.split('\n');
|
188
|
+
let dynamicFontSize = fontSize;
|
189
|
+
if (dynamicFontSize < dynamicFontSizeSetting.min) {
|
190
|
+
dynamicFontSize = dynamicFontSizeSetting.min;
|
191
|
+
}
|
192
|
+
else if (dynamicFontSize > dynamicFontSizeSetting.max) {
|
193
|
+
dynamicFontSize = dynamicFontSizeSetting.max;
|
194
|
+
}
|
195
|
+
const dynamicFontFit = (_a = dynamicFontSizeSetting.fit) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_DYNAMIC_FIT;
|
196
|
+
const calculateConstraints = (size) => {
|
197
|
+
let totalWidthInMm = 0;
|
198
|
+
let totalHeightInMm = 0;
|
199
|
+
const boxWidthInPt = (0, common_1.mm2pt)(boxWidth);
|
200
|
+
const firstLineTextHeight = (0, exports.heightOfFontAtSize)(fontKitFont, size);
|
201
|
+
const firstLineHeightInMm = (0, common_1.pt2mm)(firstLineTextHeight * lineHeight);
|
202
|
+
const otherRowHeightInMm = (0, common_1.pt2mm)(size * lineHeight);
|
203
|
+
paragraphs.forEach((paragraph, paraIndex) => {
|
204
|
+
const lines = (0, exports.getSplittedLines)(paragraph, {
|
205
|
+
font: fontKitFont,
|
206
|
+
fontSize: size,
|
207
|
+
characterSpacing,
|
208
|
+
boxWidthInPt,
|
209
|
+
});
|
210
|
+
lines.forEach((line, lineIndex) => {
|
211
|
+
if (dynamicFontFit === constants_1.DYNAMIC_FIT_VERTICAL) {
|
212
|
+
// For vertical fit we want to consider the width of text lines where we detect a split
|
213
|
+
const textWidth = (0, exports.widthOfTextAtSize)(line, fontKitFont, size, characterSpacing);
|
214
|
+
const textWidthInMm = (0, common_1.pt2mm)(textWidth);
|
215
|
+
totalWidthInMm = Math.max(totalWidthInMm, textWidthInMm);
|
216
|
+
}
|
217
|
+
if (paraIndex + lineIndex === 0) {
|
218
|
+
totalHeightInMm += firstLineHeightInMm;
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
totalHeightInMm += otherRowHeightInMm;
|
222
|
+
}
|
223
|
+
});
|
224
|
+
if (dynamicFontFit === constants_1.DYNAMIC_FIT_HORIZONTAL) {
|
225
|
+
// For horizontal fit we want to consider the line's width 'unsplit'
|
226
|
+
const textWidth = (0, exports.widthOfTextAtSize)(paragraph, fontKitFont, size, characterSpacing);
|
227
|
+
const textWidthInMm = (0, common_1.pt2mm)(textWidth);
|
228
|
+
totalWidthInMm = Math.max(totalWidthInMm, textWidthInMm);
|
229
|
+
}
|
230
|
+
});
|
231
|
+
return { totalWidthInMm, totalHeightInMm };
|
232
|
+
};
|
233
|
+
const shouldFontGrowToFit = (totalWidthInMm, totalHeightInMm) => {
|
234
|
+
if (dynamicFontSize >= dynamicFontSizeSetting.max) {
|
235
|
+
return false;
|
236
|
+
}
|
237
|
+
if (dynamicFontFit === constants_1.DYNAMIC_FIT_HORIZONTAL) {
|
238
|
+
return totalWidthInMm < boxWidth;
|
239
|
+
}
|
240
|
+
return totalHeightInMm < boxHeight;
|
241
|
+
};
|
242
|
+
const shouldFontShrinkToFit = (totalWidthInMm, totalHeightInMm) => {
|
243
|
+
if (dynamicFontSize <= dynamicFontSizeSetting.min || dynamicFontSize <= 0) {
|
244
|
+
return false;
|
245
|
+
}
|
246
|
+
return totalWidthInMm > boxWidth || totalHeightInMm > boxHeight;
|
247
|
+
};
|
248
|
+
let { totalWidthInMm, totalHeightInMm } = calculateConstraints(dynamicFontSize);
|
249
|
+
// Attempt to increase the font size up to desired fit
|
250
|
+
while (shouldFontGrowToFit(totalWidthInMm, totalHeightInMm)) {
|
251
|
+
dynamicFontSize += constants_1.FONT_SIZE_ADJUSTMENT;
|
252
|
+
const { totalWidthInMm: newWidth, totalHeightInMm: newHeight } = calculateConstraints(dynamicFontSize);
|
253
|
+
if (newHeight < boxHeight) {
|
254
|
+
totalWidthInMm = newWidth;
|
255
|
+
totalHeightInMm = newHeight;
|
256
|
+
}
|
257
|
+
else {
|
258
|
+
dynamicFontSize -= constants_1.FONT_SIZE_ADJUSTMENT;
|
259
|
+
break;
|
260
|
+
}
|
261
|
+
}
|
262
|
+
// Attempt to decrease the font size down to desired fit
|
263
|
+
while (shouldFontShrinkToFit(totalWidthInMm, totalHeightInMm)) {
|
264
|
+
dynamicFontSize -= constants_1.FONT_SIZE_ADJUSTMENT;
|
265
|
+
({ totalWidthInMm, totalHeightInMm } = calculateConstraints(dynamicFontSize));
|
266
|
+
}
|
267
|
+
return dynamicFontSize;
|
268
|
+
});
|
269
|
+
exports.calculateDynamicFontSize = calculateDynamicFontSize;
|
270
|
+
//# sourceMappingURL=helper.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/text/helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,0CAUuB;AACvB,mCAAgC;AAEhC,2CASqB;AAEd,MAAM,iCAAiC,GAAG,CAC/C,WAAwB,EACxB,QAAgB,EAChB,UAAkB,EAClB,iBAAyB,EACzB,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAEpD,8FAA8F;IAC9F,MAAM,kBAAkB,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,UAAU,CAAC;IAE3D,6BAA6B;IAC7B,6FAA6F;IAC7F,wDAAwD;IACxD,+FAA+F;IAC/F,qFAAqF;IACrF,MAAM,aAAa,GAAG,CAAC,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAErE,IAAI,iBAAiB,KAAK,8BAAkB,EAAE;QAC5C,OAAO,EAAE,MAAM,EAAE,IAAA,cAAK,EAAC,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;KACvD;IAED,2CAA2C;IAC3C,6FAA6F;IAC7F,wFAAwF;IACxF,oCAAoC;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;SACP;KACF;IAED,wDAAwD;IACxD,OAAO,qBAAqB,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE;QAC7D,eAAe,IAAI,gCAAoB,CAAC;QACxC,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC;KAC/E;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,CAAA,CAAC;AArHW,QAAA,wBAAwB,4BAqHnC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const pdfRender_1 = require("./pdfRender");
|
4
|
+
const propPanel_1 = require("./propPanel");
|
5
|
+
const uiRender_1 = require("./uiRender");
|
6
|
+
const schema = { pdf: pdfRender_1.pdfRender, ui: uiRender_1.uiRender, propPanel: propPanel_1.propPanel };
|
7
|
+
exports.default = schema;
|
8
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/text/index.ts"],"names":[],"mappings":";;AACA,2CAAwC;AACxC,2CAAwC;AACxC,yCAAsC;AAGtC,MAAM,MAAM,GAAuB,EAAE,GAAG,EAAE,qBAAS,EAAE,EAAE,EAAE,mBAAQ,EAAE,SAAS,EAAT,qBAAS,EAAE,CAAC;AAE/E,kBAAe,MAAM,CAAC"}
|
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.pdfRender = void 0;
|
13
|
+
const common_1 = require("@pdfme/common");
|
14
|
+
const constants_1 = require("./constants");
|
15
|
+
const helper_1 = require("./helper");
|
16
|
+
const renderUtils_1 = require("../renderUtils");
|
17
|
+
const embedAndGetFontObjCache = new WeakMap();
|
18
|
+
const embedAndGetFontObj = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
const { pdfDoc, font } = arg;
|
20
|
+
if (embedAndGetFontObjCache.has(pdfDoc)) {
|
21
|
+
return embedAndGetFontObjCache.get(pdfDoc);
|
22
|
+
}
|
23
|
+
const fontValues = yield Promise.all(Object.values(font).map((v) => __awaiter(void 0, void 0, void 0, function* () {
|
24
|
+
let fontData = v.data;
|
25
|
+
if (typeof fontData === 'string' && fontData.startsWith('http')) {
|
26
|
+
fontData = yield fetch(fontData).then((res) => res.arrayBuffer());
|
27
|
+
}
|
28
|
+
return pdfDoc.embedFont(fontData, {
|
29
|
+
subset: typeof v.subset === 'undefined' ? true : v.subset,
|
30
|
+
});
|
31
|
+
})));
|
32
|
+
const fontObj = Object.keys(font).reduce((acc, cur, i) => Object.assign(acc, { [cur]: fontValues[i] }), {});
|
33
|
+
embedAndGetFontObjCache.set(pdfDoc, fontObj);
|
34
|
+
return fontObj;
|
35
|
+
});
|
36
|
+
const getFontProp = ({ value, font, schema, }) => __awaiter(void 0, void 0, void 0, function* () {
|
37
|
+
var _a, _b, _c, _d, _e;
|
38
|
+
const fontSize = schema.dynamicFontSize
|
39
|
+
? yield (0, helper_1.calculateDynamicFontSize)({ textSchema: schema, font, value })
|
40
|
+
: (_a = schema.fontSize) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_FONT_SIZE;
|
41
|
+
const color = (0, renderUtils_1.hex2RgbColor)(schema.fontColor || constants_1.DEFAULT_FONT_COLOR);
|
42
|
+
return {
|
43
|
+
alignment: (_b = schema.alignment) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_ALIGNMENT,
|
44
|
+
verticalAlignment: (_c = schema.verticalAlignment) !== null && _c !== void 0 ? _c : constants_1.DEFAULT_VERTICAL_ALIGNMENT,
|
45
|
+
lineHeight: (_d = schema.lineHeight) !== null && _d !== void 0 ? _d : constants_1.DEFAULT_LINE_HEIGHT,
|
46
|
+
characterSpacing: (_e = schema.characterSpacing) !== null && _e !== void 0 ? _e : constants_1.DEFAULT_CHARACTER_SPACING,
|
47
|
+
fontSize,
|
48
|
+
color,
|
49
|
+
};
|
50
|
+
});
|
51
|
+
const pdfRender = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
52
|
+
const { value, pdfDoc, pdfLib, page, options, schema } = arg;
|
53
|
+
const { font = (0, common_1.getDefaultFont)() } = options;
|
54
|
+
const [pdfFontObj, fontKitFont, fontProp] = yield Promise.all([
|
55
|
+
embedAndGetFontObj({ pdfDoc, font }),
|
56
|
+
(0, helper_1.getFontKitFont)(schema, font),
|
57
|
+
getFontProp({ value, font, schema }),
|
58
|
+
]);
|
59
|
+
const { fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing } = fontProp;
|
60
|
+
const fontName = (schema.fontName ? schema.fontName : (0, common_1.getFallbackFontName)(font));
|
61
|
+
const pdfFontValue = pdfFontObj[fontName];
|
62
|
+
const pageHeight = page.getHeight();
|
63
|
+
(0, renderUtils_1.renderBackgroundColor)({ schema, page, pageHeight });
|
64
|
+
const { width, height, rotate } = (0, renderUtils_1.convertSchemaDimensionsToPt)(schema);
|
65
|
+
page.pushOperators(pdfLib.setCharacterSpacing(characterSpacing !== null && characterSpacing !== void 0 ? characterSpacing : constants_1.DEFAULT_CHARACTER_SPACING));
|
66
|
+
const firstLineTextHeight = (0, helper_1.heightOfFontAtSize)(fontKitFont, fontSize);
|
67
|
+
const descent = (0, helper_1.getFontDescentInPt)(fontKitFont, fontSize);
|
68
|
+
const halfLineHeightAdjustment = lineHeight === 0 ? 0 : ((lineHeight - 1) * fontSize) / 2;
|
69
|
+
const fontWidthCalcValues = {
|
70
|
+
font: fontKitFont,
|
71
|
+
fontSize,
|
72
|
+
characterSpacing,
|
73
|
+
boxWidthInPt: width,
|
74
|
+
};
|
75
|
+
let lines = [];
|
76
|
+
value.split(/\r|\n|\r\n/g).forEach((line) => {
|
77
|
+
lines = lines.concat((0, helper_1.getSplittedLines)(line, fontWidthCalcValues));
|
78
|
+
});
|
79
|
+
// Text lines are rendered from the bottom upwards, we need to adjust the position down
|
80
|
+
let yOffset = 0;
|
81
|
+
if (verticalAlignment === constants_1.VERTICAL_ALIGN_TOP) {
|
82
|
+
yOffset = firstLineTextHeight + halfLineHeightAdjustment;
|
83
|
+
}
|
84
|
+
else {
|
85
|
+
const otherLinesHeight = lineHeight * fontSize * (lines.length - 1);
|
86
|
+
if (verticalAlignment === constants_1.VERTICAL_ALIGN_BOTTOM) {
|
87
|
+
yOffset = height - otherLinesHeight + descent - halfLineHeightAdjustment;
|
88
|
+
}
|
89
|
+
else if (verticalAlignment === constants_1.VERTICAL_ALIGN_MIDDLE) {
|
90
|
+
yOffset =
|
91
|
+
(height - otherLinesHeight - firstLineTextHeight + descent) / 2 + firstLineTextHeight;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
lines.forEach((line, rowIndex) => {
|
95
|
+
const textWidth = (0, helper_1.widthOfTextAtSize)(line, fontKitFont, fontSize, characterSpacing);
|
96
|
+
const rowYOffset = lineHeight * fontSize * rowIndex;
|
97
|
+
page.drawText(line, {
|
98
|
+
x: (0, renderUtils_1.calcX)(schema.position.x, alignment, width, textWidth),
|
99
|
+
y: (0, renderUtils_1.calcY)(schema.position.y, pageHeight, yOffset) - rowYOffset,
|
100
|
+
rotate,
|
101
|
+
size: fontSize,
|
102
|
+
color,
|
103
|
+
lineHeight: lineHeight * fontSize,
|
104
|
+
maxWidth: width,
|
105
|
+
font: pdfFontValue,
|
106
|
+
wordBreaks: [''],
|
107
|
+
});
|
108
|
+
});
|
109
|
+
});
|
110
|
+
exports.pdfRender = pdfRender;
|
111
|
+
//# sourceMappingURL=pdfRender.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pdfRender.js","sourceRoot":"","sources":["../../../../src/text/pdfRender.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0CAA0F;AAE1F,2CAUqB;AACrB,qCAOkB;AAClB,gDAMwB;AAExB,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9C,MAAM,kBAAkB,GAAG,CAAO,GAAwC,EAAE,EAAE;IAC5E,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;IAC7B,IAAI,uBAAuB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QACvC,OAAO,uBAAuB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KAC5C;IAED,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,GAAG,CAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAO,CAAC,EAAE,EAAE;QAClC,IAAI,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC;QACtB,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YAC/D,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SACnE;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAChC,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;SAC1D,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CACH,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,I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,CAAC,IAAI,EAAE;YAClB,CAAC,EAAE,IAAA,mBAAK,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC;YACxD,CAAC,EAAE,IAAA,mBAAK,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,GAAG,UAAU;YAC7D,MAAM;YACN,IAAI,EAAE,QAAQ;YACd,KAAK;YACL,UAAU,EAAE,UAAU,GAAG,QAAQ;YACjC,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,CAAC,EAAE,CAAC;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAxEW,QAAA,SAAS,aAwEpB"}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.propPanel = void 0;
|
4
|
+
const common_1 = require("@pdfme/common");
|
5
|
+
const constants_1 = require("./constants");
|
6
|
+
const UseDynamicFontSize = (props) => {
|
7
|
+
const { rootElement, changeSchemas, activeSchema } = props;
|
8
|
+
const checkbox = document.createElement('input');
|
9
|
+
checkbox.type = 'checkbox';
|
10
|
+
checkbox.checked = Boolean(activeSchema === null || activeSchema === void 0 ? void 0 : activeSchema.dynamicFontSize);
|
11
|
+
checkbox.onchange = (e) => {
|
12
|
+
const val = e.target.checked
|
13
|
+
? {
|
14
|
+
min: constants_1.DEFAULT_DYNAMIC_MIN_FONT_SIZE,
|
15
|
+
max: constants_1.DEFAULT_DYNAMIC_MAX_FONT_SIZE,
|
16
|
+
fit: constants_1.DEFAULT_DYNAMIC_FIT,
|
17
|
+
}
|
18
|
+
: undefined;
|
19
|
+
changeSchemas([{ key: 'dynamicFontSize', value: val, schemaId: activeSchema.id }]);
|
20
|
+
};
|
21
|
+
const label = document.createElement('label');
|
22
|
+
label.innerText = 'Dynamic Font Size';
|
23
|
+
label.style.cssText = 'display: flex; width: 100%;';
|
24
|
+
label.appendChild(checkbox);
|
25
|
+
rootElement.appendChild(label);
|
26
|
+
};
|
27
|
+
exports.propPanel = {
|
28
|
+
propPanelSchema: ({ options, activeSchema }) => {
|
29
|
+
const font = options.font || { [common_1.DEFAULT_FONT_NAME]: { data: '', fallback: true } };
|
30
|
+
const fontNames = Object.keys(font);
|
31
|
+
const fallbackFontName = (0, common_1.getFallbackFontName)(font);
|
32
|
+
const enableDynamicFont = Boolean(activeSchema === null || activeSchema === void 0 ? void 0 : activeSchema.dynamicFontSize);
|
33
|
+
const textSchema = {
|
34
|
+
fontName: {
|
35
|
+
title: 'Font Name',
|
36
|
+
type: 'string',
|
37
|
+
widget: 'select',
|
38
|
+
default: fallbackFontName,
|
39
|
+
props: { options: fontNames.map((name) => ({ label: name, value: name })) },
|
40
|
+
span: 8,
|
41
|
+
},
|
42
|
+
alignment: {
|
43
|
+
title: 'Text Align',
|
44
|
+
type: 'string',
|
45
|
+
widget: 'select',
|
46
|
+
props: {
|
47
|
+
options: [
|
48
|
+
{ label: 'Left', value: constants_1.DEFAULT_ALIGNMENT },
|
49
|
+
{ label: 'Center', value: constants_1.ALIGN_CENTER },
|
50
|
+
{ label: 'Right', value: constants_1.ALIGN_RIGHT },
|
51
|
+
],
|
52
|
+
},
|
53
|
+
span: 8,
|
54
|
+
},
|
55
|
+
verticalAlignment: {
|
56
|
+
title: 'Vertical Align',
|
57
|
+
type: 'string',
|
58
|
+
widget: 'select',
|
59
|
+
props: {
|
60
|
+
options: [
|
61
|
+
{ label: 'Top', value: constants_1.VERTICAL_ALIGN_TOP },
|
62
|
+
{ label: 'Middle', value: constants_1.VERTICAL_ALIGN_MIDDLE },
|
63
|
+
{ label: 'Bottom', value: constants_1.VERTICAL_ALIGN_BOTTOM },
|
64
|
+
],
|
65
|
+
},
|
66
|
+
span: 8,
|
67
|
+
},
|
68
|
+
fontSize: {
|
69
|
+
title: 'Font Size',
|
70
|
+
type: 'number',
|
71
|
+
widget: 'inputNumber',
|
72
|
+
span: 8,
|
73
|
+
disabled: enableDynamicFont,
|
74
|
+
},
|
75
|
+
lineHeight: { title: 'Line Height', type: 'number', widget: 'inputNumber', span: 8 },
|
76
|
+
characterSpacing: { title: 'Char Spc', type: 'number', widget: 'inputNumber', span: 8 },
|
77
|
+
useDynamicFontSize: { type: 'boolean', widget: 'UseDynamicFontSize', bind: false },
|
78
|
+
dynamicFontSize: {
|
79
|
+
type: 'object',
|
80
|
+
widget: 'card',
|
81
|
+
column: 3,
|
82
|
+
properties: {
|
83
|
+
min: { title: 'Min', type: 'number', widget: 'inputNumber', hidden: !enableDynamicFont },
|
84
|
+
max: { title: 'Max', type: 'number', widget: 'inputNumber', hidden: !enableDynamicFont },
|
85
|
+
fit: {
|
86
|
+
title: 'Fit',
|
87
|
+
type: 'string',
|
88
|
+
widget: 'select',
|
89
|
+
hidden: !enableDynamicFont,
|
90
|
+
props: {
|
91
|
+
options: [
|
92
|
+
{ label: 'Horizontal', value: constants_1.DYNAMIC_FIT_HORIZONTAL },
|
93
|
+
{ label: 'Vertical', value: constants_1.DYNAMIC_FIT_VERTICAL },
|
94
|
+
],
|
95
|
+
},
|
96
|
+
},
|
97
|
+
},
|
98
|
+
},
|
99
|
+
fontColor: { title: 'Font Color', type: 'string', widget: 'color' },
|
100
|
+
backgroundColor: { title: 'Background', type: 'string', widget: 'color' },
|
101
|
+
};
|
102
|
+
return textSchema;
|
103
|
+
},
|
104
|
+
widgets: { UseDynamicFontSize },
|
105
|
+
defaultValue: 'Type Something...',
|
106
|
+
defaultSchema: {
|
107
|
+
type: 'text',
|
108
|
+
position: { x: 0, y: 0 },
|
109
|
+
width: 45,
|
110
|
+
height: 10,
|
111
|
+
alignment: constants_1.DEFAULT_ALIGNMENT,
|
112
|
+
verticalAlignment: constants_1.DEFAULT_VERTICAL_ALIGNMENT,
|
113
|
+
fontSize: constants_1.DEFAULT_FONT_SIZE,
|
114
|
+
lineHeight: constants_1.DEFAULT_LINE_HEIGHT,
|
115
|
+
characterSpacing: constants_1.DEFAULT_CHARACTER_SPACING,
|
116
|
+
dynamicFontSize: undefined,
|
117
|
+
fontColor: constants_1.DEFAULT_FONT_COLOR,
|
118
|
+
fontName: undefined,
|
119
|
+
backgroundColor: '',
|
120
|
+
},
|
121
|
+
};
|
122
|
+
//# sourceMappingURL=propPanel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"propPanel.js","sourceRoot":"","sources":["../../../../src/text/propPanel.ts"],"names":[],"mappings":";;;AAAA,0CAMuB;AAEvB,2CAiBqB;AAErB,MAAM,kBAAkB,GAAG,CAAC,KAA2B,EAAE,EAAE;IACzD,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAE3D,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACjD,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAE,YAAoB,aAApB,YAAY,uBAAZ,YAAY,CAAU,eAAe,CAAC,CAAC;IACnE,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAM,EAAE,EAAE;QAC7B,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO;YAC1B,CAAC,CAAC;gBACE,GAAG,EAAE,yCAA6B;gBAClC,GAAG,EAAE,yCAA6B;gBAClC,GAAG,EAAE,+BAAmB;aACzB;YACH,CAAC,CAAC,SAAS,CAAC;QACd,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC;IACF,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,SAAS,GAAG,mBAAmB,CAAC;IACtC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