示例#1
0
        public unsafe D2D.Geometry CreateGeometry(float fontSize, string text, float[] glyphAdvances = null,
                                                  DW.GlyphOffset[] glyphOffsets = null)
        {
            // USC4のコードポイント配列を取得
            byte[] utf32 = Encoding.UTF32.GetBytes(text);
            var    cps   = new int[text.Length];

            fixed(int *p = cps)
            Marshal.Copy(utf32, 0, (IntPtr)p, utf32.Length);

            // GlyphIndexの配列に変換
            short[] indices = FontFace.GetGlyphIndicesW(cps);

            // ジオメトリの作成
            var geometry = new D2D.PathGeometry(_d2DFactory);

            using (D2D.GeometrySink sink = geometry.Open())
            {
                _fontFace.GetGlyphRunOutline(fontSize, indices, glyphAdvances, glyphOffsets, false, false, sink);
                sink.Close();
            }

            return(geometry);
        }