Font-Problem VC6.0 Windows
-
Hallo
In meiner Applikation sollte sich die Font-Größe aus der Auflösung und den eingestellen Zeilen/Spalten ergeben.
int main(int argc, char* argv[])
{
HFONT font;
LOGFONT myFont;
HDC testDC;
SIZE fontSize;
UINT i;
BOOL rc;testDC = CreateCompatibleDC(0);
memset(&myFont, 0, sizeof(myFont));
myFont.lfWeight = FW_MEDIUM;
myFont.lfCharSet = ANSI_CHARSET;
myFont.lfPitchAndFamily = FIXED_PITCH;
myFont.lfQuality = ANTIALIASED_QUALITY;
myFont.lfOutPrecision = OUT_RASTER_PRECIS;
strcpy(myFont.lfFaceName , "Courier New");for (i = 0; i < 10; i++) {
myFont.lfHeight = 20 + i;
myFont.lfWidth = 16;font = CreateFontIndirect(&myFont);
SelectObject(testDC, font);
rc = GetTextExtentPoint32(testDC, "X", 1, &fontSize);
if (rc == TRUE) {
dprintf("Font (%d/%d) -> (%d/%d)", myFont.lfWidth, myFont.lfHeight, fontSize.cx, fontSize.cy);
}
}DeleteDC(testDC);
return 0;
}Output:
Font (16/20) -> (15/20)
Font (16/21) -> (16/21)
Font (16/22) -> (16/22)
Font (16/23) -> (17/23)
Font (16/24) -> (17/24)
Font (16/25) -> (17/25)
Font (16/26) -> (16/25)
Font (16/27) -> (16/27)
Font (16/28) -> (16/27)
Font (16/29) -> (16/29)Wieso erhalte ich bei 16/24 einen Font mit einer Breite von 17? Dies darf nicht passieren, da der Text somit größer ist als der verfügbare Zeichenbereich. Bei 15/24 würde ich 16/24 erhalten - welche Logik steckt hier dahinter?
Danke!!!!
-
Vielleicht hilft dir das hier weiter:
-
Du kanst nur einen Wunsch an den Font-Mapper ausprechen was Du gerne hättest. Welcher physikalische Font am Ende rauskommt ist eine andere Sache.
Das ist so by design vor allem weil nicht alle Fonts frei skalierbar sind.
-
Danke für die Antworten
Beim "Courier New" handelt es sich meines Wissens um einen TrueTyp-Font und dieser solle doch eigentlich frei skalierbar sein. Verwendet ich z.B.: die Fonts ""DotumChe" o. "Lucida Console" ist dies der Fall. Wieso verhält sich "Courier New" anders?
Danke
-
Das garantiert dennoch nicht punkt genaues Mapping!
-
vielleicht steh ich gerade etwas auf der Leitung
Output "Courier New":
Font (16/10) -> (15/8)
Font (16/11) -> (13/8)
Font (16/12) -> (14/12)
Font (16/13) -> (14/12)
Font (16/14) -> (14/14)
Font (16/15) -> (14/15)
Font (16/16) -> (15/16)
Font (16/17) -> (15/17)
Font (16/18) -> (16/18)
Font (16/19) -> (15/18)
Font (16/20) -> (15/20)
Font (16/21) -> (16/21)
Font (16/22) -> (16/22)
Font (16/23) -> (17/23)
Font (16/24) -> (17/24)
Font (16/25) -> (17/25)
Font (16/26) -> (16/25)
Font (16/27) -> (16/27)
Font (16/28) -> (16/27)
Font (16/29) -> (16/29)Output "DotumChe" and "Lucida Console":
Font (16/10) -> (16/10)
Font (16/11) -> (16/11)
Font (16/12) -> (16/12)
Font (16/13) -> (16/13)
Font (16/14) -> (16/14)
Font (16/15) -> (16/15)
Font (16/16) -> (16/16)
Font (16/17) -> (16/17)
Font (16/18) -> (16/18)
Font (16/19) -> (16/19)
Font (16/20) -> (16/20)
Font (16/21) -> (16/21)
Font (16/22) -> (16/22)
Font (16/23) -> (16/23)
Font (16/24) -> (16/24)
Font (16/25) -> (16/25)
Font (16/26) -> (16/26)
Font (16/27) -> (16/27)
Font (16/28) -> (16/28)
Font (16/29) -> (16/29)Hab da jetzt schon etwas nachgelesen - eigentlich sollten sich die Vector-Fonts frei skalieren lassen, aber "Courier New" verhält sich anders zu den getesten Fonts. Ich versteh den Unterschied nicht - wieso lassen sich die anderen frei skalieren, nur diese nicht?
Sorry wenn ich hier auf der Leitung stehe bzw. lästig bin!!!!
-
Das Problem scheint sich durch "Font Hinting" erklären zu lassen
Danke an alle