### Question:
Paragraph extends Div { @Override public Rectangle doPrepare(Double widthLimit) { this.lines.clear(); Double width = this.getWidth(); if (widthLimit == null) { throw new NullPointerException("widthLimit为空"); } widthLimit -= widthPlus(); if (width == null || (width > widthLimit)) { width = widthLimit; } setWidth(width); TxtLineBlock line = newLine(); LinkedList<Span> seq = new LinkedList<>(contents); processPlaceholder(seq); seq = spanLinebreakSplit(seq); while (!seq.isEmpty()) { Span s = seq.pop(); double blockWidth = s.blockSize().getWidth(); if (blockWidth > width && s.isIntegrity()) { continue; } boolean added = line.tryAdd(s); if (added) { if (s.hasLinebreak()) { lines.add(line); line = newLine(); } continue; } if (s.isIntegrity()) { lines.add(line); line = newLine(); seq.push(s); continue; } Span toNextLineSpan = line.trySplitAdd(s); if (toNextLineSpan == null) { seq.push(s); } else { seq.push(toNextLineSpan); } lines.add(line); line = newLine(); } if (!line.isEmpty()) { lines.add(line); } double height = lines.stream() .mapToDouble(TxtLineBlock::getHeight) .sum(); setHeightIfNotExist(height); if (lines.size() == 1) { width = lines.get(0).getWidth(); setWidth(width); } width += widthPlus(); height += heightPlus(); return new Rectangle(width, height); } Paragraph(Double width, Double height);  Paragraph();  Paragraph(String text); Paragraph add(String text); Paragraph add(Span content); Double getLineSpace(); Paragraph setLineSpace(Double lineSpace); Font getDefaultFont(); Paragraph setDefaultFont(Font defaultFont); Double getFontSize(); Paragraph setFontSize(Double defaultFontSize); LinkedList<Span> getContents(); Paragraph setContents(List<Span> contents); LinkedList<TxtLineBlock> getLines(); Integer getFirstLineIndent(); Paragraph setFirstLineIndent(Integer firstLineIndent); Paragraph clearFirstLineIndent(); @Override Rectangle doPrepare(Double widthLimit); @Override Div[] contentSplitAdjust(double sHeight, T div1, T div2); @Override Paragraph clone();  }### Answer:
@Test public void doPrepare() { Paragraph p1 = new Paragraph(); p1.setFontSize(10.0); p1.add("我说你好"); Span span = new Span("你说Hi") .setFontSize(15d); p1.add(span); Rectangle rectangle = p1.doPrepare(400d); System.out.println(rectangle); Assertions.assertEquals(rectangle.getHeight(), 17); Assertions.assertEquals(rectangle.getWidth(), 400); rectangle = p1.doPrepare(55d); System.out.println(rectangle); Assertions.assertEquals(rectangle.getHeight(), (2 + 15) * 2); span.setLetterSpacing(3d); rectangle = p1.doPrepare(56d); System.out.println(rectangle); Assertions.assertEquals(rectangle.getHeight(), 12 + (15 + 2) * 2); int cnt = 0; for (TxtLineBlock line : p1.getLines()) { cnt++; System.out.print(cnt + ": "); line.getInlineSpans().forEach(s-> System.out.print(s.getText())); System.out.println(); } }