Skip to main content
Participant
October 30, 2020
Answered

Remove Auto Kern from entire document

  • October 30, 2020
  • 6 replies
  • 708 views

I am trying to convert a series of flash site documents to an HTML5 canvas. They're pretty basic, a few moving elements and some buttons, but it seems like all of my text has "Auto Kern" checked. I've found that if I have a single piece of text with Auto Kern on, the document (once published) will not play. Is there a way remove Auto Kern from everything, with a script or otherwise? For each of these documents I've been playing Where's Kern for hours, and it feels like there must be a better way. Is it possible to do with scripts?

 

Any advice would be greatly appreciated.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer ClayUUID

The presence of Auto Kern in a converted document shouldn't stop it from playing. At most it should just generate a warning when you publish. That's all that used to happen.

 

Well, that being said, try copying this script into a .jsfl file and running it when your document is loaded. It should strip all the auto kerning from a document. Not extensively tested, but seems to work.

function main() {
	var dom = fl.getDocumentDOM();
	scanLibrary(dom.library.items);
	scanTimeline(dom.getTimeline());
	alert("Scan complete!");
}

function scanLibrary(libItems) {
	var i, item;
	for (i in libItems) {
		item = libItems[i];
		if (["movie clip", "graphic", "button"].indexOf(item.itemType) != -1) {
			scanTimeline(item.timeline);
		}
	}
}

function scanTimeline(timeline) {
	var layer, frames, element, member, frameSet, elementSet, memberSet;
	var	layerSet = timeline.layers;
	for (layer in layerSet) {
		frameSet = layerSet[layer].frames;
		for (frame in frameSet) {
			elementSet = frameSet[frame].elements;
			for (element in elementSet) {
				changeText(elementSet[element]);
				memberSet = elementSet[element].members;
				if (memberSet != undefined) {
					for (member in memberSet) {
						changeText(memberSet[member]);
					}
				}
			}
		}
	}
}

function changeText(item) {
	if (item.textRuns) {
		for (var txt in item.textRuns) {
			item.textRuns[txt].textAttrs.autoKern = false;
		}
	}
}

main();

 

6 replies

ClayUUIDCorrect answer
Legend
October 30, 2020

The presence of Auto Kern in a converted document shouldn't stop it from playing. At most it should just generate a warning when you publish. That's all that used to happen.

 

Well, that being said, try copying this script into a .jsfl file and running it when your document is loaded. It should strip all the auto kerning from a document. Not extensively tested, but seems to work.

function main() {
	var dom = fl.getDocumentDOM();
	scanLibrary(dom.library.items);
	scanTimeline(dom.getTimeline());
	alert("Scan complete!");
}

function scanLibrary(libItems) {
	var i, item;
	for (i in libItems) {
		item = libItems[i];
		if (["movie clip", "graphic", "button"].indexOf(item.itemType) != -1) {
			scanTimeline(item.timeline);
		}
	}
}

function scanTimeline(timeline) {
	var layer, frames, element, member, frameSet, elementSet, memberSet;
	var	layerSet = timeline.layers;
	for (layer in layerSet) {
		frameSet = layerSet[layer].frames;
		for (frame in frameSet) {
			elementSet = frameSet[frame].elements;
			for (element in elementSet) {
				changeText(elementSet[element]);
				memberSet = elementSet[element].members;
				if (memberSet != undefined) {
					for (member in memberSet) {
						changeText(memberSet[member]);
					}
				}
			}
		}
	}
}

function changeText(item) {
	if (item.textRuns) {
		for (var txt in item.textRuns) {
			item.textRuns[txt].textAttrs.autoKern = false;
		}
	}
}

main();

 

Participant
November 1, 2020

This script is absolutely awesome. Did the trick.

 

Should I be worried that some of these files weren't working with auto-kern enabled on text? I determined that it was causing issues by laboriously deleting layers, by process of elimination. I found that if I had a single layer with Auto Kern checked anywhere on the timeline, the published HTML5 file would just load as the background color... If I unchecked auto-kern, then bam, it would load just fine... Is that a sign that there's something more systemically wrong with my projects? 

Participating Frequently
November 2, 2020

@etguillemette : In HTML5 canvas documents, auto kern is not supported for dynamic text and will be removed for converted documents. Could you please share a sample project where it is causing issues in HTML5 canvas output on publishing or, submit a bug report with file links.