Skip to content

Commit

Permalink
fix: page width should great than 0 (#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Feb 24, 2024
1 parent 1a0bbcd commit 281a4b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/src/data/docs/default-document-data-cn.ts
Expand Up @@ -27,7 +27,7 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {
st: 0,
ed: 4,
ts: {
fs: 24,
fs: 20,
ff: 'Microsoft YaHei',
cl: {
rgb: 'rgb(255, 255, 255)',
Expand All @@ -42,7 +42,7 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {
st: 5,
ed: 9,
ts: {
fs: 18,
fs: 16,
ff: 'Microsoft YaHei',
cl: {
rgb: 'rgb(30, 30, 30)',
Expand All @@ -54,7 +54,7 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {
st: 9,
ed: 13,
ts: {
fs: 18,
fs: 16,
ff: 'Microsoft YaHei',
cl: {
rgb: 'rgb(30, 30, 30)',
Expand All @@ -66,7 +66,7 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {
st: 13,
ed: 3057,
ts: {
fs: 14,
fs: 12,
ff: 'Microsoft YaHei',
cl: {
rgb: 'rgb(30, 30, 30)',
Expand Down
Expand Up @@ -271,6 +271,14 @@ function _lineOperator(
if (!columnInfo) return;

const column = columnInfo!.column;

// If the page width < marginLeft + marginRight, will trigger infinity loop, so return it first.
// The best solution is to do data checks and data repairs, and pass the correct data to the render layer.
if (column.width <= 0) {
console.error('The column width is less than 0, need to adjust page width to make it great than 0');
return;
}

const line = getLastLineByColumn(column);

const ascent = Math.max(...spanGroup.map((span) => span.bBox.ba));
Expand Down

0 comments on commit 281a4b9

Please sign in to comment.