コード例 #1
0
 public FT_Error NewFace(FontLibrary library, string path, int face_index)
 {
     if (Form == LongForm.Long4)
     {
         return(FT_New_Face_4(library.Handle, path, face_index, ref mHandle));
     }
     else
     {
         return(FT_New_Face_8(library.Handle, path, ToLong8(face_index), ref mHandle));
     }
 }
コード例 #2
0
        static void Main(string[] args)
        {
            try
            {
                var library = new DumbFont.FontLibrary();
                FT_CHECK(library.Init_FreeType());
                var longForm = DetrimineLongForm();
                var packed   = load_font(library, "Noto Sans 700.ttf", longForm, 4U);

                Console.WriteLine("Average glyph size: {0} bytes", packed.glyph_data_size / packed.no_of_glyphs);
                Console.WriteLine("    points size: {0} bytes", packed.glyph_points_size / packed.no_of_glyphs);
                Console.WriteLine("    cells size: {0} bytes", packed.glyph_cells_size / packed.no_of_glyphs);


                FT_CHECK(library.Done_FreeType());
            }
            catch (Exception e)
            {
                var foregroundColor = Console.ForegroundColor;
                var backgroundColor = Console.BackgroundColor;

                var exceptionType = e.GetType();
                if (exceptionType == typeof(BadImageFormatException))
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Magenta;
                }

                Console.BackgroundColor = ConsoleColor.Cyan;
                Console.WriteLine(exceptionType);
                Console.BackgroundColor = backgroundColor;
                Console.ForegroundColor = foregroundColor;

                Console.WriteLine(e);
            }
        }