All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.openhtmltopdf.bidi.support.ICUBidiSplitter Maven / Gradle / Ivy

Go to download

Open HTML to PDF is a CSS 2.1 renderer written in Java. This artifact supports right-to-left text mixed with left-to-right text.

There is a newer version: 1.0.10
Show newest version
package com.openhtmltopdf.bidi.support;

import com.ibm.icu.text.Bidi;
import com.ibm.icu.text.BidiRun;
import com.openhtmltopdf.bidi.BidiSplitter;
import com.openhtmltopdf.bidi.BidiSplitterFactory;
import com.openhtmltopdf.bidi.BidiTextRun;

public class ICUBidiSplitter implements BidiSplitter {

	public static class ICUBidiSplitterFactory implements BidiSplitterFactory {
		@Override
		public BidiSplitter createBidiSplitter() {
			return new ICUBidiSplitter();
		}
	}
	
	private Bidi bidi = new Bidi();
	
	@Override
	public void setParagraph(String paragraph, byte defaultDirection) {
		bidi.setPara(paragraph, defaultDirection, null);
	}

	@Override
	public int countTextRuns() {
		return bidi.countRuns();
	}

	@Override
	public BidiTextRun getVisualRun(int runIndex) {
		BidiRun run = bidi.getVisualRun(runIndex);
		BidiTextRun textRun = new BidiTextRun(run.getStart(), run.getLength(), run.getDirection());
		return textRun;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy