Skip to content

More wrap-character visual tests #2427

Open

Description

@springmeyer

There are a lot of line wrapping conditions it would be good to capture in visual tests. So far we just have b8a0c16 which tests wrapping on a few custom characters when wrap-character is provided. But the more common usecase is when users do not manually provide wrap-character and instead only provide wrap-width. In this case the wrapping is done automatically based on the locale + ICU break iterator. This needs more test with various types of international text so that if anything regresses we'll understand the changes and in the future if we support intelligent locales the visual tests can capture what improves in the layout results.

Activity

  1. springmeyer commented on Sep 22, 2014

    @springmeyer
    MemberAuthor

    /cc @Andrey-VI - would be great if you could supply a pull request that covers some of your common and more rare usecases.

  2. springmeyer commented on Oct 15, 2014

    @springmeyer
    MemberAuthor

    bump @Andrey-VI - this is your chance to help make sure your future usecases don't break :)

  3. Andrey-VI commented on Oct 16, 2014

    @Andrey-VI

    Yep. I'll try to do something for this.

  4. Andrey-VI commented on Nov 3, 2014

    @Andrey-VI

    Copy from 'Pull requests' section:
    After this new visual tests I realized that I need a different behaviour from wrap-character and repeat-wrap-character="true":
    if we use, for example, wrap-character="-" and repeat-wrap-character="true" all default ICU line breaking are ignored. How to avoid this?

    For now I have two ideas, both of them doesn't break wrap-character behaviour:

    1. Use repeat-wrap-character="[symbol]", so if ICU breaks line at this [symbol] it's repeated on the new line.
    2. Use repeat-wrap-character="true/false" and repeat any ICU line break characters except whitespace characters (RegEx \s class) on the new line.

    I prefer the first one.

    @artemp , @springmeyer , is this possible to implement? What are you think?

  5. springmeyer commented on Nov 3, 2014

    @springmeyer
    MemberAuthor

    Thanks for the details @Andrey-VI. I'm having trouble understanding exactly what you need. Could you provide some specific visual images of what you think would be ideal output? Then we will have more of a clear sense of how to implement correctly.

  6. Andrey-VI commented on Nov 3, 2014

    @Andrey-VI

    OK. I'll try to explain more.
    Current behaviour:
    text-line-wrap-800-450-2 0-agg

    First and third column: wrap-character='', second and fourth: wrap-character='-';
    first row: repeat-wrap-character="false", second: repeat-wrap-character="true".

    I want to achieve this behaviour:
    text-line-wrap-800-450-2 0-agg-mod

    I'm wondering is it possible to know at what symbol ICU break iterator breaks line? If it is possible than we can introduce repeat-wrap-character="[symbol]" property and repeat only that [symbol] on new lines.

  7. Andrey-VI commented on Apr 7, 2015

    @Andrey-VI

    @springmeyer , do you understand what I want? :)

  8. Andrey-VI commented on Sep 9, 2015

    @Andrey-VI
  9. Andrey-VI commented on Apr 13, 2021

    @Andrey-VI

    @springmeyer, @artemp, 6 years and counting… Is it hopeless?
    Still using 2.3.x because of this hyphen issue in Mapnik 3.x :(
    See #2333 (comment)

  10. artemp commented on Feb 17, 2022

    @artemp
    Member

    @Andrey-VI - I'm trying to have a fresh look at this issue but I'm confused. Could you provide a test case (XML style file with inlined JSON datasource) which would result in text rendering you mentioned above ? Thanks.

  11. Andrey-VI commented on Feb 17, 2022

    @Andrey-VI

    @artemp, visual test: #2539
    Unfortunately, in the current version of Mapnik it's impossible to do what I mentioned above. If it were possible, then there would be no request…
    The key issue now is: if we use, for example, wrap-character="-" and repeat-wrap-character="true" all default ICU line breaking are ignored. So a names without -, for example Two Four Eight Sixteen Thirty two Sixty four, won't wrap at all.
    And for combinations of Two-Four-Eight-Sixteen-Thirty two-Sixty four and Two Four Eight Sixteen Thirty two Sixty four we can get either

    Two-Four-
    Eight-Sixteen-
    Thirty two-
    Sixty four
    

    and
    Two Four Eight Sixteen Thirty two Sixty four
    with a small wrap-width, wrap-character="-" and repeat-wrap-character="false"
    or

    Two-Four-
    -Eight-Sixteen-
    -Thirty two-
    -Sixty four
    

    and
    Two Four Eight Sixteen Thirty two Sixty four
    with a small wrap-width, wrap-character="-" and repeat-wrap-character="true".
    Current behaviour:
    current
    Desired behaviour (options variant 1):
    desired
    Desired behaviour (options variant 2):
    desired - 2
    Thus, for combinations of Two-Four-Eight-Sixteen-Thirty two-Sixty four and Two Four Eight Sixteen Thirty two Sixty four I want to get

    Two-Four-
    -Eight-Sixteen-
    -Thirty
    two-Sixty
    four
    

    and (something like)

    Two Four
    Eight
    Sixteen
    Thirty
    two Sixty
    four
    

    .

  12. artemp commented on Feb 17, 2022

    @artemp
    Member

    @Andrey-VI 👍 I need to familiarise myself with current implementation again. I'll try to find time next week (Tuesday). Thanks.

  13. artemp commented on Apr 20, 2022

    @artemp
    Member

    @Andrey-VI
    Could you try the following patch to see if it addresses your issue ? This is not a proper solution, I'm just trying to understand the issue. The patch always treats (space) character as a potential break point:

    diff --git a/src/text/text_layout.cpp b/src/text/text_layout.cpp
    index e091e1429..625fcf03b 100644
    --- a/src/text/text_layout.cpp
    +++ b/src/text/text_layout.cpp
    @@ -330,16 +330,37 @@ struct line_breaker : util::noncopyable
         std::int32_t following(std::int32_t offset)
         {
             std::int32_t pos = ustr_.indexOf(wrap_char_, offset);
    +        std::int32_t pos2 = ustr_.indexOf(' ', offset);
             if (pos != -1)
    +        {
    +            if (pos2 != -1 && pos2 < pos) pos = pos2;
    +            ++pos;
    +        }
    +        else if (pos2 != -1)
    +        {
    +            pos = pos2;
                 ++pos;
    +        }
             return pos;
         }
     
         std::int32_t preceding(std::int32_t offset)
         {
             std::int32_t pos = ustr_.lastIndexOf(wrap_char_, 0, offset);
    +        std::int32_t pos2 = ustr_.lastIndexOf(' ', 0, offset);
             if (pos != -1)
    +        {
    +            if (pos2 != -1 && pos2 > pos) pos = pos2;
                 ++pos;
    +        }
    +        else if (pos2 != -1)
    +        {
    +            pos = pos2;
    +            ++pos;
    +        }
    +
    +        //if (pos != -1)
    +        //    ++pos;
             return pos;
         }
  14. artemp commented on Apr 20, 2022

    @artemp
    Member

    text-line-wrap

  15. Andrey-VI commented on Apr 20, 2022

    @Andrey-VI

    @artemp,
    master:
    text-repeat-wrap-character-512-512-2 0-agg-reference
    master with the patch:
    text-repeat-wrap-character-512-512-2 0-agg
    Looks very promising!
    But I believe that the second column should not contain the space characters indicated below:
    Two-Four-
    -Eight-
    -Sixteen-
    -Thirty
    two-Sixty
    four
    (wrap-character="-", repeat-wrap-character="true")
    and
    Two-Four-
    Eight-
    Sixteen-
    Thirty
    two-Sixty
    four
    (wrap-character="-", repeat-wrap-character="false").
    The first column does not contain this extra space characters both for
    wrap-character="", repeat-wrap-character="true"
    and
    wrap-character="", repeat-wrap-character="false".

  16. artemp commented on Apr 21, 2022

    @artemp
    Member

    @Andrey-VI - as I mentioned this is just to clarify what is a desirable output visually and not a solution. Extra spaces are occurring because they're treated the same way as a wrap-character (in this case -). To summarise - rendering above minus extra spaces is what you're expecting, right?

  17. Andrey-VI commented on Apr 21, 2022

    @Andrey-VI

    @artemp, yes, you're right.
    In short: ideally, I want the default ICU line breaking (as in the first column) with the ability to repeat - on new lines.

  18. Andrey-VI commented on Apr 5, 2024

    @Andrey-VI

    Hi @artemp, any progress on this?
    I recently found out that my custom 2.3.x build does not have #1543 change that I really need. Therefore, migration to 3.x has become even more necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions