* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: text.c,v 1.121 2004/12/18 18:21:02 royce Exp $ */
+/* $Id: text.c,v 1.122 2004/12/18 21:35:35 royce Exp $ */
#include <w32k.h>
#include <ft2build.h>
ZwClose(hDirectory);
return;
}
-
+
FileName.Buffer = ExAllocatePool(PagedPool, MAX_PATH);
if (FileName.Buffer == NULL)
{
FT_Render_Mode FASTCALL
IntGetFontRenderMode(LOGFONTW *logfont)
-{
+{
switch(logfont->lfQuality)
{
//case ANTIALIASED_QUALITY:
PWSTR src;
NTSTATUS Status;
int Ret;
-
+
/* Copy the UNICODE_STRING structure */
Status = MmCopyFromCaller(&SafeFileName, Filename, sizeof(UNICODE_STRING));
if(!NT_SUCCESS(Status))
/* Reserve for prepending '\??\' */
SafeFileName.Length += 4 * sizeof(WCHAR);
SafeFileName.MaximumLength += 4 * sizeof(WCHAR);
-
+
src = SafeFileName.Buffer;
SafeFileName.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, SafeFileName.MaximumLength, TAG_STRING);
if(!SafeFileName.Buffer)
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
-
+
/* Prepend '\??\' */
RtlCopyMemory(SafeFileName.Buffer, L"\\??\\", 4 * sizeof(WCHAR));
SetLastNtError(Status);
return 0;
}
-
+
Ret = IntGdiAddFontResource(&SafeFileName, fl);
-
+
ExFreePool(SafeFileName.Buffer);
return Ret;
}
{
/* FIXME */
/* ASSERT(FALSE);*/
- Status = STATUS_INVALID_HANDLE;
+ Status = STATUS_INVALID_HANDLE;
}
}
else
TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
if (0 == TM->tmAveCharWidth)
{
- TM->tmAveCharWidth = 1;
+ TM->tmAveCharWidth = 1;
}
TM->tmMaxCharWidth = (FT_MulFix(FontGDI->face->bbox.xMax - FontGDI->face->bbox.xMin,
XScale) + 32) >> 6;
FontGDI = CurrentEntry->Font;
ASSERT(FontGDI);
-
+
RtlInitAnsiString(&EntryFaceNameA, FontGDI->face->family_name);
RtlAnsiStringToUnicodeString(&EntryFaceNameW, &EntryFaceNameA, TRUE);
if ((LF_FACESIZE - 1) * sizeof(WCHAR) < EntryFaceNameW.Length)
LOGFONTW *Lf;
TEXTMETRICW *TM;
NEWTEXTMETRICW *Ntm;
-
+
ZeroMemory(Info, sizeof(FONTFAMILYINFO));
Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
Otm = ExAllocatePoolWithTag(PagedPool, Size, TAG_GDITEXT);
if (0 == pOS2->version)
{
FT_UInt Dummy;
-
+
if (FT_Get_First_Char(FontGDI->face, &Dummy) < 0x100)
{
fs_fsCsb0 |= 1;
/* Enumerate font families in the process local list */
Win32Process = PsGetWin32Process();
IntLockProcessPrivateFonts(Win32Process);
- if (! GetFontFamilyInfoForList(&LogFont, Info, &Count, Size,
+ if (! GetFontFamilyInfoForList(&LogFont, Info, &Count, Size,
&Win32Process->PrivateFontListHead))
{
IntUnLockProcessPrivateFonts(Win32Process);
PFONTGDI FontGDI;
PTEXTOBJ TextObj = NULL;
PPALGDI PalDestGDI;
- XLATEOBJ *XlateObj, *XlateObj2;
+ XLATEOBJ *XlateObj=NULL, *XlateObj2=NULL;
ULONG Mode;
FT_Render_Mode RenderMode;
BOOLEAN Render;
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
-
+
if (NULL != UnsafeDx && Count > 0)
{
Dx = ExAllocatePoolWithTag(PagedPool, Count * sizeof(INT), TAG_GDITEXT);
goto fail;
}
}
-
+
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
if ( !BitmapObj )
+ {
goto fail;
+ }
SurfObj = &BitmapObj->SurfObj;
ASSERT(SurfObj);
/* Create the brushes */
PalDestGDI = PALETTE_LockPalette(dc->w.hPalette);
if ( !PalDestGDI )
- Mode = PAL_RGB;
+ Mode = PAL_RGB;
else
{
- Mode = PalDestGDI->Mode;
- PALETTE_UnlockPalette(dc->w.hPalette);
+ Mode = PalDestGDI->Mode;
+ PALETTE_UnlockPalette(dc->w.hPalette);
}
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
if ( !XlateObj )
+ {
goto fail;
+ }
hBrushFg = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.textColor));
if ( !hBrushFg )
+ {
goto fail;
+ }
BrushFg = BRUSHOBJ_LockBrush(hBrushFg);
if ( !BrushFg )
+ {
goto fail;
+ }
IntGdiInitBrushInstance(&BrushFgInst, BrushFg, NULL);
if ((fuOptions & ETO_OPAQUE) || dc->w.backgroundMode == OPAQUE)
{
hBrushBg = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.backgroundColor));
if ( !hBrushBg )
+ {
goto fail;
+ }
BrushBg = BRUSHOBJ_LockBrush(hBrushBg);
if ( !BrushBg )
+ {
goto fail;
+ }
IntGdiInitBrushInstance(&BrushBgInst, BrushBg, NULL);
}
XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, dc->w.hPalette);
if ( !XlateObj2 )
+ {
goto fail;
+ }
SourcePoint.x = 0;
SourcePoint.y = 0;
TextObj = TEXTOBJ_LockText(dc->w.hFont);
if(TextObj == NULL)
{
- goto fail;
+ goto fail;
}
FontObj = TextObj->Font;
}
}
if (!found)
+ {
DPRINT1("WARNING: Could not find desired charmap!\n");
+ }
IntLockFreeType;
error = FT_Set_Charmap(face, found);
IntUnLockFreeType;
if (error)
+ {
DPRINT1("WARNING: Could not set the charmap!\n");
+ }
}
Render = IntIsFontRenderingEnabled();
RenderMode = IntGetFontRenderMode(&TextObj->logfont);
else
RenderMode = FT_RENDER_MODE_MONO;
-
+
IntLockFreeType;
error = FT_Set_Pixel_Sizes(
face,
glyph_index = FT_Get_Char_Index(face, *TempText);
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
IntUnLockFreeType;
-
+
if (error)
{
DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
if (error)
{
- EngDeleteXlate(XlateObj);
- EngDeleteXlate(XlateObj2);
DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
goto fail;
}
IntUnLockFreeType;
if (error)
{
- EngDeleteXlate(XlateObj);
- EngDeleteXlate(XlateObj2);
DPRINT1("WARNING: Failed to render glyph!\n");
goto fail;
}
DestRect.right = DestRect.left + glyph->bitmap.width;
DestRect.top = TextTop + yoff - glyph->bitmap_top;
DestRect.bottom = DestRect.top + glyph->bitmap.rows;
-
+
bitSize.cx = glyph->bitmap.width;
bitSize.cy = glyph->bitmap.rows;
MaskRect.right = glyph->bitmap.width;
MaskRect.bottom = glyph->bitmap.rows;
-
+
/*
* We should create the bitmap out of the loop at the biggest possible
* glyph size. Then use memset with 0 to clear it and sourcerect to
HSourceGlyph = EngCreateBitmap(bitSize, pitch, (glyph->bitmap.pixel_mode == ft_pixel_mode_grays) ? BMF_8BPP : BMF_1BPP, BMF_TOPDOWN, glyph->bitmap.buffer);
if ( !HSourceGlyph )
{
- EngDeleteXlate(XlateObj);
- EngDeleteXlate(XlateObj2);
DPRINT1("WARNING: EngLockSurface() failed!\n");
goto fail;
}
if ( !SourceGlyphSurf )
{
EngDeleteSurface((HSURF)HSourceGlyph);
- EngDeleteXlate(XlateObj);
- EngDeleteXlate(XlateObj2);
DPRINT1("WARNING: EngLockSurface() failed!\n");
goto fail;
}
-
+
/*
* Use the font data as a mask to paint onto the DCs surface using a
* brush.
ExFreePool(Dx);
}
DC_UnlockDc( hDC );
-
+
return TRUE;
fail:
}
FontGDI = ObjToGDI(TextObj->Font, FONT);
-
+
face = FontGDI->face;
if (face->charmap == NULL)
{
SetLastWin32Error(STATUS_INVALID_PARAMETER);
return FALSE;
}
-
+
if(!(dc = DC_LockDc(hDC)))
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
Status = STATUS_INVALID_HANDLE;
}
DC_UnlockDc(hDC);
-
+
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
-
+
return TRUE;
}
SetLastWin32Error(ERROR_INVALID_HANDLE);
return GDI_ERROR;
}
-
+
FontGdi = ObjToGDI(TextObj->Font, FONT);
-
+
IntLockFreeType;
if (FT_IS_SFNT(FontGdi->face))
TEXTOBJ_UnlockText(hFont);
- return Result;
+ return Result;
}
static UINT FASTCALL
LONG WeightDiff;
NTSTATUS Status;
UINT Score = 1;
-
+
RtlInitAnsiString(&EntryFaceNameA, FontGDI->face->family_name);
Status = RtlAnsiStringToUnicodeString(&EntryFaceNameW, &EntryFaceNameA, TRUE);
if (NT_SUCCESS(Status))
SubstituteFontFamily(&FaceName, 0);
MatchScore = 0;
TextObj->Font = NULL;
-
+
/* First search private fonts */
Win32Process = PsGetWin32Process();
IntLockProcessPrivateFonts(Win32Process);
&TextObj->logfont, &FaceName,
&Win32Process->PrivateFontListHead);
IntUnLockProcessPrivateFonts(Win32Process);
-
+
/* Search system fonts */
IntLockGlobalFonts;
FindBestFontFromList(&TextObj->Font, &MatchScore,
RtlFreeUnicodeString(&FaceName);
TEXTOBJ_UnlockText(FontHandle);
-
+
ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->Font)) != 0);
return Status;