public double computeWidthUntilCharacter(int paragraph, int character) {
		List<Text> textNodes = getTextNodes(paragraph);
		double width = 0;
		int index = 0;
		Text lastNode = null;

		for (Text textNode : textNodes) {
			String text = textNode.getText();
			double boundWidth = textNode.getBoundsInLocal().getWidth();

			if (index + text.length() < character) {
				index += text.length();
				width += boundWidth;
			} else {
				double charWidth = boundWidth / StringUtil.getTabAdjustedLength(text);
				width += charWidth * (character - index);
				return width;
			}

			lastNode = textNode;
		}

		// we never reached the character
		if (index < character) {
			double charWidth = 0L;
			if (lastNode == null)
				charWidth = 1.7;
			else
				charWidth = lastNode.getBoundsInLocal().getWidth() / StringUtil.getTabAdjustedLength(lastNode.getText());

			width += charWidth * (character - index);
		}

		return width;
	}
Compute the width of text until a specific character.

@param paragraph
		Paragraph index to compute the width of.
@param character
		Character index to compute the width until.

@return Width of text until the character.
recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/Editor.java