-/* $Id$
- *
+/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/gdi32/object/font.c
if(count == -1) count = strlen(str);
lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0);
strW = HeapAlloc(GetProcessHeap(), 0, lenW*sizeof(WCHAR));
+ if (!strW)
+ return NULL;
MultiByteToWideChar(cp, 0, str, count, strW, lenW);
DPRINT("mapped %s -> %S\n", str, strW);
if(plenW) *plenW = lenW;
int i;
ENUMLOGFONTEXA EnumLogFontExA;
NEWTEXTMETRICEXA NewTextMetricExA;
+ LOGFONTW lfW;
Info = RtlAllocateHeap(GetProcessHeap(), 0,
INITIAL_FAMILY_COUNT * sizeof(FONTFAMILYINFO));
{
return 0;
}
+
+ if (!LogFont)
+ {
+ lfW.lfCharSet = DEFAULT_CHARSET;
+ lfW.lfPitchAndFamily = 0;
+ lfW.lfFaceName[0] = 0;
+ LogFont = &lfW;
+ }
+
FontFamilyCount = NtGdiGetFontFamilyInfo(Dc, LogFont, Info, INITIAL_FAMILY_COUNT);
if (FontFamilyCount < 0)
{
memcpy(&resultsW, lpResults, sizeof(resultsW));
lpStringW = FONT_mbtowc(hdc, lpString, uCount, &uCountW, &font_cp);
+ if (lpStringW == NULL)
+ {
+ return 0;
+ }
if(lpResults->lpOutString)
+ {
resultsW.lpOutString = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*uCountW);
+ if (resultsW.lpOutString == NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, lpStringW);
+ return 0;
+ }
+ }
ret = GetCharacterPlacementW(hdc, lpStringW, uCountW, nMaxExtent, &resultsW, dwFlags);
return 0;
}
- nSet = uCount;
+ nSet = uCount;
if ( nSet > lpResults->nGlyphs )
nSet = lpResults->nGlyphs;
iFirstChar,
(ULONG)(iLastChar - iFirstChar + 1),
(PWCHAR) NULL,
- 0,
+ 0,
(PVOID) pxBuffer);
}
wstr[0],
(ULONG) count,
(PWCHAR) wstr,
- GCW_NOFLOAT|GCW_WIN32,
+ GCW_NOFLOAT|GCW_WIN32,
(PVOID) lpBuffer);
HeapFree(GetProcessHeap(), 0, str);
return FALSE;
}
- ret = NtGdiGetCharABCWidthsW( hdc,
+ ret = NtGdiGetCharABCWidthsW( hdc,
wstr[0],
(ULONG)count,
(PWCHAR)wstr,
if ((Ret == ARABIC_CHARSET) || (Ret == HEBREW_CHARSET))
Ret = (GCP_KASHIDA|GCP_DIACRITIC|GCP_LIGATE|GCP_GLYPHSHAPE|GCP_REORDER);
}
- Gcp = GetDCDWord(hDc, GdiGetFontLanguageInfo, GCP_ERROR);
+ Gcp = GetDCDWord(hDc, GdiGetFontLanguageInfo, GCP_ERROR);
if ( Gcp == GCP_ERROR)
return Gcp;
else
INT countW;
lpstrW = FONT_mbtowc(hdc, lpstr, count, &countW, NULL);
+
+ if (lpstrW == NULL)
+ return GDI_ERROR;
+
Ret = NtGdiGetGlyphIndicesW(hdc, lpstrW, countW, pgi, flags);
HeapFree(GetProcessHeap(), 0, lpstrW);
return Ret;
if((ret = GetOutlineTextMetricsW(hdc, 0, NULL)) == 0)
return 0;
if(ret > sizeof(buf))
- lpOTMW = HeapAlloc(GetProcessHeap(), 0, ret);
+ {
+ lpOTMW = HeapAlloc(GetProcessHeap(), 0, ret);
+ if (lpOTMW == NULL)
+ {
+ return 0;
+ }
+ }
GetOutlineTextMetricsW(hdc, ret, lpOTMW);
needed = sizeof(OUTLINETEXTMETRICA);
DPRINT("needed = %d\n", needed);
if(needed > cbData)
+ {
/* Since the supplied buffer isn't big enough, we'll alloc one
that is and memcpy the first cbData bytes into the lpOTM at
the end. */
output = HeapAlloc(GetProcessHeap(), 0, needed);
+ if (output == NULL)
+ {
+ goto end;
+ }
+ }
ret = output->otmSize = min(needed, cbData);
FONT_TextMetricWToA( &lpOTMW->otmTextMetrics, &output->otmTextMetrics );
if (!cPairs && !kern_pairA) return total_kern_pairs;
kern_pairW = HeapAlloc(GetProcessHeap(), 0, total_kern_pairs * sizeof(*kern_pairW));
+ if (kern_pairW == NULL)
+ {
+ return 0;
+ }
GetKerningPairsW(hDC, total_kern_pairs, kern_pairW);
for (i = 0; i < total_kern_pairs; i++)
/*
* @implemented
*/
-DWORD
+LONG
WINAPI
GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height)
{
*
*/
/*
- * @unimplemented
+ * @implemented
*/
BOOL
WINAPI
int index = 0;
switch (flags) {
case TCI_SRCFONTSIG:
- while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
+ while (index < MAXTCIINDEX && !(*lpSrc>>index & 0x0001)) index++;
break;
case TCI_SRCCODEPAGE:
- while (PtrToUlong(lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
+ while (index < MAXTCIINDEX && PtrToUlong(lpSrc) != FONT_tci[index].ciACP) index++;
break;
case TCI_SRCCHARSET:
- while (PtrToUlong(lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
+ while (index < MAXTCIINDEX && PtrToUlong(lpSrc) != FONT_tci[index].ciCharset) index++;
break;
default:
return FALSE;