Code example for TextPaint

Methods: ascent, descent

0
		return result;
	} 
 
	private int breakWidth(int availableWidth) {
		float titleLineHeight = -titlePaint.ascent() + titlePaint.descent();
		float textLineHeight = -textPaint.ascent() + textPaint.descent();
 
		if (imgSizeMode == 0 && (imgHeightInPixel == -1 || imgWidthInPixel == -1)) {
			// We don't know the exact size of the image yet, so approximate it 
			imgHeightInPixel = (int) (titleLineHeight * imgSizeInLines);
			imgWidthInPixel = imgHeightInPixel;
		} 
 
		int fullWidth = availableWidth - getPaddingLeft() - getPaddingRight();
		int tabbedWidth = (int) (fullWidth - (imgWidthInPixel + imagePadding));
 
		int imageHeightInTitleLines = (int) Math.ceil(imgHeightInPixel / titleLineHeight);
 
		int titleLines = 100;
		int[] titleMaxWidths = new int[titleLines];
		tabbedTitleLines = Math.min(titleLines, imageHeightInTitleLines);
		Arrays.fill(titleMaxWidths, 0, tabbedTitleLines, tabbedWidth);
		Arrays.fill(titleMaxWidths, tabbedTitleLines, titleLines, fullWidth);
		titleBreaker.setMaxWidths(titleMaxWidths);
		titleBreaker.breakText(title, titlePaint);
 
		int textLinesToTab = 0;
		float realTitleLinesHeight = titleBreaker.getLines().size() * titleLineHeight;
		if ((realTitleLinesHeight + titleTextPadding) < imgHeightInPixel) {
			float d = imgHeightInPixel - (realTitleLinesHeight + titleTextPadding);
			textLinesToTab = (int) Math.ceil(d / textLineHeight);
		} 
 
		int[] textMaxWidths = new int[textMaxLines];
		tabbedTextLines = Math.min(textLinesToTab, textMaxLines);
		Arrays.fill(textMaxWidths, 0, tabbedTextLines, tabbedWidth);
		Arrays.fill(textMaxWidths, tabbedTextLines, textMaxLines, fullWidth);
		textBreaker.setMaxWidths(textMaxWidths);
		textBreaker.breakText(text, textPaint);
 
		return availableWidth;
	} 
 
	@Override