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

  • Home
  • SEARCH
  • 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 7420889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:18:59+00:00 2026-05-29T08:18:59+00:00

In core Java book it says The width of the rectangle that the getStringBounds

  • 0

In core Java book it says

The width of the rectangle that the getStringBounds method returns is the horizontal
extent of the string. The height of the rectangle is the sum of ascent, descent, and
leading. The rectangle has its origin at the baseline of the string. The top y -coordinate of the rectangle is negative. Thus, you can obtain string width, height, and
ascent as follows:

double stringWidth = bounds.getWidth();
double stringHeight = bounds.getHeight();
double ascent = -bounds.getY();

What does the author mean when saying that the rectangle has its origin at the baseline of the string, while top y-coordinate is the ascent?

Where does the bounding rectangle of the string start?

with a test string i got the following:

w: 291.0
h: 91.265625
x:0.0
y:-72.38671875
descent: 15.8203125
leading: 3.0585938

That mean the rectangle origin is at the leading not the baseline, am i correct on this?

  • 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-29T08:18:59+00:00Added an answer on May 29, 2026 at 8:18 am

    The math works out:

    72.38671875 ascent + 15.8203125 descent + 3.0585938 leading = 91.265625 total height

    This tutorial on 2D Text has an image illustrating leading, descent, and ascent.

    In your specific case, 72.38671875 is the height of the ascent. That’s measured from the baseline to the top of the tallest glyph. The leading is the space between the bottom of the descender to the top of the next line.

    The bounding rectangle is relative to the baseline. The API for FontMetrics.getStringBounds states “The returned bounds is in baseline-relative coordinates”, which explains your results. x will always be 0, and the height of the bounding box will be the ascent plus the descent plus the leading.

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

Sidebar

Related Questions

In the Core Java Volume1 book there is a caution that say: CAUTION: The
Is there any website which provides core java based programming challenges that tests programming
In a book on Core Java, I found this excerpt : Think about the
I am a core Java developer (J2SE) that was assigned to a one-man project,
What's the difference between Java Servlet and core Java? Is that difficult to learn
Can we read cookies using core-java, that has been written using .NET MVC code?
I've recently learned core Java and want to develop my skills further with practice
Using Eclipse I want to view the source code for a core Java class
How does Java decide which core to assign a thread or a process? Is
I have this JSP code snippet: <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c%> <c:choose> <c:when test=${var1.properties[\Item Type\]

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.