Does anyone have an example of a "specifically formatted image" that the newImageFont() function takes? Seeing one would save me time of trying to figure it out on my own from the source. A high-level explanation would help too.
What does this thing eat?
Examples of newImageFont usage?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Examples of newImageFont usage?
EDIT: Original message removed. I fixed the problem.
The image in the Wiki is not PoT, so it displays white rectangles instead of the letter glyphs on my usual test machine. I have attached a fixed png image to this post and a simple test program to try it. When making the image PoT, I also fixed the little problem with the 4 glyph. Look at the image for four in the original image and contrast with this to see the little slip somebody made with the original image. (It isn't exactly serious.. but anyway.)
Somebody could update the Wiki one day perhaps? I won't do it, because I didn't make that page.
That's the program, with the most attractive shade of blue ever discovered by a human being. Look at it. Look!
EDIT: See my posting below for a better image and explanation of a slight problem with this.
The image in the Wiki is not PoT, so it displays white rectangles instead of the letter glyphs on my usual test machine. I have attached a fixed png image to this post and a simple test program to try it. When making the image PoT, I also fixed the little problem with the 4 glyph. Look at the image for four in the original image and contrast with this to see the little slip somebody made with the original image. (It isn't exactly serious.. but anyway.)
Somebody could update the Wiki one day perhaps? I won't do it, because I didn't make that page.
Code: Select all
ont = love.graphics.newImageFont("imagefont.png",
" abcdefghijklmnopqrstuvwxyz" ..
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
"123456789.,!?-+/():;%&`'*#=[]\"")
love.graphics.setFont(font)
love.graphics.setBackgroundColor(0x55,0x66,0xff)
function love.draw()
love.graphics.print(
"abcdefghijklmnopqrstuvwxyz\n" ..
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\n" ..
"0123456789.,!?-+/():;%&`'*\n" ..
"#=[]\"", 30, 30)
end
EDIT: See my posting below for a better image and explanation of a slight problem with this.
Last edited by pekka on Sun Sep 05, 2010 5:21 am, edited 1 time in total.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Examples of newImageFont usage?
Good work!
Worst reason not to update a wiki ever. XDpekka wrote:Somebody could update the Wiki one day perhaps? I won't do it, because I didn't make that page.
Help us help you: attach a .love.
Re: Examples of newImageFont usage?
I ended up reading the source code anyway, and trying various tests. During this testing I found two little features, that will soon find their way to the bug tracker.
I also found that you need only to mark the top line of the image with the spacer color. It will be ignored elsewhere. Even though there is a loop that is supposed to go thru the image and change the spacer color to completely transparent, it does not actually work. (This is one of the features I discovered.) This means you will see some residue of the spacer color at the edge of your bitmaps when you scale imagefont text to a larger size. This makes it actually preferable to only mark the upper row, so you get fewer stained pixels.
You can try this code with the original image and you should see little bars of yellowish color at each glyph's left and right sides. I did see that on my computer. The image below does not have so much yellow, so there will not be so obvious staining.
In the new image there is no huge swath of yellow at the right hand side, because it affects the spacing of the last glyph. You normally want to leave a little unused space on the right, so the last spacer before it determines the length of the spacing for the last actual glyph. If you don't leave a space, then the spacing apparently becomes zero.
I'll look at writing more about this up at the Wiki some day. I just started a page now with a quick draft.
I also found that you need only to mark the top line of the image with the spacer color. It will be ignored elsewhere. Even though there is a loop that is supposed to go thru the image and change the spacer color to completely transparent, it does not actually work. (This is one of the features I discovered.) This means you will see some residue of the spacer color at the edge of your bitmaps when you scale imagefont text to a larger size. This makes it actually preferable to only mark the upper row, so you get fewer stained pixels.
You can try this code with the original image and you should see little bars of yellowish color at each glyph's left and right sides. I did see that on my computer. The image below does not have so much yellow, so there will not be so obvious staining.
Code: Select all
font = love.graphics.newImageFont("imagefont.png",
" abcdefghijklmnopqrstuvwxyz" ..
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
"123456789.,!?-+/():;%&`'*#=[]\"")
love.graphics.setFont(font)
love.graphics.setBackgroundColor(0x55,0x66,0xff)
function love.draw()
love.graphics.scale(2)
love.graphics.print(
"abcdefghijklmnopqrstuvwxyz\n" ..
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\n" ..
"0123456789.,!?-+/():;%&`'*\n" ..
"#=[]\"\"", 30, 30)
end
I'll look at writing more about this up at the Wiki some day. I just started a page now with a quick draft.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Examples of newImageFont usage?
Since fonts were almost entirely rewritten, is this still the case?
Re: Examples of newImageFont usage?
I was talking about version 0.6.2. I'll just stop. This shit is getting ridiculous.
Who is online
Users browsing this forum: No registered users and 68 guests