Correct font size
-
I have a window that needs to display text using a fixed size (mono spaced) TT font (say Courier New) and the text will be limited to 80 columns by 24 rows. I need to calculate the bounding rect that keeps the aspect ratio of the font and centers it in the window. I can get all this to work fine. The next problem is choosing the font size. How do I get windows to give me a font size that will correctly fill this rect? Is this not possible? It seems no matter what I do, I get font sizes that do not scale up or down smoothly, and the text is usually either too small or too big. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
-
I have a window that needs to display text using a fixed size (mono spaced) TT font (say Courier New) and the text will be limited to 80 columns by 24 rows. I need to calculate the bounding rect that keeps the aspect ratio of the font and centers it in the window. I can get all this to work fine. The next problem is choosing the font size. How do I get windows to give me a font size that will correctly fill this rect? Is this not possible? It seems no matter what I do, I get font sizes that do not scale up or down smoothly, and the text is usually either too small or too big. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
The MidiPlyr PSDK sample has code which scales the timer text so it fills the window (not very well mind you). It's located in Samples/Multimedia/Audio/MidiPlyr/uiutils.c:EmbossedTextOut() and CreateScaledFont(). 80% chance that the scaled font feature (and all of uiutils.c) was created as an extra credit assignment. But anyway, the API to use is GetTextExtentPoint32. -- modified at 11:43 Thursday 9th March, 2006
-
The MidiPlyr PSDK sample has code which scales the timer text so it fills the window (not very well mind you). It's located in Samples/Multimedia/Audio/MidiPlyr/uiutils.c:EmbossedTextOut() and CreateScaledFont(). 80% chance that the scaled font feature (and all of uiutils.c) was created as an extra credit assignment. But anyway, the API to use is GetTextExtentPoint32. -- modified at 11:43 Thursday 9th March, 2006
Thanks. I know about GetTextExtentPoint32. Unfortunately the problem is getting windows to use a reasonable font size. It appears that windows only has a few font sizes, and there's no provision or way to smoothly scale up or down without jumps in sizes. This means that sometimes the font matches the rect just fine, others it's too small, and other times it's too big. I'll look into the example though! ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
-
I have a window that needs to display text using a fixed size (mono spaced) TT font (say Courier New) and the text will be limited to 80 columns by 24 rows. I need to calculate the bounding rect that keeps the aspect ratio of the font and centers it in the window. I can get all this to work fine. The next problem is choosing the font size. How do I get windows to give me a font size that will correctly fill this rect? Is this not possible? It seems no matter what I do, I get font sizes that do not scale up or down smoothly, and the text is usually either too small or too big. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
a little bit confused by ur post: every row must contain 80 characters or differnt (max is 80)? all rows use same font? "display" means by paint (CDC etc) or text control (CEdit etc)?
A nice tool for optimizing your Microsoft html-help contents. Includeh10
-
Thanks. I know about GetTextExtentPoint32. Unfortunately the problem is getting windows to use a reasonable font size. It appears that windows only has a few font sizes, and there's no provision or way to smoothly scale up or down without jumps in sizes. This means that sometimes the font matches the rect just fine, others it's too small, and other times it's too big. I'll look into the example though! ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
The MidiPlyr sample also has this problem. It doesn't fully scale to the window, hence the jumps in font size you see. So if Microsoft, for all their wealth, power and unrestricted access to the Windows source code, can't get it right, what hope do we poor insignificant developers who get the scrap heap public API, have :)?