Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7195941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:40:51+00:00 2026-05-28T20:40:51+00:00

I have some code (unfortunately not written by me, or else I would know

  • 0

I have some code (unfortunately not written by me, or else I would know where to start looking for solutions) that draws some line graphs. When I run the code on my Windows machine and on the Linux machine, I get different results: on the Linux machine, the border around the legend is drawn with less height, resulting in some ugly problems when there are more than 3 items in the legend.

Is there some known difference when using

int getHeight(Graphics2D g, String text) {
    Rectangle2D bounds = g.getFont().getStringBounds(text, g.getFontMetrics().getFontRenderContext());
    return bounds.getHeight();
}

or where could the problem be?

Windows:

C:\>java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

Linux:

$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.10) (6b20-1.9.10-0ubuntu1~10.04.3)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

UPDATE:

It was a rounding bug that seemingly only occurred with linux fonts, not with windows ones. Strange.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:40:52+00:00Added an answer on May 28, 2026 at 8:40 pm

    Your method is based on getFontMetrics(), that return the font metric of the current font. I assume you’re using default font in your program, and they are different in the different OS, so the result height might be different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some terribly written ASP.NET code that is just not working right (go
I have some code in a javascript file that needs to send queries back
I have some code that gives a user id to a utility that then
In Netbeans, I used some scala code (jar) written by someone else and included
I've inherited a 10K-line program written in 8051 assembly language that requires some changes.
I have some code that calls an API and gets a set of results
I have been assigned a project with a lot of poorly written code that
So I have a library (not written by me) which unfortunately uses abort() to
I have some code that is used to programmatically create a Document to send
I have some code that needs Unicode strings for the most part, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.