| 3948 | } |
| 3949 | |
| 3950 | function _drawMultilineText(page, text, rect, font) { |
| 3951 | const lines = String(text).replace(/\r/g, "").split("\n"); |
| 3952 | const fontSize = Math.max( |
| 3953 | 8, |
| 3954 | Math.min(11, rect.height / Math.max(lines.length + 0.5, 2)) |
| 3955 | ); |
| 3956 | const lineHeight = fontSize + 1.5; |
| 3957 | |
| 3958 | let y = rect.y + rect.height - fontSize - 2; |
| 3959 | |
| 3960 | for (const line of lines) { |
| 3961 | if (y < rect.y + 1) break; |
| 3962 | |
| 3963 | page.drawText(line, { |
| 3964 | x: rect.x + 2, |
| 3965 | y, |
| 3966 | size: fontSize, |
| 3967 | font, |
| 3968 | color: rgb(0, 0, 0), |
| 3969 | maxWidth: Math.max(1, rect.width - 4), |
| 3970 | lineHeight |
| 3971 | }); |
| 3972 | |
| 3973 | y -= lineHeight; |
| 3974 | } |
| 3975 | } |
| 3976 | |
| 3977 | function _drawCombText(page, text, rect, font) { |
| 3978 | const chars = String(text).split(""); |