void Paragraph::breakLines(le_int32 width, le_int32 height) { fHeight = height; // don't re-break if the width hasn't changed if (fWidth == width) { return; } fWidth = width; float lineWidth = (float) (width - 2 * MARGIN); const ParagraphLayout::Line *line; // Free the old LineInfo's... for (le_int32 li = 0; li < fLineCount; li += 1) { delete fLines[li]; } fLineCount = 0; for (le_int32 p = 0; p < fParagraphCount; p += 1) { ParagraphLayout *paragraphLayout = fParagraphLayout[p]; if (paragraphLayout != NULL) { paragraphLayout->reflow(); while ((line = paragraphLayout->nextLine(lineWidth)) != NULL) { addLine(line); } } else { addLine(NULL); } } }
U_CAPI le_int32 U_EXPORT2 pl_getDescent(const pl_paragraph *paragraph) { ParagraphLayout *pl = (ParagraphLayout *) paragraph; if (pl == NULL) { return 0; } return pl->getDescent(); }
U_CAPI UBiDiDirection U_EXPORT2 pl_getTextDirection(pl_paragraph *paragraph) { ParagraphLayout *pl = (ParagraphLayout *) paragraph; if (pl == NULL) { return UBIDI_LTR; } return pl->getTextDirection(); }
U_CAPI UBiDiLevel U_EXPORT2 pl_getParagraphLevel(pl_paragraph *paragraph) { ParagraphLayout *pl = (ParagraphLayout *) paragraph; if (pl == NULL) { return 0; } return pl->getParagraphLevel(); }
U_CAPI pl_line * U_EXPORT2 pl_nextLine(pl_paragraph *paragraph, float width) { ParagraphLayout *pl = (ParagraphLayout *) paragraph; if (pl == NULL) { return NULL; } return (pl_line *) pl->nextLine(width); }
U_CAPI void U_EXPORT2 pl_reflow(pl_paragraph *paragraph) { ParagraphLayout *pl = (ParagraphLayout *) paragraph; if (pl == NULL) { return; } return pl->reflow(); }
ParagraphLayouter::Line *NextLine(int max_width) { ParagraphLayout::Line *l = p->nextLine(max_width); return l == NULL ? NULL : new ICULine(l); }
void Reflow() { p->reflow(); }
Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns *fontRuns, LEErrorCode &status) : fParagraphLayout(NULL), fParagraphCount(0), fParagraphMax(PARA_GROW), fParagraphGrow(PARA_GROW), fLineCount(0), fLinesMax(LINE_GROW), fLinesGrow(LINE_GROW), fLines(NULL), fChars(NULL), fLineHeight(-1), fAscent(-1), fWidth(-1), fHeight(-1), fParagraphLevel(UBIDI_DEFAULT_LTR) { static const LEUnicode separators[] = {CH_LF, CH_CR, CH_LSEP, CH_PSEP, 0x0000}; if (LE_FAILURE(status)) { return; } le_int32 ascent = 0; le_int32 descent = 0; le_int32 leading = 0; LocaleRuns *locales = NULL; FontRuns fr(0); fLines = LE_NEW_ARRAY(const ParagraphLayout::Line *, fLinesMax); fParagraphLayout = LE_NEW_ARRAY(ParagraphLayout *, fParagraphMax); fChars = LE_NEW_ARRAY(LEUnicode, charCount + 1); LE_ARRAY_COPY(fChars, chars, charCount); fChars[charCount] = 0; LEUnicode *pStart = &fChars[0]; while (*pStart != 0) { LEUnicode *pEnd = u_strpbrk(pStart, separators); le_int32 pAscent, pDescent, pLeading; ParagraphLayout *paragraphLayout = NULL; if (pEnd == NULL) { pEnd = &fChars[charCount]; } if (pEnd != pStart) { subsetFontRuns(fontRuns, pStart - fChars, pEnd - fChars, &fr); paragraphLayout = new ParagraphLayout(pStart, pEnd - pStart, &fr, NULL, NULL, locales, fParagraphLevel, FALSE, status); if (LE_FAILURE(status)) { delete paragraphLayout; break; // return? something else? } if (fParagraphLevel == UBIDI_DEFAULT_LTR) { fParagraphLevel = paragraphLayout->getParagraphLevel(); } pAscent = paragraphLayout->getAscent(); pDescent = paragraphLayout->getDescent(); pLeading = paragraphLayout->getLeading(); if (pAscent > ascent) { ascent = pAscent; } if (pDescent > descent) { descent = pDescent; } if (pLeading > leading) { leading = pLeading; } } if (fParagraphCount >= fParagraphMax) { fParagraphLayout = (ParagraphLayout **) LE_GROW_ARRAY(fParagraphLayout, fParagraphMax + fParagraphGrow); fParagraphMax += fParagraphGrow; } fParagraphLayout[fParagraphCount++] = paragraphLayout; if (*pEnd == 0) { break; } pStart = skipLineEnd(pEnd); } fLineHeight = ascent + descent + leading; fAscent = ascent; }