Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Overlapping text

Explorer ,
Mar 21, 2025 Mar 21, 2025

A script for Illustrator that selects text objects containing a single character that are in exactly the same position on the page, one on top of the other, overlapping.

function selectOverlappingTextObjects() {
	var doc = app.activeDocument;
	var textFrames = doc.textFrames;
	var selectedItems = [];
	for (var i = 0; i < textFrames.length; i++) {
		var tf1 = textFrames[i];
		if (tf1.contents.length === 1) {
			var tf1Bounds = tf1.geometricBounds; 
			var tf1Position = {
				x: (tf1Bounds[0] + tf1Bounds[2]) / 2,
				y: (tf1Bounds[1] + tf1Bounds[3]) / 2
			};
			for (var j = i + 1; j < textFrames.length; j++) {
				var tf2 = textFrames[j];
				if (tf2.contents.length === 1) {
					var tf2Bounds = tf2.geometricBounds;
					var tf2Position = {
						x: (tf2Bounds[0] + tf2Bounds[2]) / 2,
						y: (tf2Bounds[1] + tf2Bounds[3]) / 2
					};
					if (Math.abs(tf1Position.x - tf2Position.x) < 1 && Math.abs(tf1Position.y - tf2Position.y) < 1) {
						tf1.selected = true;
						tf2.selected = true;
						selectedItems.push(tf1, tf2);
					}
				}
			}
		}
	}
	return selectedItems;
}
selectOverlappingTextObjects();

This script works, but it selects both text objects. The idea is to leave only one, so it should select only one of each pair.

TOPICS
Feature request
99
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Adobe