コード例 #1
0
ファイル: TextRenderingTest.cs プロジェクト: zwcloud/ImGui
        public void ShouldGenerateARightTexMesh()
        {
            var      text       = "ABC";
            var      fontFamily = Utility.FontDir + "msjh.ttf";
            var      fontSize   = 36;
            GlyphRun glyphRun   = new GlyphRun(text, fontFamily, fontSize);

            var geometryRenderer = new ImGui.GraphicsImplementation.BuiltinGeometryRenderer();
            var textMesh         = new TextMesh();

            geometryRenderer.SetTextMesh(textMesh);
            geometryRenderer.DrawGlyphRun(new Brush(Color.Black), glyphRun);
            geometryRenderer.SetTextMesh(null);

            var objFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/TextRenderingTest/texMesh.obj";

            Graphics.SaveTextMeshToObjFile(objFilePath, textMesh);
            Process.Start(ModelViewerPath, objFilePath);
        }
コード例 #2
0
        public void ShouldGetCorrectOffsetOfAGlyph()
        {
            var      text       = "A";
            var      fontFamily = Utility.FontDir + "msjh.ttf";
            var      fontSize   = 36;
            GlyphRun glyphRun   = new GlyphRun(new Point(50, 100), text, fontFamily, fontSize);

            var geometryRenderer = new ImGui.GraphicsImplementation.BuiltinGeometryRenderer();
            var textMesh         = new TextMesh();

            geometryRenderer.SetTextMesh(textMesh);
            geometryRenderer.DrawGlyphRun(new Brush(Color.Black), glyphRun);
            geometryRenderer.SetTextMesh(null);

            var objFilePath =
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
                + "/ShouldGetARightMeshFromTypography.obj";

            ImGui.Development.Graphics.SaveTextMeshToObjFile(objFilePath, textMesh);
            Process.Start(ModelViewerPath, objFilePath);
        }
コード例 #3
0
ファイル: TextRenderingTest.cs プロジェクト: zwcloud/ImGui
        public void ShouldGetARightMeshAfterAppendingATextMesh()
        {
            var textMeshA = new TextMesh();
            {
                var      text       = "ij = I::oO(0xB81l);";
                var      fontFamily = Utility.FontDir + "msjh.ttf";
                var      fontSize   = 12;
                GlyphRun glyphRun   = new GlyphRun(text, fontFamily, fontSize);

                var geometryRenderer = new ImGui.GraphicsImplementation.BuiltinGeometryRenderer();
                geometryRenderer.SetTextMesh(textMeshA);
                geometryRenderer.DrawGlyphRun(new Brush(Color.Black), glyphRun);
                geometryRenderer.SetTextMesh(null);
            }

            var textMeshB = new TextMesh();
            {
                var      text       = "auto-sized";
                var      fontFamily = Utility.FontDir + "msjh.ttf";
                var      fontSize   = 12;
                GlyphRun glyphRun   = new GlyphRun(new Point(50, 100), text, fontFamily, fontSize);

                var geometryRenderer = new ImGui.GraphicsImplementation.BuiltinGeometryRenderer();
                geometryRenderer.SetTextMesh(textMeshB);
                geometryRenderer.DrawGlyphRun(new Brush(Color.Black), glyphRun);
                geometryRenderer.SetTextMesh(null);
            }

            TextMesh textMesh = new TextMesh();

            textMesh.Append(textMeshA, Vector.Zero);
            textMesh.Append(textMeshB, Vector.Zero);

            var objFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
                              + "/TextRenderingTest/ShouldGetARightMeshAfterAppendingATextMesh.obj";

            Graphics.SaveTextMeshToObjFile(objFilePath, textMesh);
            Process.Start(ModelViewerPath, objFilePath);
        }