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

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 , Sync and storage , Type

Views

278

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

Community Expert , 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

Votes

Translate

Translate
Community Expert ,
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

Votes

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

LATEST

EXACTLY LIKE WHAT I WANT!!! THANKSSSS

Votes

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