Java Code Examples for com.lowagie.text.Utilities#isSurrogatePair()

The following examples show how to use com.lowagie.text.Utilities#isSurrogatePair() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BidiLine.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Gets the width of a range of characters.
 * 
 * @param startIdx the first index to calculate
 * @param lastIdx the last inclusive index to calculate
 * @return the sum of all widths
 */
public float getWidth(int startIdx, int lastIdx) {
	char c = 0;
	char uniC;
	PdfChunk ck = null;
	float width = 0;
	for (; startIdx <= lastIdx; ++startIdx) {
		boolean surrogate = Utilities.isSurrogatePair(text, startIdx);
		if (surrogate) {
			width += detailChunks[startIdx].getCharWidth(Utilities.convertToUtf32(text, startIdx));
			++startIdx;
		} else {
			c = text[startIdx];
			ck = detailChunks[startIdx];
			if (PdfChunk.noPrint(ck.getUnicodeEquivalent(c))) {
				continue;
			}
			width += detailChunks[startIdx].getCharWidth(c);
		}
	}
	return width;
}
 
Example 2
Source File: BidiLine.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Gets the width of a range of characters.
 * @param startIdx the first index to calculate
 * @param lastIdx the last inclusive index to calculate
 * @return the sum of all widths
 */    
public float getWidth(int startIdx, int lastIdx) {
    char c = 0;
    PdfChunk ck = null;
    float width = 0;
    for (; startIdx <= lastIdx; ++startIdx) {
        boolean surrogate = Utilities.isSurrogatePair(text, startIdx);
        if (surrogate) {
            width += detailChunks[startIdx].getCharWidth(Utilities.convertToUtf32(text, startIdx));
            ++startIdx;
        }
        else {
            c = text[startIdx];
            ck = detailChunks[startIdx];
            if (PdfChunk.noPrint(ck.getUnicodeEquivalent(c)))
                continue;
            width += detailChunks[startIdx].getCharWidth(c);
        }
    }
    return width;
}