Re: Automatically resize font when component size changes?



Thanks Andrew, but I kind of hoping there would be something a little
simpler. I've already looked at the FontMetrics as described in my
first post. If I use that, I would have to:

1) Figure out which string is the widest and tallest of all possible
strings. I'm betting it's likely 88:88:88 but to be safe, I'd have to
check all of them for a given font. Some weird font might make
11:11:11 really wide.
2) Figure out how much painting area I actually have within a JLabel.
Actually, I still don't know how to find this part out! I guess I
could just be conservative and say (width-16)x(height-16).
3) Figure out how large I could make the biggest string found in step
1 such that it would not overflow the dimensions found in step two.
Other than an experimental trial and error of create the string,
measure the string, compare against dimensions, repeat, I'm not sure
how to do this.

What I'm looking for is a way to drastically speed up this process so
I have the user resize the control on the fly without tanking the CPU.
-Will

.



Relevant Pages

  • Re: screen.fonts again
    ... As far as I know in a single font file ... Private Declare Function RegCloseKey Lib "advapi32.dll" _ ... ByVal lpSubKey As String, ... Dim Buffer As String, FontName As String ...
    (microsoft.public.vb.general.discussion)
  • Re: [Q]How to display Tahoma italic font
    ... I can't display Tahoma font in italic properly using ... string and incrementing XIncrement, you should do a second increment as ... character of the non-italic string that follows). ... // beginning at the specified point (XIncrement, YStart). ...
    (microsoft.public.win32.programmer.gdi)
  • Re: CListCtrl unicode doesnt display korean characters correctly
    ... Your assumptions are ok about the not described types, Strings are CString, not arrays of TCHARs ... It is a font from Microsoft. ... The korean string is in case 2. ... The LoadString method gets it from the resources. ...
    (microsoft.public.vc.mfc)
  • Re: [Q]How to display Tahoma italic font
    ... right hand normal letters overlap the last italic letter. ... other fonts, here i mean any font i've tried. ... space you need for the string. ... // beginning at the specified point (XIncrement, ...
    (microsoft.public.win32.programmer.gdi)
  • Re: File Hex View : how to improve this procedure ?
    ... OneHexLine: String; ... RichEdit With no word wrap and fixed width font ...
    (comp.lang.pascal.delphi.misc)