private void saveWordBreakIfNotYetSaved(Glyph wordBreak) { if (savedWordBreakAtLineEnding == null) { if (TextUtil.isNewLine(wordBreak)) { wordBreak = font.getGlyph('\u0020'); // we don't want to print '\n' in content stream } // it's word-break character at the end of the line, which we want to save after trimming savedWordBreakAtLineEnding = new GlyphLine(Collections.<Glyph>singletonList(wordBreak)); } }
private void saveWordBreakIfNotYetSaved(Glyph wordBreak) { if (savedWordBreakAtLineEnding == null) { if (TextUtil.isNewLine(wordBreak)) { wordBreak = font.getGlyph('\u0020'); // we don't want to print '\n' in content stream } // it's word-break character at the end of the line, which we want to save after trimming savedWordBreakAtLineEnding = new GlyphLine(Collections.<Glyph>singletonList(wordBreak)); } }
/** * Trims any whitespace characters from the start of the {@link GlyphLine} * to be rendered. */ public void trimFirst() { updateFontAndText(); if (text != null) { Glyph glyph; while (text.start < text.end && TextUtil.isWhitespace(glyph = text.get(text.start)) && !TextUtil.isNewLine(glyph)) { text.start++; } } }
/** * Trims any whitespace characters from the start of the {@link GlyphLine} * to be rendered. */ public void trimFirst() { updateFontAndText(); if (text != null) { Glyph glyph; while (text.start < text.end && TextUtil.isWhitespace(glyph = text.get(text.start)) && !TextUtil.isNewLine(glyph)) { text.start++; } } }
private void updateBidiLevels(int totalNumberOfTrimmedGlyphs, BaseDirection baseDirection) { if (totalNumberOfTrimmedGlyphs != 0 && levels != null) { levels = Arrays.copyOfRange(levels, totalNumberOfTrimmedGlyphs, levels.length); } List<Integer> unicodeIdsReorderingList = null; if (levels == null && baseDirection != null && baseDirection != BaseDirection.NO_BIDI) { unicodeIdsReorderingList = new ArrayList<>(); boolean newLineFound = false; for (IRenderer child : childRenderers) { if (newLineFound) { break; } if (child instanceof TextRenderer) { GlyphLine text = ((TextRenderer) child).getText(); for (int i = text.start; i < text.end; i++) { Glyph glyph = text.get(i); if (TextUtil.isNewLine(glyph)) { newLineFound = true; break; } // we assume all the chars will have the same bidi group // we also assume pairing symbols won't get merged with other ones int unicode = glyph.hasValidUnicode() ? glyph.getUnicode() : glyph.getUnicodeChars()[0]; unicodeIdsReorderingList.add(unicode); } } } levels = unicodeIdsReorderingList.size() > 0 ? TypographyUtils.getBidiLevels(baseDirection, ArrayUtil.toIntArray(unicodeIdsReorderingList)) : null; } }
private void updateBidiLevels(int totalNumberOfTrimmedGlyphs, BaseDirection baseDirection) { if (totalNumberOfTrimmedGlyphs != 0 && levels != null) { levels = Arrays.copyOfRange(levels, totalNumberOfTrimmedGlyphs, levels.length); } List<Integer> unicodeIdsReorderingList = null; if (levels == null && baseDirection != null && baseDirection != BaseDirection.NO_BIDI) { unicodeIdsReorderingList = new ArrayList<>(); boolean newLineFound = false; for (IRenderer child : childRenderers) { if (newLineFound) { break; } if (child instanceof TextRenderer) { GlyphLine text = ((TextRenderer) child).getText(); for (int i = text.start; i < text.end; i++) { Glyph glyph = text.get(i); if (TextUtil.isNewLine(glyph)) { newLineFound = true; break; } // we assume all the chars will have the same bidi group // we also assume pairing symbols won't get merged with other ones int unicode = glyph.hasValidUnicode() ? glyph.getUnicode() : glyph.getUnicodeChars()[0]; unicodeIdsReorderingList.add(unicode); } } } levels = unicodeIdsReorderingList.size() > 0 ? TypographyUtils.getBidiLevels(baseDirection, ArrayUtil.toIntArray(unicodeIdsReorderingList)) : null; } }
GlyphLine childLine = ((TextRenderer) child).line; for (int i = childLine.start; i < childLine.end; i++) { if (TextUtil.isNewLine(childLine.get(i))) { newLineFound = true; break;
GlyphLine childLine = ((TextRenderer) child).line; for (int i = childLine.start; i < childLine.end; i++) { if (TextUtil.isNewLine(childLine.get(i))) { newLineFound = true; break;
if (TextUtil.isNewLine(text.get(ind))) { wordBreakGlyphAtLineEnding = text.get(ind); isSplitForcedByNewLine = true;
if (TextUtil.isNewLine(text.get(ind))) { wordBreakGlyphAtLineEnding = text.get(ind); isSplitForcedByNewLine = true;