how to change the font size after catch some character

Participant ,
Nov 08, 2020 Nov 08, 2020

Copy link to clipboard

Copied

Hey all,

 

I'm trying to view a decimal value, and after the point (11.11) i want to decrase the font size...

I've managed to read and change the size but chatching the value after the point and make smaller was a bit tricky.

var rect = doc.pages[0].textFrames.add({
		geometricBounds: [12.7, 12.7, 90, 90]
	});

	rect.contents = "737.87"
	rect.texts[0].pointSize = 30
	rect.texts[0].appliedFont = "Variable	Black"
	rect.texts[0].parentStory.justification = Justification.CENTER_ALIGN

 

bascily, i want to check if the content has a point and if yse after the point "87" make  the font smaller lets say 20 and before the point "737" same font size 30 ..

if any one can help me i will be thankful.

thanks all again.

TOPICS
Activation billing and install, Bug, EPUB, Feature request, How to, Import and export, InCopy workflow, Performance, Print, Publish online, Scripting, SDK, Server developers, Sync and storage, Type

Views

105

Likes

translate

Translate

Translate

Report

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

correct answers 1 Correct Answer

Adobe Community Professional , Nov 08, 2020 Nov 08, 2020
Try the following   var rect = app.activeDocument.pages[0].textFrames.add({ geometricBounds: [12.7, 12.7, 90, 90] }); rect.contents = "737.87" rect.texts[0].pointSize = 30 rect.texts[0].appliedFont = "Variable Black" rect.texts[0].parentStory.justification = Justification.CENTER_ALIGN app.findGrepPreferences.findWhat = '\\d+\\.\\K\\d+' var f = rect.findGrep() if(f.length) f[0].pointSize = 20 app.findGrepPreferences.findWhat = NothingEnum.NOTHING   -Manan

Likes

translate

Translate

Translate
Adobe Community Professional ,
Nov 08, 2020 Nov 08, 2020

Copy link to clipboard

Copied

Try the following

 

var rect = app.activeDocument.pages[0].textFrames.add({
		geometricBounds: [12.7, 12.7, 90, 90]
	});

	rect.contents = "737.87"
	rect.texts[0].pointSize = 30
	rect.texts[0].appliedFont = "Variable	Black"
	rect.texts[0].parentStory.justification = Justification.CENTER_ALIGN

app.findGrepPreferences.findWhat = '\\d+\\.\\K\\d+'
var f = rect.findGrep()
if(f.length)
	f[0].pointSize = 20
app.findGrepPreferences.findWhat = NothingEnum.NOTHING

 

-Manan

Likes

translate

Translate

Translate

Report

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
Participant ,
Nov 08, 2020 Nov 08, 2020

Copy link to clipboard

Copied

EXACTLY LIKE WHAT I WANT!!! THANKSSSS

Likes

translate

Translate

Translate

Report

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