Link to home
Start Free TrialLog in
Avatar of kisrael
kisrael

asked on

Java Fonts on X-windows

I'm doing some server side graphic generating, and I'm having trouble with shrinking the default "serif" and "sans-serif" fonts on X... I'm trying to shrink a font to make sure a line of text is beneath a certain width, but it seems like a lot of font sizes get bumped up to the next fontsize, until finally a font size of 1 or 2 shows up as microscopic.  Are there any fonts in particular that have more flexibility in sizing on X?  Or should I be taking another approach to this problem?
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Could you post some code?
Avatar of kisrael
kisrael

ASKER

Ugh-- I don't have the source here right now, but the basic idea in pseudocode is:

String text = "this is a test";
int fontsize = 10
int maxwidth = 200
Font thisfont = new font(size=fontsize)

while (width of (text) > maxwidth
          && fontsize > 1) {
   fontsize--
   thisfont = new font(size=fontsize)
}

drawtext(text)
I can't see any reason, other than an unnoticed error in your code, why this shouldn't work...
Avatar of kisrael

ASKER

The code works fine on Windows, but I think the fonts that are used in that setup tend to scale much better than under X: the former tend to be truetype, the latter tend to be bitmap.  So it's a question that's pretty specific to X I think.
ASKER CERTIFIED SOLUTION
Avatar of jwenting
jwenting
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kisrael

ASKER

Sorry, I can't just use one size fits all for fonts.

Aren't there any X fonts that are available in a wider array of sizes?
Good luck kisrael - I'm out
Avatar of kisrael

ASKER

Guess there wasn't a great answer for this one. Sorry it took so long for me to get back to it....