Skip to content

gmt text -Dj argument not functioning as intended #5981

Closed

Description

@NevPalmer

Description of the problem

When using the command gmt text -M for plotting files of multi-line text, the -Dj option does not correctly offset the text with respect to the specified justification (TL, BR, etc).
This issue only occurs with multi-line text. Standard single-line text plots offset correctly as expected.

Full script that generated the error

#! /usr/bin/env bash
gmt begin test_plot pdf

    gmt basemap -R10/70/-3/8 -JX15c/10c -B -B+glightgreen+t"Test plot"

# The following displays as expected with no -Dj parameter specified
    gmt text -M -F+f+a+j <<EOF
>30 3 10p,Times-Bold,black 0 TR 0.32c 2c r
Original  X
Multiline.
EOF
# The following does not displays as expected
# with the -Dj parameter specified the multiline text is always offset with
# respect to +x +y and not in the direction relevant to the justification
# (In this case because TR is used I would expect the offset to be -x -y)
    gmt text -M -F+f+a+j -Dj2c <<EOF
>30 3 10p,Times-Bold,black 0 TR 0.32c 2c r
Offset   X
Multiline.
EOF

# When standerd single line text is plotted the -Dj offset is applied as expected
# with respect to the specified justification (TR in the 2nd example).
    gmt text -F+f+a+j <<EOF
50 3 10p,Helvetica,red 0 TR Original single line. X
EOF
    gmt text -F+f+a+j -Dj2c <<EOF
50 3 10p,Helvetica,red 0 TR Offset single line. X
EOF

gmt end

Full error message

There is no error message. The plotted text is offset incorrectly.

Actual outcome
The single-line and multi-line text are both specified to offset similarly but they offset in opposite directions as ahown in this PDF, which was generated from the above script.
test_plot.pdf

Expected outcome

The offset direction when specified by -Dj should be as defined by the text justification.
eg text justified TR should offset -x -y
or text justified BL should offset +x +y

System information

  • Operating system:
  • GMT version (gmt --version): 6.1.0

Activity

  1. added
    bug
    on Nov 11, 2021
  2. welcome commented on Nov 11, 2021

    @welcome

    👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. We appreciate that you took the time to contribute!

    Please make sure you read our Contributing Guide and abide by our Code of Conduct.

  3. self-assigned this
    on Nov 11, 2021
  4. added this to the milestone on Nov 11, 2021
  5. PaulWessel commented on Nov 11, 2021

    @PaulWessel
    Contributor

    I can confirm the issue I will look for a fix.

  6. PaulWessel commented on Nov 12, 2021

    @PaulWessel
    Contributor

    Actually, -Dj for paragraphs were never implemented since it has to be done in PostScript (we do not know the paragraph height until we use PostScript operators). So for now I will update the docs to state that -Dj cannot be used with -M, but I will open a feature request so that we do not forget to see how we can implement this down the road.

  7. maxrjones commented on Nov 12, 2021

    @maxrjones
    Member

    Closing this issue, since the feature request part will be tracked by #5986.

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

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions