|
Is there a way to make a font bigger or smaller than 12 pixels? Displaying 1-3 of 3 total.
1
KingOfTheNorth
|
There doesn't seem to be any discussion in the forums about EnableVariableWidth() and SetCharacterWidth().
I tried both functions and came up empty-handed (aka does not work)
In the documentation for SetCharacterWidth(), the description
void SetCharacterWidth(int font, int character, int width)
shows an 'int' for the character (which I can only assume the ascii number of the character 'a').
The example on the same page, however, says
SetCharacterWidth(0, 'a', 20); // Every 'a' is now 20 pixels wide.
where it clearly shows 'a' as a character and not an 'int'.
I've tried using the ascii number of 'a' (number 97):
void genericFunctionName()
{
int bg = LoadImage("bg.pcx");
int myFont = LoadImage("font.pcx");
EnableVariableWidth(myFont);
SetCharacterWidth(0, 97, 20); //set to 20 pixels wide, should show a wide 'a' character
string strn1;
string strn2;
while(num < 1000)
{
Render();
Blit(0,0,bg,screen);
strn1 = str(num); //counts up to 1000, then exits the loop
strn2 = "a"
PrintString(10, 195, screen, myFont, strn1);
PrintString(10, 205, screen, myFont, strn2);
ShowPage();
num++;
}
FreeImage(bg);
FreeFont(myFont);
}
and the 'a' was not affected whatsoever. Am I doing the code wrong or is there a way to change the font size (height and width) of the character before the Render()?
Posted on 2010-07-27 09:21:34
|
Overkill
|
I think I get what you're trying to do, but those functions won't do what you expect.
The EnableVariableWidth function makes it so each character width is reduced to the area in your font that isn't transparent. This has the effect of making the spacing between characters be reduced where possible, and that allows to the text to look more natural, rather than monospace like this... where every character takes up the same width .
SetCharacterWidth , should just set the width of spacing between a character manually. I admit, someone should have named this a bit nicer, since it has no effect on the actual width of the character, just how much "space" it occupies. The example for this is correct, at any rate. Character literals are ints in Verge (since it has no char type). Character literals and string literals are different, with characters using ' single quotes and being converted into a number representing its ASCII code, while strings use " double quotes. (To store a character from its integer code into a string, you use the chr(int character) function to convert it back, so 'A' == 65, and chr(65) or chr('A') are the same as the string "A").
I have a feeling that your font images are the actual problem. They are probably actually 12 pixels in size. Setting the "character width" of fonts will not stretch or shrink the font to a different size. This just used to determine how much horizontal space to occupy for a character (which affects where the next characters within the same PrintString appear). You won't see this at all if you draw one letter in a single PrintString , but if you print a word or sentence, you'll notice this effect.
These are pixel fonts, and can only be drawn at one size. To make smaller or larger fonts, you need to actually create or find new font images.
The other method around this is to not PrintString directly to the screen, but rather make an image with NewImage beforehand, draw the text at normal size onto that image, and then ScaleBlit or RotScale it afterwards.
Hope that helps.
Posted on 2010-07-29 16:05:39 (last edited on 2010-07-29 23:23:36)
|
KingOfTheNorth
|
I see.
I will keep that in mind in the future!
Posted on 2010-08-05 18:15:00
|
Displaying 1-3 of 3 total.
1
|
|