PDA

View Full Version : How can I improve GDI accuracy to expand/condense fonts?


guillep2k
27th March 2002, 15:15
Hi!

I'm trying to render fonts over a memory bitmap (not to be show on the screen) to be used for DVD subpictures. DVD subpictures are usually 720x480, but are supposed to display in a 4:3 aspect ratio, so I must expand fonts horizontally by 12.5% when using a 1:1 memory device context. My problems are two, as follows:

1) The main problem is the accuracy of the LOGFONT structure. Since I'm typically using -22 as the tmHeight, I'm obtaining AveCharWidths of about 12. A 12.5% increase should give me a new width of 13.5, but since tmWidth is integer, I can only use a value of 13 or 14, which gives me a bad aspect ratio correction. Is there a way of using more precise values (a smaller scale, like tenths of a logical unit) in the LOGFONT structure? I cannot use larger fonts, because then I would have to downscale the resulting bitmaps with a considerable loss of quality (I cannot use anti-alias since the targer is monochrome).

2) I'm using the CreateCompatibleDC function to get a DC to work with, but I have no warranty that the screen DC will give me square (1:1) pixels. How can I get a working DC with the desired pixel shape (aspect ratio)? (If I can do this, point 1 would be covered too).

Thanks in advance,
Guille

maven
28th March 2002, 11:28
render onto an offscreen bitmap and stretch (BitBlt?) when putting them on the screen...

guillep2k
28th March 2002, 14:33
Well... thanks for your hint, but that's exactly what I should avoid because most of the font hints would be destroyed (I can't perform anti-alias!). However, I found a way:

mdc->SetMapMode( MM_ANISOTROPIC );
mdc->SetWindowExt( 64, 64 );
mdc->SetViewportExt( 1, 1 );

This way I can use font sizes 64 times larger, which gives me enough accuracy when changing the font width. However, this method produced silghtly (but very noriceable) different rendering results... font widths and heights were different for about one pixel, and I wonder why (as if the roundings where different). I'm worried about loosing quality by using this method.

Guille