Is there a way to find the fonts names?
BlitzPlus Forums/BlitzPlus Programming/Is there a way to find the fonts names?
| ||
I am scanning the windows fonts folder then I randomly select a font there, but it isn’t working all the time because the correct way would be to give the font name to ‘LoadFont’… Is there a way to find the fonts names? RequestFont() is not an option since I am collecting every fonts in the win fonts folder… Thank you. |
| ||
I've had a brief look at doing this, and so far there are no easy answers. From the look of things, it would involve loading the font file into a bank and extracting the name and other data. The main problem comes from finding the format and coping with different ways of storing it. Code Project has a good article on the subject: Retrieving font name from TTF file. I'm taking another look to see what I can do, but no promises. |
| ||
Hey Phil, thanks! I found a way to avoid the problem, of course it’s not perfect since I lost a huge amount of possible fonts… Basically, in the random font select, I do: . ReselectFont … Randomselectcode… … If FontName$(fonttest) = "Arial" Then Goto ReselectFont End If If the loaded font isn’t good, it will reset to “Arial” so it gives me another chance to pick a new one, not perfect, but working :) |
| ||
I've managed to get a very rough version working. You pass the function a file name, and it will tell you what the font is called. Needs some cleaning up, but it's a start. I'll try and get it sorted by Friday :) |
| ||
waa, that s really cool ! Thanks :) |
| ||
Phew, done! It's not perfect, but it gets the job done. You can download it here: Blitz.FontApi. For some reason it doesn't like Arial, but all the other fonts I've tested work. To use it include "Blitz_Font_TTF.bb" and "Blitz_Basic_Endian.bb" (both are included in that archive). The following examples shows how to get the font name and copyright notice. ; Endian support Include "Blitz_Basic_Endian.bb" ; Load the font Local myFont.TTF = TTF_Load("C:/Windows/Fonts/Verdana.ttf") ; Print some details Print "This font's family is called: " + TTF_GetFontName(myFont) Print "Copyright: " + TTF_Name_GetProperty(myFont, TTF_NAME_ID_COPYRIGHT) ; Cleanup TTF_Dispose(myFont) Hope that helps! |
| ||
If that helps? It’s absolutely great!!! :) I will add you to the credits and Pongo too. That application is only for personal use in a first time, but I am thinking to turn it into commercial later, so if I do, I think about you guys, I think its normal, that kind of work, I couldn’t have done it myself! Basically, what I am doing in a mass website builder… My goal is to build 50 100 500 websites automatically… As far as now, you inject an item/products/whatever database, different themes, FTP User/pass, HTML templates…….. And the program will run until all websites are completed and uploaded. Everything is random, from the texts, to the html tables size, the colors, the size and shape of everything… Websites are all different… I got to that point already. For a week now, I’ve been coding the graphical creation to really be unique and that’s where you guys kick in. :) The font is randomly loaded to build a logo. Voila some explanations :) Cheers. |