コード例 #1
0
ファイル: Font.cs プロジェクト: CallumDev/BubbleEngine
        public Font(FontContext ctx, string filename, float size)
        {
            context  = ctx;
            size26d6 = FTMath.To26Dot6(size);
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException("Font not found " + filename, filename);
            }

            var err = FT.FT_New_Face(context.Library, filename, 0, out facePtr);

            if (err != 0)
            {
                throw new Exception("Freetype Error");
            }

            FT.FT_Set_Char_Size(facePtr,
                                FTMath.To26Dot6(0),
                                size26d6,
                                0,
                                96
                                );
            //get metrics
            var faceRec = Marshal.PtrToStructure <FT.FaceRec> (facePtr);
            var szRec   = Marshal.PtrToStructure <FT.SizeRec> (faceRec.size);

            lineHeight = (int)FTMath.From26Dot6(szRec.metrics.height);
            pages.Add(new Texture(
                          PAGE_SIZE, PAGE_SIZE
                          ));

            //Rasterize standard ASCII
            for (int i = 32; i < 127; i++)
            {
                AddCharacter((uint)i);
            }
        }
コード例 #2
0
 public GameBase()
 {
     GraphicsSettings = new GraphicsSettings();
     FontContext      = new FontContext();
     Window           = new Window();
 }