Font Pixelsize - Without counting?
Hey guys!
I'm currently working on a game, that involves ASCII Art. In the background I want to have my engine that does the math stuff: collisions, position changes etc. Of course, the images (texts) differ in size (not in font size: number of chars), but use the same font. Now I need to know how large a character is in pixels at a certain font size, so that I can define one constant to calculate with. I want to achieve that without counting the pixels manually on screen. Is there a formula or maybe information stored somewhere at the font data? Its Fixedsys. I haven't found anything on the net so far. Thanks in advance! |
lulz it depends on so many things, like whether the fonts are monospaced or not, and even then, what fonts you're using (Is it called Fixedsys?), and where... This has been an issue for me as well in programming. I don't believe the size of the characters is store anywhere, but we could say 12 point characters would be 8 pixels wide, since that is a power of 2 (don't ask why would that matter, I'm making educated guesses...). But that can only be applied to monospaced fonts, where every letter and character has the same width. The one I'm using right now is Times New Roman, where for example the letters I and O aren't equally wide. Courier New is an example of monospaced fonts, where I and O have the same width. Not sure if I understood your problem, but I tried to summarize my experiences.
|
I guess "Involving ASCII art" means "monospaced", am I correct?
Just a strong guess, but proportional fonts seem difficult to use with ASCII art... If you are using an IDE using the DTP point system (wild guess), then I think the font size will also depend on the screen's dpi value since a DTP point is measured in inch or mm, but not in pixels. Can you maybe give some more details about the programming environment and font you are using? Hope you keep us informed about your game and your progress with it. ;-) |
Thanks for your replies!
The font is called "Fixedsys", which is, indeed, 8x8 pixels in standard size (and also a quite common one in ASCII Art, because it is regular). I simply don't grasp the connection between font size and it's size in pixels. So font size 12 means 8x8 pixels; font size 24 equals 16x16? I don't think so... I'm using Blitz3D, because I was quite advanced with QuickBasic, which unfortunatly became obsolete, because it's for DOS. |
Quote:
Quote:
That font size refers to "typographic points". From http://en.wikipedia.org/wiki/Point_%28typography%29 (chapter "Current DTP point system"): "The desktop publishing point (DTP point) is defined as 1/72 of the Anglo-Saxon compromise inch of 1959 (25.4 mm) which makes it 0.0138 inch or 0.3527 mm. Twelve points make up a pica, and six picas make an inch." Long live the imperial units. :palm: As a result, that gives the real size of the font on the display - independent of its pixel density. |
Quote:
What lines do you mean? I don't quite get it! |
Quote:
Even if you know that the font is 8x8 pixels per letter - you still need to know the distance (in pixels) between two consecutive letters (horizontally) and the distance between two lines (vertically) in order to calculate the total height of some ASCII art comprising more than one column or row. If there would be no additional few pixels between two lines, the letters of them would "stick together". =>
|
The current time is 01:38 PM (GMT) |
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.