Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text length for last paragraph #353

Closed
shalanah opened this issue May 23, 2016 · 3 comments
Closed

Text length for last paragraph #353

shalanah opened this issue May 23, 2016 · 3 comments

Comments

@shalanah
Copy link

Looks like the last paragraph is one character longer than the string provided. Just wondering if this is a bug, or intentional. Are we just missing the last character of the paragraph?

{
  "textKey": "testing",
  "textStyleRange": [
    {
      "from": 0,
      "to": 8, // should be 7 unless an assumed end of paragraph character
      "textStyle": {}
    }
  ],
  "paragraphStyleRange": [
    {
      "from": 0,
      "to": 8, // should be 7 unless an assumed end of paragraph character
      "paragraphStyle": {}
    }
  ]
}
@mcilroyc
Copy link
Contributor

@shalanah could you please provide a little more context? What are the simple steps to reproduce the data you included in the bug description?

@shalanah
Copy link
Author

Sure, no problem!

Example 1:

  • Create a textbox with the text "Lorem\rIpsum"
Paragraph 1: "Lorem\r"

Looking at the first paragraphStyleRange we have from: 0 and to: 6 which works perfectly. It also gives us an accurate length of 6 characters ( 6 - 0 ).

Paragraph 2: "Ipsum"

Here we have from: 6 and end with to: 12. This gives us an inaccurate length of 6 characters ( 12 - 6 ) when "Ipsum" is only 5 characters long.

"text": {
    "textKey": "Lorem\rIpsum",
    "paragraphStyleRange": [
        {
            "from": 0, // good
            "to": 6, // good
            "paragraphStyle": '...'
        },
        {
            "from": 6, // good
            "to": 12, // one character too long
            "paragraphStyle": '...'
        }
    ]
}

Example 2:

  • Create a text box with just the text "Lorem"
Paragraph 1: "Lorem"

Looking at the paragraphStyleRange we have from: 0 and to: 6. This gives us the inaccurate length of 6 characters when "Lorem" is only 5 characters long.

"text": {
    "textKey": "Lorem",
    "paragraphStyleRange": [
        {
            "from": 0, // good
            "to": 6, // one character too long
            "paragraphStyle": '...'
        }
    ]
}

@mcilroyc
Copy link
Contributor

I was able to reproduce this, and I can't see how this would be considered correct. But I also can't make a strong case for trying to change it.

Another way to look at it... If you don't factor \r in the paragraph text then they're both off by one!
lorem = 5
ipsum = 5

cc: @timothynoel in case you feel that this could/should be addressed in photoshop proper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants