freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [ft-devel] What is FT_Library?


From: Allan Yang, Jian Hua - SH
Subject: RE: [ft-devel] What is FT_Library?
Date: Thu, 29 Nov 2007 10:20:37 +0800

And the snippet from the C# source files as below:

-- FreeType.cs --

using System;
using System.Runtime.InteropServices;

namespace FreeTypeWrap
{

        public enum FT_LOAD_TYPES
        {
                FT_LOAD_DEFAULT = 0,
                FT_LOAD_NO_SCALE = 1
        }
        
        public enum FT_RENDER_MODES
        {
                FT_RENDER_MODE_NORMAL = 0,
                FT_RENDER_MODE_LIGHT = 1                                
        }

        [StructLayout (LayoutKind.Sequential)]
        public class Library {
                public System.IntPtr    memory;
                public Generic                  generic;
                public int                              major;
                public int                              minor;
                public int                              patch;
                public uint                             modules;
                public System.IntPtr    module0, module1, module2, module3, 
module4, module5, module6, module7, module8, module9, module10;
                public System.IntPtr    module11, module12, module13, module14, 
module15, module16, module17, module18, module19, module20;
                public System.IntPtr    module21, module22, module23, module24, 
module25, module26, module27, module28, module29, module30;
                public System.IntPtr    module31;
                public ListRec                  renderers;
                public System.IntPtr    renderer;
                public System.IntPtr    auto_hinter;
                public System.IntPtr    raster_pool;
                public long                             raster_pool_size;
                public System.IntPtr    debug0, debug1, debug2, debug3;         
                [DllImport ("freetype.dll")]
                public static extern int FT_Init_FreeType( out System.IntPtr 
lib );
                [DllImport ("freetype.dll")]
                public static extern void FT_Done_FreeType( System.IntPtr lib );
        }

        [StructLayout (LayoutKind.Sequential)]
        public class Generic {
                public System.IntPtr    data;
                public System.IntPtr    finalizer;
        }

        [StructLayout (LayoutKind.Sequential)]
        public class BBox {
                public int      xMin, yMin;
                public int      xMax, yMax;     
        }

        [StructLayout (LayoutKind.Sequential)]
        public class ListRec {
                public System.IntPtr head;
                public System.IntPtr tail;
        }

        [StructLayout (LayoutKind.Sequential)]
        public class Vector {
                public int x;
                public int y;
        }


        [StructLayout (LayoutKind.Sequential)]
        public class Face {
                public int                              num_faces;
                public int                              face_index;
                public int                              face_flags;
                public int                              style_flags;
                public int                              num_glyphs;
                public string                   family_name;
                public string                   style_name;
                public int                              num_fixed_sizes;
                public System.IntPtr    available_sizes;
                public int                              num_charmaps;
                public System.IntPtr    charmaps;
                public Generic                  generic;
                public BBox                             box;
                public ushort                   units_per_EM;
                public short                    ascender;
                public short                    descender;
                public short                    height;
                public short                    max_advance_width;
                public short                    max_advance_height;
                public short                    underline_position;
                public short                    underline_tickness;
                public System.IntPtr    glyphrec;
                public System.IntPtr    size;
                public System.IntPtr    charmap;
                public System.IntPtr    driver;
                public System.IntPtr    memory;
                public System.IntPtr    stream;
                public ListRec                  sizes_list;
                public Generic                  autohint;
                public System.IntPtr    extensions;
                public System.IntPtr    internal_face;
                [DllImport ("freetype.dll")]
                public static extern int FT_New_Face( System.IntPtr lib, 
                        string fname, 
                        int index,
                        out System.IntPtr face );
                [DllImport ("freetype.dll")]
                public static extern void FT_Set_Char_Size( System.IntPtr face, 
                        int width,
                        int height,
                        int horz_resolution,
                        int vert_resolution);
                [DllImport ("freetype.dll")]
                public static extern void FT_Set_Pixel_Sizes( System.IntPtr 
face,
                        int pixel_width,
                        int pixel_height );
                [DllImport ("freetype.dll")]
                public static extern void FT_Done_Face( System.IntPtr face );
                [DllImport ("freetype.dll")]
                public static extern int FT_Get_Char_Index( System.IntPtr face, 
char c); 
                [DllImport ("freetype.dll")]
                public static extern int FT_Load_Glyph( System.IntPtr face,
                        int index,
                        FT_LOAD_TYPES flags);
        }
        
        [StructLayout (LayoutKind.Sequential)]
        public class GlyphRec {
                public System.IntPtr                    library;        
                public System.IntPtr                    clazz;          
                public int                                              format; 
        
                public Vector                                   advance;
        }

        [StructLayout (LayoutKind.Sequential)]
        public class GlyphClass {
                public  int                             size;                   
                public  uint                    format;                 
                public  System.IntPtr   init;
                public  System.IntPtr   done;
                public  System.IntPtr   copy;
                public  System.IntPtr   transform;
                public  System.IntPtr   bbox;
                public  System.IntPtr   prepare;
        }

        [StructLayout (LayoutKind.Sequential)]
        public class BitmapGlyph {
                public GlyphRec                 root;
                public int                              left;
                public int                              top;
                public Bitmap                   bitmap;
        }

        [StructLayout (LayoutKind.Sequential)]
        public class Bitmap {
                public int              rows;
                public int              width;
                public int              pitch;
                public IntPtr   buffer;
                public short    num_grays;
                public sbyte    pixel_mode;
                public sbyte    palette_mode;
                public IntPtr   palette;        
        }
        

        [StructLayout (LayoutKind.Sequential)]
        public class Glyph {
                [DllImport ("freetype.dll")]
                public static extern int FT_Get_Glyph( System.IntPtr glyphrec,
                        out System.IntPtr glyph );
                [DllImport ("freetype.dll")]
                public static extern void FT_Glyph_To_Bitmap( out System.IntPtr 
glyph,
                        FT_RENDER_MODES render_mode,
                        int origin,
                        int destroy);
        }

}

-- End of FreeType.cs --


Allan
-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Yves Goergen
Sent: 2007年11月29日 6:27
To: address@hidden
Subject: [ft-devel] What is FT_Library?

Hi,

I was just trying to use the FreeType library in a C# application, with
Visual Studio 2005. I have downloaded the freetype6.dll file from the
indicated website and thought that by reading the header files (*.h) I
could create an API class to use FreeType from C# (.NET) applications.
But that's not that easy. the first function that I found is
FT_New_Face(). Its first argument is of type FT_Library - which is never
defined! Okay, it is defined as something else which in turn is never
defined. I have also found a Visual Studio Project file that I could
open with my VS, but it also just plain said it doesn't know what that
thing is. (It can resolve other types though.)

I assume that it's just an integer or something, but I need the exact
type and type size for .NET interop to work correctly. Can somebody
please tell me where I can find this (and possibly other hidden) type
definitions in the source code?

Or is there already a C# interop class available? I haven't found one,
so I thought I'll make my own. It doesn't need to be complete (for my
needs), my first goal is to create a font browser application that can -
different from what is available - display demo texts with fonts that
are not installed in the system but only lying in a directory on disk.

-- 
Yves Goergen "LonelyPixel" <address@hidden>
Visit my web laboratory at http://beta.unclassified.de


_______________________________________________
Freetype-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/freetype-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]