PDA

View Full Version : How does IDA determine MONOSPACED fonts?


Aimless
June 7th, 2009, 07:31
Well,

I admit. Its a catchy topic. The aforesaid is not limited only to IDA, but other applications as well, specifically, programming editors.

Here is what happens: You install a brand new, shiny editor and then select the font in which you want to program (heck, it could easily be font selection in IDA). And voila! All fonts are listed. All fonts that are MONOSPACED, that is!!

Amazing. How does IDA (or any other programmer editor) determine that this is a MONOSPACED font as opposed to a PROPORTIONAL font? (MONOSPACED = courier, consolas, andale mono, etc. PROPORTIONAL = times roman, caslon, century, nimrod, etc.)

Obviously now, if I add another font to my C:\windows\fonts directory AND if its a MONOSPACED font, IDA (or the editors for that matter) pick it up automatically! That implies that the FONT itself must be telling the program (much like a PE is EXE or DLL flag) that it is either MONOSPACED or PROPORTIONAL. Question is, where? Plus there is the issue of OTF v/s TTF fonts. So I searched Google and came up with nothing but noise!

So, is there a kind soul who has a readymade TTF or OTF file format structure ready (or can point me in the correct direction)? I'd be so happy!

In case you are wondering why, let me tell you that I am doing this for the absolutely useless purpose of trying to see what my disassembly looks like (i know, I can do it in an editor but that's missing the point) in, say, Times in IDA window.

Have Phun

Iwarez
June 7th, 2009, 07:51
Hi Aimless,

If you look at the LOGFONT structure you will see a member called lfPitchAndFamily. You can use that to determine that it is a monospace font. You can use it in combination with EnumFonts for example to get a list of monotype fonts.

See also http://msdn.microsoft.com/en-us/library/dd145037(VS.85).aspx

IW

Aimless
June 7th, 2009, 11:47
You da man!



Have Phun

Woodmann
June 8th, 2009, 20:46
I love happy endings to benign questions .

Nice to know I am not the only other person who wonders these things.

Woodmann

Iwarez
June 9th, 2009, 15:37
Hey Woodmann, not only do I wonder, I also seek the answer to the question! :P I believe however it's more a case of having it encountered before and being able to recall the answer.