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?
Could you post some code?
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)
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...
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
Aren't there any X fonts that are available in a wider array of sizes?
Good luck kisrael - I'm out
ASKER
Guess there wasn't a great answer for this one. Sorry it took so long for me to get back to it....