Text width

From: Oskar Sigvardsson (gingis55_at_yahoo.com)
Date: 02/27/04


Date: 26 Feb 2004 16:52:39 -0800

Hello,

I need to know how to get get the width of a string without having a
java.awt.Graphics around (otherwise i'd just
graphics.getFontMetrics().stringWidth("Hello I'm a string") )

The thing is that I have I function that returns an Image with the
text, and I want to create the Image inside the function. The size of
the Image is determined by how big the text is, but to get the size of
the text I need to have an Image, and to get the Image I need to know
the size of the text. So I'm in a catch-22 hell and I don't know how
to get out (I suppose I could create a temporary Image and use that
for determining the size and then discard it and create another Image
with the correct size but there has to be a better way.)

Any help appriciated
Oskar Sigvardsson



Relevant Pages

  • Re: Decipher Formula
    ... calculates for each cell in the range J3:P57 the difference between the ... and the string which results if you substitute 'Discard' in these ... J4: With Discard ... The SUMPRODUCT formula would return the following for these three ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Parsing JSON (#155)
    ... In some places where I don't want to discard I use (? ... converting it to Ruby 1.8 like this: ... def invalid ... 'Invalid JSON: %s' % string ...
    (comp.lang.ruby)
  • Re: How to use EOF in C
    ... nch = nch + 1; ... So if we get EOF, we simply discard the data read to that point, ... An '\0' by itself is not a string. ... If you have a character pointer pointing to that then the pointer is ...
    (comp.lang.c)
  • Re: Encoding difference in Vista breaks my app :(
    ... i've done some more testing and found that it wasn't safe to discard anything above ASCII 179. ... a working version is to open up the hashed string into a Char array, and then check if the integer value of each one is 65533. ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Read strings from one file and search for them in a directory containing htm files
    ... > find a matching line that contains that ONE STRING, ... In the 'grep' command above: ... -r for recursive searching, since if the number of files was large, ... first match (and print out the filename, but we discard that). ...
    (comp.unix.shell)