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

EMFRenderer ignores selected textAlignMode #28

Open
vladk-dev opened this issue Aug 29, 2014 · 0 comments
Open

EMFRenderer ignores selected textAlignMode #28

vladk-dev opened this issue Aug 29, 2014 · 0 comments

Comments

@vladk-dev
Copy link

EMFRenderer.textAlignMode is ignored when drawing text. Thus the text is being placed wrong unless textAlignMode is TA_LEFT.

The following patch works for me. I have tested it with TA_CENTER:

  public void drawOrAppendText(String text, double x, double y) {
    FontRenderContext frc = g2.getFontRenderContext();
    TextLayout layout = new TextLayout(text, g2.getFont(), frc);
    double textWidth = layout.getBounds().getWidth();
    if ((getTextAlignMode() & EMFConstants.TA_CENTER) != 0) {
        x = x - (textWidth / 2);
    } else if ((getTextAlignMode() & EMFConstants.TA_RIGHT) != 0) {
        x = x - textWidth;
    }
    ...
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

1 participant