Beispiel #1
0
 public static extern int GetCodepointKernAdvance(
     FontInfo info,
     int ch1,
     int ch2);
Beispiel #2
0
 private static extern void GetFontVMetrics(
     ref FontInfo info,
     ref int ascent,
     ref int descent,
     ref int lineGap);
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 /// <param name="scale_x"></param>
 /// <param name="scale_y"></param>
 /// <param name="codepoint"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <param name="xoff"></param>
 /// <param name="yoff"></param>
 /// <returns></returns>
 /// <remarks>
 /// allocates a large-enough single-channel 8bpp bitmap and renders the
 /// specified character/glyph at the specified scale into it, with
 /// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque).
 /// *width &amp; *height are filled out with the width &amp; height of the bitmap,
 /// which is stored left-to-right, top-to-bottom.
 ///
 /// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
 ///</remarks>
 public static byte[] GetCodepointBitmap(
     FontInfo info,
     float scale_x,
     float scale_y,
     int codepoint,
     ref int width,
     ref int height,
     int?xoff,
     int?yoff)
 {
     //TODO: What if width and height can be null? There will be 6 combinations!
     byte[] result;
     if (xoff.HasValue && yoff.HasValue)
     {
         int xoffTmp = 0, yoffTmp = 0;
         var ptr = GetCodepointBitmap(ref info, scale_x, scale_y, codepoint,
                                      ref width, ref height,
                                      ref xoffTmp,
                                      ref yoffTmp);
         if (ptr == IntPtr.Zero)
         {
             throw new Exception("GetCodepointBitmap Failed");
         }
         else
         {
             result = new byte[width * height];
             Marshal.Copy(ptr, result, 0, result.Length);
         }
         xoff = xoffTmp;
         yoff = xoffTmp;
     }
     else if (xoff.HasValue)
     {
         int xoffTmp = 0;
         var ptr     = GetCodepointBitmap(ref info, scale_x, scale_y, codepoint,
                                          ref width, ref height,
                                          ref xoffTmp,
                                          IntPtr.Zero);
         if (ptr == IntPtr.Zero)
         {
             throw new Exception("GetCodepointBitmap Failed");
         }
         else
         {
             result = new byte[width * height];
             Marshal.Copy(ptr, result, 0, result.Length);
         }
         xoff = xoffTmp;
     }
     else if (yoff.HasValue)
     {
         int yoffTmp = 0;
         var ptr     = GetCodepointBitmap(ref info, scale_x, scale_y, codepoint,
                                          ref width, ref height,
                                          IntPtr.Zero,
                                          ref yoffTmp);
         if (ptr == IntPtr.Zero)
         {
             throw new Exception("GetCodepointBitmap Failed");
         }
         else
         {
             result = new byte[width * height];
             Marshal.Copy(ptr, result, 0, result.Length);
         }
         yoff = yoffTmp;
     }
     else
     {
         var ptr = GetCodepointBitmap(ref info, scale_x, scale_y, codepoint,
                                      ref width, ref height,
                                      IntPtr.Zero,
                                      IntPtr.Zero);
         if (ptr == IntPtr.Zero)
         {
             throw new Exception("GetCodepointBitmap Failed");
         }
         else
         {
             result = new byte[width * height];
             Marshal.Copy(ptr, result, 0, result.Length);
         }
     }
     return(result);
 }
Beispiel #4
0
 public static extern void GetCodepointHMetrics(
     FontInfo info,
     int codepoint,
     ref int advanceWidth,
     ref int leftSideBearing);
Beispiel #5
0
 public static extern int InitFont(
     ref FontInfo info,
     IntPtr data,
     int offset);