Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-pdf/textkit

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-pdf/textkit - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

23

lib/block/truncate.js

@@ -16,3 +16,20 @@ "use strict";

var ELLIPSIS_UNICODE = 8230;
var ELLIPSIS_STRING = String.fromCharCode(ELLIPSIS_UNICODE);
/**
* Get ellipsis codepoint. This may be different in standard and embedded fonts
*
* @param {number} font
* @return {Object} ellipsis codepoint
*/
var getEllipsisCodePoint = function getEllipsisCodePoint(font) {
if (!font.encode) return ELLIPSIS_UNICODE;
var _font$encode = font.encode(ELLIPSIS_STRING),
codePoints = _font$encode[0];
return parseInt(codePoints[0], 16);
};
/**
* Trucante block with ellipsis

@@ -24,2 +41,4 @@ *

*/
var truncate = function truncate(block) {

@@ -30,3 +49,5 @@ var runs = R.propOr([], 'runs', R.last(block));

if (font) {
return R.adjust(-1, R.compose((0, _append.default)(font.glyphForCodePoint(8230)), _trim.default))(block);
var codePoint = getEllipsisCodePoint(font);
var glyph = font.glyphForCodePoint(codePoint);
return R.adjust(-1, R.compose((0, _append.default)(glyph), _trim.default))(block);
}

@@ -33,0 +54,0 @@

18

lib/layout/finalizeFragments.js

@@ -21,6 +21,4 @@ "use strict";

var ALIGNMENT_FACTORS = {
left: 0,
center: 0.5,
right: 1,
justify: 0
right: 1
};

@@ -67,8 +65,9 @@ /**

return function (line) {
var lineAdvanceWidth = (0, _advanceWidth.default)(line);
var remainingWidth = Math.max(0, line.box.width - lineAdvanceWidth);
var shouldJustify = align === 'justify' || lineAdvanceWidth > line.box.width;
var lineWidth = (0, _advanceWidth.default)(line);
var alignFactor = ALIGNMENT_FACTORS[align] || 0;
var remainingWidth = Math.max(0, line.box.width - lineWidth);
var shouldJustify = align === 'justify' || lineWidth > line.box.width;
return R.compose(R.when(R.always(shouldJustify), engines.justification(options)), R.evolve({
box: R.evolve({
x: R.add(remainingWidth * ALIGNMENT_FACTORS[align])
x: R.add(remainingWidth * alignFactor)
})

@@ -115,3 +114,6 @@ }))(line);

var finalizeFragments = function finalizeFragments(engines, options, blocks) {
return R.map(R.addIndex(R.map)(finalizeBlock(engines, options)), blocks);
var blockFinalizer = finalizeBlock(engines, options);
return blocks.map(function (block) {
return block.map(blockFinalizer);
});
};

@@ -118,0 +120,0 @@

@@ -39,2 +39,3 @@ "use strict";

var paragraphs = [].concat(attributedStrings);
var layoutBlock = (0, _layoutParagraph.default)(engines, options);
var maxLines = R.propOr(Infinity, 'maxLines', container);

@@ -47,3 +48,3 @@ var truncateEllipsis = container.truncateMode === 'ellipsis';

while (linesCount > 0 && nextParagraph) {
var block = (0, _layoutParagraph.default)(engines, options)(paragraphRect, nextParagraph);
var block = layoutBlock(paragraphRect, nextParagraph);
var slicedBlock = (0, _slice.default)(linesCount, block);

@@ -50,0 +51,0 @@ var linesHeight = (0, _height.default)(slicedBlock);

{
"name": "@react-pdf/textkit",
"license": "MIT",
"version": "2.0.5",
"version": "2.0.6",
"description": "An advanced text layout framework",

@@ -25,3 +25,3 @@ "main": "./lib/index.js",

},
"gitHead": "e15b90e39aefde8635663b58ef2e3ffa6494cecd"
"gitHead": "eeb19949e0eb13b25ea790ffe387bc2da6b2f298"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc