Fix a cut & paste error.
[reactos.git] / reactos / subsys / win32k / objects / text.c
index 8c4e739..89589ea 100644 (file)
@@ -189,7 +189,7 @@ IntLoadSystemFonts(VOID)
          return;
       }
 
-      FileName.Buffer = ExAllocatePool(PagedPool, MAX_PATH);
+      FileName.Buffer = ExAllocatePool(PagedPool, MAX_PATH * sizeof(WCHAR));
       if (FileName.Buffer == NULL)
       {
          ExFreePool(DirInfoBuffer);
@@ -197,7 +197,7 @@ IntLoadSystemFonts(VOID)
          return;
       }
       FileName.Length = 0;
-      FileName.MaximumLength = MAX_PATH;
+      FileName.MaximumLength = MAX_PATH * sizeof(WCHAR);
 
       while (1)
       {
@@ -255,7 +255,6 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
    NTSTATUS Status;
    HANDLE FileHandle;
    OBJECT_ATTRIBUTES ObjectAttributes;
-   FILE_STANDARD_INFORMATION FileStdInfo;
    PVOID Buffer = NULL;
    IO_STATUS_BLOCK Iosb;
    INT Error;
@@ -305,7 +304,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
    Error = FT_New_Memory_Face(
       library,
       Buffer,
-      FileStdInfo.EndOfFile.u.LowPart,
+      ViewSize,
       0,
       &Face);
    IntUnLockFreeType;
@@ -1459,7 +1458,7 @@ NtGdiExtTextOut(
    FT_Face face;
    FT_GlyphSlot glyph;
    LONGLONG TextLeft, RealXStart;
-   ULONG TextTop, pitch, previous, BackgroundLeft;
+   ULONG TextTop, previous, BackgroundLeft;
    FT_Bool use_kerning;
    RECTL DestRect, MaskRect, SpecifiedDestRect;
    POINTL SourcePoint, BrushOrigin;
@@ -1527,7 +1526,7 @@ NtGdiExtTextOut(
       }
    }
 
-   BitmapObj = BITMAPOBJ_LockBitmap(DC_BITMAP(dc));
+   BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
    if ( !BitmapObj )
    {
       goto fail;
@@ -1542,7 +1541,7 @@ NtGdiExtTextOut(
    YStart = Start.y + dc->w.DCOrgY;
 
    /* Create the brushes */
-   PalDestGDI = PALETTE_LockPalette(DC_PALETTE(dc));
+   PalDestGDI = PALETTE_LockPalette(dc->w.hPalette);
    if ( !PalDestGDI )
       Mode = PAL_RGB;
    else
@@ -1550,12 +1549,12 @@ NtGdiExtTextOut(
       Mode = PalDestGDI->Mode;
       PALETTE_UnlockPalette(PalDestGDI);
    }
-   XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, DC_PALETTE(dc), NULL);
+   XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
    if ( !XlateObj )
    {
       goto fail;
    }
-   hBrushFg = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.textColor));
+   hBrushFg = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.textColor), 0);
    if ( !hBrushFg )
    {
       goto fail;
@@ -1568,7 +1567,7 @@ NtGdiExtTextOut(
    IntGdiInitBrushInstance(&BrushFgInst, BrushFg, NULL);
    if ((fuOptions & ETO_OPAQUE) || dc->w.backgroundMode == OPAQUE)
    {
-      hBrushBg = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.backgroundColor));
+      hBrushBg = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.backgroundColor), 0);
       if ( !hBrushBg )
       {
          goto fail;
@@ -1580,7 +1579,7 @@ NtGdiExtTextOut(
       }
       IntGdiInitBrushInstance(&BrushBgInst, BrushBg, NULL);
    }
-   XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, DC_PALETTE(dc));
+   XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, dc->w.hPalette);
    if ( !XlateObj2 )
    {
       goto fail;
@@ -1599,6 +1598,7 @@ NtGdiExtTextOut(
       DestRect.top    = SpecifiedDestRect.top    + dc->w.DCOrgY;
       DestRect.right  = SpecifiedDestRect.right  + dc->w.DCOrgX;
       DestRect.bottom = SpecifiedDestRect.bottom + dc->w.DCOrgY;
+      IntLPtoDP(dc, (LPPOINT)&DestRect, 2);
       IntEngBitBlt(
          &BitmapObj->SurfObj,
          NULL,
@@ -1632,6 +1632,7 @@ NtGdiExtTextOut(
    FontGDI = ObjToGDI(FontObj, FONT);
    ASSERT(FontGDI);
 
+   IntLockFreeType;
    face = FontGDI->face;
    if (face->charmap == NULL)
    {
@@ -1652,10 +1653,8 @@ NtGdiExtTextOut(
       {
          DPRINT1("WARNING: Could not find desired charmap!\n");
       }
-      IntLockFreeType;
       error = FT_Set_Charmap(face, found);
-      IntUnLockFreeType;
-      if (error)
+         if (error)
       {
          DPRINT1("WARNING: Could not set the charmap!\n");
       }
@@ -1667,7 +1666,6 @@ NtGdiExtTextOut(
    else
       RenderMode = FT_RENDER_MODE_MONO;
 
-   IntLockFreeType;
    error = FT_Set_Pixel_Sizes(
       face,
       TextObj->logfont.lfWidth,
@@ -1675,10 +1673,10 @@ NtGdiExtTextOut(
       (TextObj->logfont.lfHeight < 0 ?
       - TextObj->logfont.lfHeight :
       TextObj->logfont.lfHeight == 0 ? 11 : TextObj->logfont.lfHeight));
-   IntUnLockFreeType;
    if (error)
    {
       DPRINT1("Error in setting pixel sizes: %u\n", error);
+      IntUnLockFreeType;
       goto fail;
    }
 
@@ -1723,10 +1721,8 @@ NtGdiExtTextOut(
 
       for (i = Start; i < Count; i++)
       {
-         IntLockFreeType;
          glyph_index = FT_Get_Char_Index(face, *TempText);
          error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
-         IntUnLockFreeType;
 
          if (error)
          {
@@ -1739,9 +1735,7 @@ NtGdiExtTextOut(
          if (use_kerning && previous && glyph_index)
          {
             FT_Vector delta;
-            IntLockFreeType;
             FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
-            IntUnLockFreeType;
             TextWidth += delta.x;
          }
 
@@ -1773,14 +1767,13 @@ NtGdiExtTextOut(
 
    for (i = 0; i < Count; i++)
    {
-      IntLockFreeType;
       glyph_index = FT_Get_Char_Index(face, *String);
       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);
+        IntUnLockFreeType;
          goto fail;
       }
 
@@ -1790,25 +1783,18 @@ NtGdiExtTextOut(
       if (use_kerning && previous && glyph_index && NULL == Dx)
       {
          FT_Vector delta;
-         IntLockFreeType;
          FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
-         IntUnLockFreeType;
          TextLeft += delta.x;
       }
 
       if (glyph->format == ft_glyph_format_outline)
       {
-         IntLockFreeType;
          error = FT_Render_Glyph(glyph, RenderMode);
-         IntUnLockFreeType;
          if (error)
          {
             DPRINT1("WARNING: Failed to render glyph!\n");
             goto fail;
          }
-         pitch = glyph->bitmap.pitch;
-      } else {
-         pitch = glyph->bitmap.width;
       }
 
       if (fuOptions & ETO_OPAQUE)
@@ -1846,12 +1832,21 @@ NtGdiExtTextOut(
        * 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
        * limit the work of the transbitblt.
+       *
+       * FIXME: DIB bitmaps should have an lDelta which is a multiple of 4.
+       * Here we pass in the pitch from the FreeType bitmap, which is not
+       * guaranteed to be a multiple of 4. If it's not, we should expand
+       * the FreeType bitmap to a temporary bitmap.
        */
 
-      HSourceGlyph = EngCreateBitmap(bitSize, pitch, (glyph->bitmap.pixel_mode == ft_pixel_mode_grays) ? BMF_8BPP : BMF_1BPP, BMF_TOPDOWN, glyph->bitmap.buffer);
+      HSourceGlyph = EngCreateBitmap(bitSize, glyph->bitmap.pitch,
+                                     (glyph->bitmap.pixel_mode == ft_pixel_mode_grays) ?
+                                     BMF_8BPP : BMF_1BPP, BMF_TOPDOWN,
+                                     glyph->bitmap.buffer);
       if ( !HSourceGlyph )
       {
         DPRINT1("WARNING: EngLockSurface() failed!\n");
+       IntUnLockFreeType;
         goto fail;
       }
       SourceGlyphSurf = EngLockSurface((HSURF)HSourceGlyph);
@@ -1859,6 +1854,7 @@ NtGdiExtTextOut(
       {
         EngDeleteSurface((HSURF)HSourceGlyph);
         DPRINT1("WARNING: EngLockSurface() failed!\n");
+       IntUnLockFreeType;
         goto fail;
       }
 
@@ -1911,6 +1907,8 @@ NtGdiExtTextOut(
       String++;
    }
 
+   IntUnLockFreeType;
+
    EngDeleteXlate(XlateObj);
    EngDeleteXlate(XlateObj2);
    BITMAPOBJ_UnlockBitmap(BitmapObj);
@@ -2118,15 +2116,17 @@ NtGdiGetFontLanguageInfo(HDC  hDC)
   return 0;
 }
 
-DWORD
-STDCALL
-NtGdiGetGlyphOutline(HDC  hDC,
-                           UINT  Char,
-                           UINT  Format,
-                           LPGLYPHMETRICS  gm,
-                           DWORD  Bufsize,
-                           LPVOID  Buffer,
-                           CONST LPMAT2 mat2)
+ULONG
+APIENTRY
+NtGdiGetGlyphOutline(
+    IN HDC hdc,
+    IN WCHAR wch,
+    IN UINT iFormat,
+    OUT LPGLYPHMETRICS pgm,
+    IN ULONG cjBuf,
+    OUT OPTIONAL PVOID pvBuf,
+    IN LPMAT2 pmat2,
+    IN BOOL bIgnoreRotation)
 {
   UNIMPLEMENTED;
   return 0;
@@ -2153,9 +2153,10 @@ NtGdiGetOutlineTextMetrics(HDC  hDC,
 }
 
 BOOL
-STDCALL
-NtGdiGetRasterizerCaps(LPRASTERIZER_STATUS  rs,
-                            UINT  Size)
+APIENTRY
+NtGdiGetRasterizerCaps(
+    OUT LPRASTERIZER_STATUS praststat,
+    IN ULONG cjBytes)
 {
   UNIMPLEMENTED;
   return FALSE;
@@ -2169,11 +2170,12 @@ NtGdiGetTextCharset(HDC  hDC)
   return 0;
 }
 
-UINT
-STDCALL
-NtGdiGetTextCharsetInfo(HDC  hDC,
-                             LPFONTSIGNATURE  Sig,
-                             DWORD  Flags)
+INT
+APIENTRY
+NtGdiGetTextCharsetInfo(
+    IN HDC hdc,
+    OUT OPTIONAL LPFONTSIGNATURE lpSig,
+    IN DWORD dwFlags)
 {
   UNIMPLEMENTED;
   return 0;
@@ -2854,7 +2856,7 @@ GetFontScore(LOGFONTW *LogFont, PUNICODE_STRING FaceName, PFONTGDI FontGDI)
   return Score;
 }
 
-static inline VOID
+static __inline VOID
 FindBestFontFromList(FONTOBJ **FontObj, UINT *MatchScore, LOGFONTW *LogFont,
                      PUNICODE_STRING FaceName, PLIST_ENTRY Head)
 {
@@ -2881,7 +2883,7 @@ FindBestFontFromList(FONTOBJ **FontObj, UINT *MatchScore, LOGFONTW *LogFont,
     }
 }
 
-static inline BOOLEAN
+static __inline BOOLEAN
 SubstituteFontFamilyKey(PUNICODE_STRING FaceName,
                         LPCWSTR Key)
 {
@@ -2917,7 +2919,7 @@ SubstituteFontFamilyKey(PUNICODE_STRING FaceName,
   return NT_SUCCESS(Status);
 }
 
-static inline void
+static __inline void
 SubstituteFontFamily(PUNICODE_STRING FaceName, UINT Level)
 {
   if (10 < Level) /* Enough is enough */