@Override
	public AttributedString substring(int start, int end) {
		IndexedOffset startPos = getIndexedOffsetForCharPosition(start);
		IndexedOffset endPos = getIndexedOffsetForCharPosition(end);

		// start and end are in the same attributed string
		if (startPos.index == endPos.index) {
			AttributedString asStart = attributedStrings[startPos.index];
			return asStart.substring(startPos.offset, endPos.offset);
		}

		// 1) find the new start and end attributed strings
		AttributedString asStart = attributedStrings[startPos.index];
		AttributedString newStart = asStart.substring(startPos.offset);
		AttributedString asEnd = attributedStrings[endPos.index];
		AttributedString newEnd = asEnd.substring(0, endPos.offset);

		// 2) add the strings in between
		AttributedString[] newStrings = new AttributedString[(endPos.index - startPos.index) + 1];

		// copy into the second position until the second to last position, as the first and
		// last positions will be filled in later
		System.arraycopy(attributedStrings, startPos.index + 1, newStrings, 1,
			newStrings.length - 1);

		// 3) add the new start and new end into the respective positions
		newStrings[0] = newStart;
		newStrings[newStrings.length - 1] = newEnd;
		return new CompositeAttributedString(newStrings);
	}
An AttributedString that is composed of other AttributedStrings.
Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/CompositeAttributedString.java