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

Type popping out of text frame

Guide ,
Apr 07, 2023 Apr 07, 2023

Copy link to clipboard

Copied

#InDesign #typography Some times type pops out of the text frame, what is this called? Is there a way to detect or automatically fix it. Does it matter?

 

I have looked at the app.selection[0].lines[0].endHorizontalOffset, which seems to be clipped to the text frame.

 

It was suggested that I look at the optical settings, but these did not change the appearance.

 

If I export the frame the type is clipped.

 

Is this a bug?

 

*I have a motive this question, I have a plugin that can detect this effect. But, I would prefer a script.

 

Screen Shot 2023-04-07 at 13.20.59.png

TOPICS
Scripting , SDK

Views

6.5K

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
Guide ,
Apr 10, 2023 Apr 10, 2023

Copy link to clipboard

Copied

Mark, that is very clever.  Excellent work.

 

Good to see a pure scripting solution. 

 

P.

 

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 ,
Apr 10, 2023 Apr 10, 2023

Copy link to clipboard

Copied

Yes it's good. 
Would like it to duplicate the frame to a new layer and put all the markers on that new layer.

It would be simple layer deletion to remove all the other pieces around it.

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 ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

I can tell you that whether this is a bug or not, it's a MAJOR PAIN. Recently, Amazon KPD has apparently made their gutter restrictions more stringent, or updated their software to catch little things like this, and it has totally ruined my carefully planned layout. It's a 500+ page book with graphics and illustrations, very tedious with everything having a very specific place. And the font is serifed and some of the serifs go into the gutter no matter what I do, and KDP then flags it when I upload my manuscript.

 

Serif-Gutter-Issue-9 August 2024.jpg

 


I don't care if some people want it like this, there should be an option to absolutely make it NOT like this if other people want that. Just make an absolute option to keep all characters inside the margins no matter what.

 

  • Changing the Margins is not an option, because it throws my entire layout off, causing everything to jump down, creating more pages, which will essentially force me to redo the entire layout.
  • Changing fonts is not an option for the same reasons.
  • Changing the Optical is not an option, because it might fix the serifs, but it forces the quotes to dangle instead, and then there's no way to fix that.

 

This file was perfectly laid out using the requirements I was given, and it took a week to get it done. Now, I have to redo the whole thing because of one little software quirk. I don't know whether KDP is being too sensitive or not, but Adobe InDesign should definitely have a fix for this.

—Michael

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 ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

I should add that I've used this particular font very frequently. All my novels were uploaded to KDP using it, and the prior edition of this book that I'm working on now was done in this font, so something clearly changed at KDP.

—Michael

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 ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

Things change perpetually at KDP.  Sometimes they even announce them. Other times, it just becomes part of the arcana of AI, bots, offshore support staff in ESL locations, and checklist/playbooks handed down from Jeff.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

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 ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

@positive_build0D4C

 

Print it scaled down - 1-2% smaller should be enough.

 

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 ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

I don't know whether KDP is being too sensitive or not,

 

They are.

 

A text frame could have any amount of Inset Spacing applied, which would keep the optical alignment, but prevent any overhang:

 

Screen Shot 10.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 ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

I remember this thread now - had a good re-read of it.

@rob day The text inset is the only way to get this done from what I have found - that's my experience too.

But I have pointed out before that this causes the entire text to reflow.

So all the Text Margins I use now are 0.5mm (top) 1mm (bottom) 0.3mm (left) and 0.3mm (right)

 

That usually is a good border for all text.

As for the person with the KDP issue - they'd have to have these insets on every text frame - and that will cause text reflow - and they have stressed it will cause text reflow to an already very tediously set out layout. 

 

It's quite frustrating that some see it as a bug and others don't. 

I agree partially it's both - and I agree that it should be an option to be absolute keep within text boundaries or be loosely goosey.

 

I think the option really should be 'Dynamic Insets' - where the text frame increases/decreases by the desired amount to ensure the text is kept within the text frame. 

The option could also indicate if you want all text frames to be the same insets or adjust individually based on content. 

 

For me, individually based would be amazing. for others the maximum required would be better.
For others, don't have to use the feature.

 

I think it's a great feature request. 

Dynamic Text Insets with an option for all text frames or individual text frames.

 

At the moment, I just make text frames with insets as described earlier. 

Maybe also the option should be to keep text within margins, so the margins/columns would act as barriers with text wrap applied to force the text inside the area. 

 

Worse thing is Tables - absolutely crazy these can't be dynamically set to fit column widths. 

As I often have tables moving from column to column with different column widths, and manually adjusting the width of the table to match the column each time. 

I had to write a script to automatically resize the columns to the width of the columns (I think some people here helped me with this one - can't remember). 

 

I think it's crazy that text/tables can stick outside of frames.

They are frames.

 

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

I think it's crazy that text/tables can stick outside of frames.

 

InDesign optically aligns the text column to the frame, and to the margin if the frame is aligned to the margin. ID has no hanging punctuation feature, which you might see in other applications—OMA is a better approach because it considers the shape of all the glyphs, and not just the punctuation. I doubt Adobe would ever consider abandoning OMA.

 

KDP’s safe zone requirement is arbitrary, so an obvious solution might be to simply set a larger safe zone then they require.

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

Imagine you went to get a picture framed and the corner was sticking out of the frame. And the answer you get is, "it's optically in the frame"

 

 

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

Imagine you went to get a picture framed and the corner was sticking out of the frame

 

But a text frame without a stroke or fill doesn’t print. Consider this case where I’m setting 24pt justified Garamond  on a 100pt margin with OMA turned on. The text visually aligns to the 100pt margins—the puncuation has to sit outside of the frame in order to create the appearance of an alignment.

 

Screen Shot 13.png

 

I could turn off OMA, or add a 5pt inset to force the puncuation inside of the frame, but now the alignment no longer appears to be on my 100pt margin—the optical text margin is at 105 pt:

 

Screen Shot 14.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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

Still don't know why it protrudes the frame. It's a frame. It should be inside the frame. That's what a frame is. 

 

All the text should shift automatically to accommodate. 

 

I get it hangs outside the frame for some alignment "feature".

 

But for me it should stay in the frame and everything else should adjust. 

 

It's a frame.

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

You can turn off OMA, but then the puncuation no longer hangs creating empty white space around the glyphs:

 

Screen Shot 15.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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

Surely you must have enough experience with the more ornamental fonts to know that many use (fishing for a term) 'negative kerning' to place swashes and extreme serifs over/under other characters. That's what we have here with fonts like Jenson, especially the italic faces, variant characters and ornaments. They know where the line is, but are designed to overstep it. And as Rob has pointed out, in a regular text column where there are no guidelines, the behavior is perfectly acceptable, even unnoticed; it's just another facet of that (small catregory of) font/s, like a particular x-height or old-style numerals and such.

 

If it were a behavior seen in common fonts, it would be unwanted and a bug.. With these fonts, it's ID precisely following the type's mapping.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

Are you talking to me @James Gifford—NitroPress forum is not great at recognising this...

 

Anyway - I have over 25 years typesetting experience. 

I work with automated detection of text outside of a predesignated area, a pixel out is declared enough for a rejection.

 

Don't get to pick the fonts - already predetermined - and already said I set the text insets quite large so descenders/ascenders/accents/terminals/head serifs/tails etc. don't protrude the frame and trigger the alarm bells.

 

It's say 10mm margin all around, everything outside the margin is 'text free' - it's stringent.

So a situation like this is unacceptable

 

EugeneTyson_0-1723311841859.png

 

 

That's why I have to increase the text insets all around on text frames. 

 

But besides saying 'it's a feature not a bug' -  text is still outside the text frame.

Doens't matter how it's dressed up.

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

Yep, I'm lookin' at you, @Eugene Tyson. 🙂

 

I mean, okay. Not calling it a feature, just a reality. And if you're working with a one-pixel error margin, it's not really the same thing as mainstream typesetting for print or print-equivalent. I'll just note again that this class of fonts has always behaved this way, back to lead type. If a feature is needed to auto-correct/-prevent/-detect/-fix it, I won't vote no. I just think that's missing the point.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

Well look we all know the ins-outs - some more than others - as to why it happens. 

It is frustrating and requires a workaround - as it doesn't behave as expected. 

 

As I said it could be built into the text frame options or the paragraph styles to prevent it happening.

 

We all work differently have different requirements, and different workarounds and tollerances. 

 

I'd love not to have to overlay the technical drawing on the text and scan around by eye zoomed in at 1200% to see if any text or table has inadvertently surpassed the margins that were set. 

 

 

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

@Eugene Tyson - have you ever considered a white outer stroke on the frame, or a masking frame, to simplify that process?


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

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 ,
Aug 11, 2024 Aug 11, 2024

Copy link to clipboard

Copied

quote

@Eugene Tyson - have you ever considered a white outer stroke on the frame, or a masking frame, to simplify that process?


By @James Gifford—NitroPress

 

How about masking TFs, exporting JPEGs, using Photoshop to get all the popouts.

 

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

quote

So a situation like this is unacceptable

But besides saying 'it's a feature not a bug' -  text is still outside the text frame.


By @Eugene Tyson

 

So, unless I missing something, shouldn't disabling optical margin alignment do exactly what you need (as @rob day has demonstrated above)?

 

OR do you still want to use OMA, but wish it to make the text more narrow by squeezing it inside the frame, instead of protruding the hanging parts?

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

No, text should be in the frame. 

It's a frame

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

No, text should be in the frame.  It's a frame

 

Hi @Eugene Tyson, I can definitely see where you're coming from here and—apologies all for long post—I'll add my opinion to the mix.

 

For me, historically, the text frame (beyond simply positioning, as all frames do) is a thing for setting type, usually in galleys or whatever, and provide us with conveniences such as optical margin alignment and the various manual tweaking we can do to improve the result. All was the craft of setting type and the text frame was to hold and manage this sequence of words and glyphs. That is all it has ever been, in my experience, from the first proper typesetting programs to now. This "1-pixel-resolution-boundary-enforcing" is a new requirement and, in my opinion, nothing to do with the behaviour of text frames, per se.

 

By contrast, the purpose of a graphic frame (beyond simply positioning, as all frames do) is to crop the graphic. This process is itself an art/craft worthy of considerable effort, as we all know. I would definitely complain and file a bug report if a graphic protruded—by even a pixel—from its frame!

 

I think that the analogy of a graphic frame to a text frame is not applicable. They are different beasts, that happen to share some properties, such as being able to be sized and positioned on the page. And that we call them both "frames".

 

My analysis of this situation is similar to @rob day's:  the job has specified a *rigid* clearspace and the type setter has made their text frame too close to it. "Oops. I didn't know that glyphs can protrude from text frames! Now I know." Then spends 5 hours re-flowing text and consolidating the memory of what text frames don't do.

 

But let's put my opinion aside and see how this can be fixed for you, Eugene...

 

You can see that simply aligning the justified character would create very unpleasant margins in many fonts. So to keep a nice margin, the "optimal" (also optical) margin would have to be determined to be inside the text frame by an amount that would differ between fonts, and would be the maximum amount for every extreme edge glyph in the entire story, that is: every page in the book, considering the glyphs on every side of the text frame—top, left, bottom, right—and apply to all text frames containing the story. (If it didn't consider every text frame containing the story the margins of the book would jump about from page to page.)

 

It could be done, but would be a fair bit of work for Adobe I think. You obviously really want this feature so there's a good chance that others might too. I suggest you file a feature request on uservoice.

 

I just wouldn't want Adobe to change the current behaviour of text frames, sorry, that would be awful.

- Mark

 

Addendum: Choosing the right text frame inset for a particular font automatically might be a difficult task: Does Indesign consider every single glyph in the font, including weird swashes and ligatures, which might mean the extreme boundary calculated was weirdly large? Or would it only consider the actual glyphs used on the extremes, which would mean that edits to the text could literally change the margins of the whole book! I would prefer to use my judgement and move the text frame away from the clear space in a sensible manner.

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 ,
Aug 11, 2024 Aug 11, 2024

Copy link to clipboard

Copied

I dont agree

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 ,
Aug 11, 2024 Aug 11, 2024

Copy link to clipboard

Copied

LATEST

I've made an attempt! I have written a script (that uses my earlier function to detect protruding glyphs) and makes an adjustment to the entire story's text—I just scaled the text horizontally because that was quickest—so that no glyph protrudes form the story's text frame(s).

 

demo.gif

 

No idea if this is suitable for real use, but it might be a starting point for a script to fix the mistake without re-flowing everything.

- Mark

/**
 * @File Fix Protruding Story.js
 *
 * Usage:
 *   1. Select a text frame.
 *   2. Run script.
 *
 * Notes:
 *   - Adjusts entire story, not only selected text frame.
 *   - Adds left/right text inset as needed to stop glyphs
 *     protruding from the text frame(s).
 *   - Does not make attempt at vertical axis protrusions.
 *   - Adjusts a story by slight horizontal scaling,
 *     so that no glyph protrudes from the story's
 *     text frame(s). (A better implementations might
 *     adjust tracking, for example.)
 *   - Every text frame containing story will be given
 *     identical text insets, even if no glyphs protrude
 *     from a particular text frame; this is to avoid the
 *     margin jumping around in a book.
 *   - The left and right text insets may be different.
 *   - Quick, proof-of-concept only!
 *
 * @author m1b
 * @version 2024-08-12
 * @discussion https://community.adobe.com/t5/indesign-discussions/type-popping-out-of-text-frame/m-p/13711048
 */
function main() {

    var doc = app.activeDocument,
        textFrame = doc.selection[0];

    if (
        !textFrame
        || !textFrame.isValid
        || textFrame.constructor.name !== 'TextFrame'
    ) {
        alert('Please select a text frame and try again.');
        return;
    }

    app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

    // get all text frames containing story
    var story = textFrame.parentStory,
        textFrames = story.textContainers;

    // calculate the maximum overshoot distance on all sides of all frames
    var overTop = 0,
        overLeft = 0,
        overBottom = 0,
        overRight = 0;

    for (var i = textFrames.length - 1, frame, bounds, protrusions, over; i >= 0; i--) {

        frame = textFrames[i];
        protrusions = getProtrudingCharacterBounds(frame);

        if (!protrusions)
            return;

        over = combineBounds(protrusions);
        bounds = frame.geometricBounds;

        overTop = Math.max(overTop, bounds[0] - over[0]);
        overLeft = Math.max(overLeft, bounds[1] - over[1]);
        overBottom = Math.max(overBottom, over[1] - bounds[2]);
        overRight = Math.max(overRight, over[3] - bounds[3]);

    }

    // adjust each text frame insets so no overshoot
    for (var i = textFrames.length - 1, frame, scale; i >= 0; i--) {

        frame = textFrames[i];

        frame.textFramePreferences.insetSpacing = [
            frame.textFramePreferences.insetSpacing[0],
            frame.textFramePreferences.insetSpacing[1] + overLeft,
            frame.textFramePreferences.insetSpacing[2],
            frame.textFramePreferences.insetSpacing[3] + overRight
        ];

        // quick and dirty solution:
        // horizontal scale text to fit
        scale = (bounds[3] - bounds[1] - overLeft - overRight) / (bounds[3] - bounds[1]);
        frame.textStyleRanges.everyItem().horizontalScale *= scale;

    }

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Fix Protruding Story');

/**
 * Returns bounds of the protruding
 * parts of lines of text frame.
 *
 * Known limitation: because it duplicates the text frame,
 * this will sometimes cause a reflow if a paragraph using
 * a multi-line composer spans multiple text frames.
 *
 * @author m1b
 * @version 2024-04-11
 * @Param {TextFrame} tf - an Indesign TextFrame.
 * @Param {Number} [offset] - distance, in points, to enlarge each bounds by (default: 0).
 * @Returns {Array<Array>} - array of [T, L, B, R] arrays.
 */
function getProtrudingCharacterBounds(tf, offset) {

    app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
    offset = offset || 0;

    // get the outermost textframe
    while (tf.parent.constructor.name == 'Character')
        tf = tf.parent.parentTextFrames[0];

    var bounds = tf.geometricBounds;

    // duplicate text frame
    var dup = tf.duplicate();
    outlines = dup.createOutlines();

    // add outlines of anchored text frames
    while (outlines[outlines.length - 1].textFrames.length > 0)
        outlines.push(outlines[outlines.length - 1].textFrames[0].createOutlines()[0]);

    // find the protruding outlines
    var found = [];

    outlinesLoop:
    for (var i = 0; i < outlines.length; i++) {

        var polygons;
        if (outlines[i].constructor.name == 'Polygon')
            // we get a Polygon if there is only one character in text frame
            polygons = [outlines[i]];

        else if (outlines[i].hasOwnProperty('polygons'))
            // a Group with polygons
            polygons = outlines[i].polygons;

        else
            continue;

        for (var j = 0; j < polygons.length; j++) {

            var r = getProtrudingRect(bounds, polygons[j].visibleBounds, offset);

            if (r)
                found = found.concat(r);

        }

    }

    // delete all the outlines
    for (var i = outlines.length - 1; i >= 0; i--)
        outlines[i].remove();

    if (dup.isValid)
        // sometimes the duplicate is left behind
        // eg. when there is a table in the text frame
        dup.remove();

    if (found)
        return found;

};

/**
 * Returns the protruding part of a rectangle.
 * @author m1b
 * @version 2024-04-11
 * @Param {Array<Number>} r1 - [T,L,B,R].
 * @Param {Array<Number>} r2 - [T,L,B,R].
 * @Param {Number} [offset] - the amount to expand resulting rectangle (default: 0).
 * @Returns {Array<Number>} [T,L,B,R].
 */
function getProtrudingRect(r1, r2, offset) {

    offset = offset || 0;

    var results = [];

    var top1 = r1[0], top2 = r2[0],
        left1 = r1[1], left2 = r2[1],
        bottom1 = r1[2], bottom2 = r2[2],
        right1 = r1[3], right2 = r2[3];

    if (
        bottom1 <= top2 || top1 >= bottom2 || right1 <= left2 || left1 >= right2
        || (left2 >= left1 && right2 <= right1 && top2 >= top1 && bottom2 <= bottom1)
    ) {
        // No overlap between the rectangles, or second
        // rectangle is completely within the first.
        return;
    }

    // handle cases where protrudes from both sides
    if (top1 > top2 && bottom1 < bottom2) {
        results = results.concat(getProtrudingRect([top1, left1, bottom2, right1], r2, offset));
        results = results.concat(getProtrudingRect([top2, left1, bottom1, right1], r2, offset));
        return results;
    }

    if (left1 > left2 && right1 < right2) {
        results = results.concat(getProtrudingRect([top1, left1, bottom1, right2], r2, offset));
        results = results.concat(getProtrudingRect([top1, left2, bottom1, right1], r2, offset));
        return results;
    }

    // Define the outside rectangle.
    var outside = [top2, left2, bottom2, right2];

    // Check for overlap on each side and adjust the outside rectangle accordingly.
    if (left1 > left2) {
        outside[1] = left2;
        outside[3] = left1;
    }
    if (right1 < right2) {
        outside[1] = right1;
        outside[3] = right2;
    }
    if (top1 > top2) {
        outside[0] = top2;
        outside[2] = top1;
    }
    if (bottom1 < bottom2) {
        outside[0] = bottom1;
        outside[2] = bottom2;
    }

    if (offset) {
        // expand by offset (useful for better
        // visibility of tiny protrusions)
        outside[0] -= offset;
        outside[1] -= offset;
        outside[2] += offset;
        outside[3] += offset;
    }

    return [outside];

};


/**
 * Returns the combined bounds of all bounds supplied.
 * Works with Illustrator or Indesign bounds.
 * @author m1b
 * @version 2024-03-09
 * @Param {Array<bounds>} boundsArray - an array of bounds [L, T, R, B] or [T, L , B, R].
 * @Returns {bounds} - the combine bounds.
 */
function combineBounds(boundsArray) {

    var combinedBounds = boundsArray[0].slice(),
        comparator;

    if (/indesign/i.test(app.name))
        comparator = [Math.min, Math.min, Math.max, Math.max];
    else if (/illustrator/i.test(app.name))
        comparator = [Math.min, Math.max, Math.max, Math.min];

    for (var i = 1; i < boundsArray.length; i++) {
        var bounds = boundsArray[i];

        combinedBounds[0] = comparator[0](combinedBounds[0], bounds[0]);
        combinedBounds[1] = comparator[1](combinedBounds[1], bounds[1]);
        combinedBounds[2] = comparator[2](combinedBounds[2], bounds[2]);
        combinedBounds[3] = comparator[3](combinedBounds[3], bounds[3]);

    }

    return combinedBounds;

};

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 ,
Aug 10, 2024 Aug 10, 2024

Copy link to clipboard

Copied

> text is still outside the text frame. Doens't matter how it's dressed up.

 

@Eugene Tyson it occurs to me that this might just be a UI issue:

 

I like that the basis for the text's margin (eg. an optical margin) aligns with the text frame UI's edge, because I want to position the notional (optimal?) margin, precisely.

 

By contrast, you want to position the text's extreme boundary of all glyphs in the story, so the text frame's UI's edges should represent this extreme boundary. I don't want this because it would make it harder for me to precisely specify where I wanted the margin to be, and I want glyphs to protrude where appropriate.

 

That might be a good way of stating this if you file a feature request. Not sure. Communication is hard.

 

EDIT: How about a preference drop down menu "Text frame UI shows:"

1. "Text margins"

2. "Glyph boundaries"

(assuming the technical challenges I mentioned in other post were solved).

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