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

An object style that aligns center the text without changing the font

Explorer ,
Jan 25, 2025 Jan 25, 2025

Copy link to clipboard

Copied

Hi, there 

 

I’d like to make an object style that aligns center the text without changing the font in the text frame. 

 

There is a way to do Vertical Justification in Object Style, 

(Object Style - TextFrame General Options - Vertical Justification- Center )

and to align center, as far as I know, the only way is to use paragraph style. 

But if I use paragraph style, it will be centered, but even the font will change.

 

How do I make an object style that only centers the text, without changing the font?

 

Screenshot 2025-01-26 at 1.18.38 PM.pngScreenshot 2025-01-26 at 12.34.10 PM.png

 

Screenshot 2025-01-26 at 1.21.10 PM.png

TOPICS
How to , Type

Views

300

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

Paragraph alignmnet is, indeed, a parpagraph level attribute and as such would be controlled by the Paragraph Style, but that doesn't mean you have to change the font.

Create a new Paragraph Style, based on your existing style that has the attributes you want, then change only the paragraph alignment in that style.

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
Explorer ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

Thanks for replying, @Peter Spier 

Isn't the font family selected and set by default in paragraph style?

In character style, the font is set to be blank by default .

Is there a way not to select a font in paragraph style?

 

Screenshot 2025-01-26 at 11.16.48 PM.png

 

Screenshot 2025-01-26 at 11.17.41 PM.png

 

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

Yes, you must select a font in the paragraph style, but you can have all of the same specifications over multiple styles.

Perhaps I'm misunderstanding the question. Are you asking if you can create an object style that will override the paragraph alignment specified in the paragraph style? The answer to that is No. An object style can either ignore the paragraph style or assign one, but cannot otherwise modify the style.

If for example you have Paragraph Style 1 that is Minion Pro 12pt with 14pt leading, left aligned, and you want the text in your frame to appear center aligned, but otherwise unchanged, you would want to create a Paragraph Style 2, Based on Paragraph Style 1, and change the alignement from Left to Center, and specify Paragraph Style 2 in the Object Style. By using Based On any changes you make to the base style, in this case Paragraph Style 1, will carry over into Paragraph Style 2 later, EXCEPT the Center alignment which you changed initially.

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
Explorer ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

@Peter Spier 

Based on doesn't seem to work.

What I need is a feature that basically keeps the font changing, but aligns it in the center.

 

 I have many text frames with different fonts.

I’d like to align center these using  only one object styles.

Is there any other possible way?

 

Screenshot 2025-01-26 at 11.57.35 PM.pngScreenshot 2025-01-26 at 11.57.57 PM.pngScreenshot 2025-01-26 at 11.58.11 PM.png

 

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

@raldrald

 

Can you post a real example of what you have / want to accomplish?

 

Showing dummy examples isn't helpful. 

 

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
Explorer ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

@Robert at ID-Tasker 

I don't think I need to upload the file.

What I want is very simple.

As I've already explained Peter, I just want those texts in many text frames to be centered.

If possible with one object style....

Screenshot 2025-01-27 at 12.50.06 AM.png

 

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

quote

@Robert at ID-Tasker 

I don't think I need to upload the file.

What I want is very simple.

As I've already explained Peter, I just want those texts in many text frames to be centered.

If possible with one object style....

Screenshot 2025-01-27 at 12.50.06 AM.png

 

By @raldrald

 

You can ignore - uncheck - ParaStyle option in the ObjectStyle definition. 

 

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

As @Peter Spier said, you will need to attach a paragraph style. It reads as if you have used different fonts in the objects. In that case, you would need to create multiple paragraph styles and then attach each one to its own object style. Of course, you could always apply a single object style and then apply the appropriate paragraph style as an override.

 

David Creamer: Community Expert (ACI and ACE 1995-2023)

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
Explorer ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

@Dave Creamer of IDEAS 

Yes, I know that a paragraph style feature included in object styles.

I don't think I need to make multiple paragraph styles for my work I'm doing. 

I just want to align center text, without affected other font properties... 

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

If you have multiple different paragraph styles in the frames you want to center you will need to create multiple paragraph styles that are center aligned, apply them to those paragraphs, then ignore the paragraph style in your object style if you want to do this with a single object style. There is no escaping the need for multiple styles , either paragraph or object, or both.

That said, there might be a scripting solution that would allow you to tag these frames, then use a script to adjust the alignment, or @Robert at ID-Tasker's tool mighht work, but I don't see this as any less work.

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

What else do you need the Object style to do? 

 

David Creamer: Community Expert (ACI and ACE 1995-2023)

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

Then just manually override the alignment after you apply the object style. Otherwise, you need the multiple paragraph styles and the multiple object styles. 

 

David Creamer: Community Expert (ACI and ACE 1995-2023)

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

Hi @raldrald:

 

A paragraph style will define all attributes of a paragraph, so no, a paragraph style cannot lack a Font Family designation.

 

See if this visual explanation is helpful:

 

  • The vertical alignment is controlled by the Object Style—in my demo, that's all it is doing.
  • The font/size/style/horizontal alignment is controlled by the paragraph style. Personally, I'd go with @Dave Creamer of IDEAS 's approach—one paragraph style per frame. Alternatives—neither considered a best practice but if you have a bazillion of these, maybe it is best for you—is add overrides or assign a full-paragraph character style. (Since you seem averse to multiple styles, I'd say go with the font overrides.)

 

2025-01-26_09-54-16 (1).gif

 

Even after any of the font modifications, the object style still controls the frame-level commands like vertical justification and the paragraph style still controls everything except for the Font Family:

 

2025-01-26_10-04-30 (1).gif

 

~Barb

 

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

CharStyle can override font family? 

 

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
Explorer ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

@Barb Binder

Thanks for the attached image.

I thought there would be a really simple way,

but there are more steps than I thought.

I wish Adobe would make that the font isn't selected by default in paragraph style settings like character style.

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

@raldrald

 

If you tell us what is your workflow - and show us more actual examples - I'm pretty sure we can think of something...

 

Right now - we have only some theoretical, dummy examples.

 

If you really have so many different fonts involved - how about DataMerge? Nested Styles? GREP Styles? XML? Tagged Text? Etc. 

 

There is always more than one way to skin the proverbial cat. 

 

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
Community Expert ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

quote

I wish Adobe would make that the font isn't selected by default in paragraph style settings like character style.

 

I hear you, but this is how all page layout applications work:

 

A paragraph style is used to define an entire paragraph, and a character style is used to differentiate words that need to look different from the rest of the text within that paragraph.

 

Whether we time-travel back to the early mid-late 80s and return to working in PageMaker or Ventura Publisher, or leap forward again to modern-day InDesign and FrameMaker, paragraph styles are used to define all aspects of each type of paragraph (title, subtitles, body copy, bullets, footnotes, etc) and then we may add character styles for the words that need to be emphasized or differentiated (perhaps a font or style or color change) within the paragraph. I am never one to suggest using overrides, but if you have that many titles and don't want to uses styles then, that's my recommendation.

 

Now if you think this is something that others would benefit from, you can log a feature request at https://indesign.uservoice.com/ . The more votes a feature request gets, the more attention it will draw from the InDesign engineering team. Please note that the community forums are geared towards users (like those of us addressing your question) helping other users (like you) figure out how to work within the bounds of the existing application. Like you, we don't work for Adobe and we can't re-engineer the software. We can offer explanations and workflow tips but that's about it.

 

~Barb

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
Explorer ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

Thanks, @Barb Binder 

I'll request the feature later. 

Thanks for your kind replying. 

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
Explorer ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

For anyone else who might need it.

 

A script that applies an object style that centers the text horizontally and vertically

when a text frame is selected.

 

// Get the active document
var doc = app.activeDocument;

// Define the object style name to be applied
var objectStyleName = "Centered TextBox Style";

// Check if the object style exists
var targetObjectStyle;
try {
    targetObjectStyle = doc.objectStyles.itemByName(objectStyleName);
    // Accessing name property to ensure it exists
    targetObjectStyle.name;
} catch(e) {
    // If the object style doesn't exist, create it
    targetObjectStyle = doc.objectStyles.add({name: objectStyleName});
    // Set your desired properties for the new object style here if needed
}

// Function to center text vertically and horizontally
function centerTextFrame(textFrame) {
    // Apply the object style
    textFrame.appliedObjectStyle = targetObjectStyle;

    // Loop through all paragraphs in the text frame
    for (var j = 0; j < textFrame.paragraphs.length; j++) {
        var paragraph = textFrame.paragraphs[j];

        // Center the text horizontally
        paragraph.justification = Justification.centerAlign;
    }

    // Center the text vertically by setting vertical justification
    textFrame.textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
}

// Check if any text frame is selected
if (app.selection.length > 0 && app.selection[0] instanceof TextFrame) {
    var selectedTextFrame = app.selection[0];
    centerTextFrame(selectedTextFrame);
   
} else {
    alert("Please select a text frame.");
}

 

 

A script that selects only the text frames with Object Sytle 1 applied

and aligns the texts horizontally in the center.

// Get the active document
var doc = app.activeDocument;

// Define the object style to target
var targetObjectStyle = doc.objectStyles.itemByName("Object Style 1");

// Loop through all text frames
for (var i = 0; i < doc.textFrames.length; i++) {
    var textFrame = doc.textFrames[i];

    // Check if the text frame has the target object style applied
    if (textFrame.appliedObjectStyle === targetObjectStyle) {

        // Loop through all paragraphs in the text frame
        for (var j = 0; j < textFrame.paragraphs.length; j++) {
            var paragraph = textFrame.paragraphs[j];

            // Change the alignment to center
            paragraph.justification = Justification.centerAlign;
        }
    }
}

// Message to indicate the script has run successfully
alert("Text frames with 'Object Style 1' applied have been center-aligned without changing the font.");

 

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
Community Expert ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

LATEST

@raldrald 

 

Have you used ChatGPT to generate this code?

 

 

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