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 1070155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:31:18+00:00 2026-05-16T20:31:18+00:00

You can obtain the width of a string in the current font with stringwidth

  • 0

You can obtain the width of a string in the current font with stringwidth and although this actually pushes offset coordinates on the stack, the y-value always seems to be useless. Is there a way to determine the exact height of a string, that may or may not include descenders?

  • 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-16T20:31:20+00:00Added an answer on May 16, 2026 at 8:31 pm

    stringwidth, as it says, doesn’t return string’s height. (In all cases I looked at, the second integer on the stack after executing stringwidth was 0 — for strings that run in horizontal direction.) stringwidth gives the relative coordinates of the currentpoint after executing a (string) show.

    The PLRM has this to say about stringwidth:

    Note that the width returned by stringwidth is defined as movement of the current
    point. It has nothing to do with the dimensions of the glyph outlines.

    So what would work to take into account the string’s height? The magic words to read up about in PRLM are charpath and pathbbox. Try this:

    %!
    /Helvetica findfont 60 scalefont setfont
    200 700 4 0 360 arc fill 
    200 700 moveto (test test) dup 
    true charpath pathbbox 
    3 -1 roll sub 2 div neg 3 1 roll sub 2 div exch 
    1 0 0 setrgbcolor
    200 700 moveto rmoveto show showpage
    

    It calculates the string’s (printed in red) height and uses that info to try and center a small filled circle (printed in black) into the center of its bounding box:

    Sample PostScript visualized

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

Sidebar

Related Questions

I have a Version class that contains a version_number string, and can obtain a
How can you obtain the system clock's current time of day (in milliseconds) in
we have that string: I like to eat apple How can I obtain the
code below. i'm tryind to obtain string answers like a1, c4 this is what
Whilst inside an iframe, can you please let me know how I can obtain
Can I obtain the source code for the core Ada libraries? I'd like to
How can I obtain the count of faulted messages from a Windows Azure Storage
How can I obtain the physical machine name that my jvm is running in?
How can I obtain kerning information for GDI to then use in GetKerningPairs ?
I have starter new System.Diagnostics.Process and it launchs FireFox. How can I obtain the

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.