Index: win32ss/gdi/ntgdi/freetype.c =================================================================== --- win32ss/gdi/ntgdi/freetype.c (revision 74612) +++ win32ss/gdi/ntgdi/freetype.c (working copy) @@ -2323,47 +2323,23 @@ if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR)) Info->FontType |= RASTER_FONTTYPE; - ExFreePoolWithTag(Otm, GDITAG_TEXT); /* face name */ - if (FaceName) - { - RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName); - } - else - { - status = IntGetFontLocalizedName(&NameW, SharedFace, TT_NAME_ID_FONT_FAMILY, - gusLanguageID); - if (NT_SUCCESS(status)) - { - /* store it */ - RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), - NameW.Buffer); - RtlFreeUnicodeString(&NameW); - } - } + if (!FaceName) + FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName); + RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName); + /* full name */ - if (FullName) - { - RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName, - sizeof(Info->EnumLogFontEx.elfFullName), - FullName); - } - else - { - status = IntGetFontLocalizedName(&NameW, SharedFace, TT_NAME_ID_FULL_NAME, - gusLanguageID); - if (NT_SUCCESS(status)) - { - /* store it */ - RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName, - sizeof(Info->EnumLogFontEx.elfFullName), - NameW.Buffer); - RtlFreeUnicodeString(&NameW); - } - } + if (!FullName) + FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName); + + RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName, + sizeof(Info->EnumLogFontEx.elfFullName), + FullName); + ExFreePoolWithTag(Otm, GDITAG_TEXT); + RtlInitAnsiString(&StyleA, Face->style_name); StyleW.Buffer = Info->EnumLogFontEx.elfStyle; StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle); @@ -4060,11 +4036,8 @@ GetFontPenalty(LOGFONTW * LogFont, PUNICODE_STRING RequestedNameW, PUNICODE_STRING ActualNameW, - PUNICODE_STRING FullFaceNameW, BYTE RequestedCharSet, - PFONTGDI FontGDI, OUTLINETEXTMETRICW * Otm, - TEXTMETRICW * TM, const char * style_name) { ULONG Penalty = 0; @@ -4072,7 +4045,7 @@ LONG Long; BOOL fFixedSys = FALSE, fNeedScaling = FALSE; const BYTE UserCharSet = CharSetFromLangID(gusLanguageID); - NTSTATUS Status; + TEXTMETRICW * TM = &Otm->otmTextMetrics; /* FIXME: Aspect Penalty 30 */ /* FIXME: IntSizeSynth Penalty 20 */ @@ -4209,51 +4182,19 @@ if (RequestedNameW->Buffer[0]) { BOOL Found = FALSE; - PSHARED_FACE SharedFace = FontGDI->SharedFace; /* localized family name */ if (!Found) { - Status = IntGetFontLocalizedName(ActualNameW, SharedFace, TT_NAME_ID_FONT_FAMILY, - gusLanguageID); - if (NT_SUCCESS(Status)) - { - Found = RtlEqualUnicodeString(RequestedNameW, ActualNameW, TRUE); - } + RtlInitUnicodeString(ActualNameW, (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName)); + Found = RtlEqualUnicodeString(RequestedNameW, ActualNameW, TRUE); } /* localized full name */ if (!Found) { - Status = IntGetFontLocalizedName(ActualNameW, SharedFace, TT_NAME_ID_FULL_NAME, - gusLanguageID); - if (NT_SUCCESS(Status)) - { - Found = RtlEqualUnicodeString(RequestedNameW, ActualNameW, TRUE); - } + RtlInitUnicodeString(ActualNameW, (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFaceName)); + Found = RtlEqualUnicodeString(RequestedNameW, ActualNameW, TRUE); } - if (gusLanguageID != gusEnglishUS) - { - /* English family name */ - if (!Found) - { - Status = IntGetFontLocalizedName(ActualNameW, SharedFace, TT_NAME_ID_FONT_FAMILY, - gusEnglishUS); - if (NT_SUCCESS(Status)) - { - Found = RtlEqualUnicodeString(RequestedNameW, ActualNameW, TRUE); - } - } - /* English full name */ - if (!Found) - { - Status = IntGetFontLocalizedName(ActualNameW, SharedFace, TT_NAME_ID_FULL_NAME, - gusEnglishUS); - if (NT_SUCCESS(Status)) - { - Found = RtlEqualUnicodeString(RequestedNameW, ActualNameW, TRUE); - } - } - } if (!Found) { /* FaceName Penalty 10000 */ @@ -4466,17 +4407,13 @@ PLIST_ENTRY Head) { ULONG Penalty; - NTSTATUS Status; PLIST_ENTRY Entry; PFONT_ENTRY CurrentEntry; FONTGDI *FontGDI; - ANSI_STRING ActualNameA; - UNICODE_STRING ActualNameW, FullFaceNameW; + UNICODE_STRING ActualNameW; OUTLINETEXTMETRICW *Otm = NULL; UINT OtmSize, OldOtmSize = 0; - TEXTMETRICW *TM; FT_Face Face; - LPBYTE pb; ASSERT(FontObj); ASSERT(MatchPenalty); @@ -4484,6 +4421,10 @@ ASSERT(pRequestedNameW); ASSERT(Head); + /* Start with a pretty big buffer */ + OldOtmSize = 2 * sizeof(OUTLINETEXTMETRICW); + Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT); + /* get the FontObj of lowest penalty */ Entry = Head->Flink; while (Entry != Head) @@ -4495,14 +4436,6 @@ ASSERT(FontGDI); Face = FontGDI->SharedFace->Face; - /* create actual name */ - RtlInitAnsiString(&ActualNameA, Face->family_name); - Status = RtlAnsiStringToUnicodeString(&ActualNameW, &ActualNameA, TRUE); - if (!NT_SUCCESS(Status)) - { - continue; - } - /* get text metrics */ OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL); if (OtmSize > OldOtmSize) @@ -4516,25 +4449,13 @@ if (Otm) { IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm); - TM = &Otm->otmTextMetrics; OldOtmSize = OtmSize; - /* create full name */ - pb = (LPBYTE)Otm + (WORD)(DWORD_PTR)Otm->otmpFullName; - Status = RtlCreateUnicodeString(&FullFaceNameW, (LPWSTR)pb); - if (!NT_SUCCESS(Status)) - { - RtlFreeUnicodeString(&ActualNameW); - RtlFreeUnicodeString(&FullFaceNameW); - continue; - } - Penalty = GetFontPenalty(LogFont, pRequestedNameW, &ActualNameW, - &FullFaceNameW, RequestedCharSet, - FontGDI, Otm, TM, Face->style_name); + RequestedCharSet, + Otm, Face->style_name); if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty) { - DPRINT("%ls Penalty: %lu\n", FullFaceNameW.Buffer, Penalty); RtlFreeUnicodeString(pActualNameW); RtlCreateUnicodeString(pActualNameW, ActualNameW.Buffer); @@ -4541,12 +4462,7 @@ *FontObj = GDIToObj(FontGDI, FONT); *MatchPenalty = Penalty; } - - RtlFreeUnicodeString(&FullFaceNameW); } - - /* free strings */ - RtlFreeUnicodeString(&ActualNameW); } if (Otm)