<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      提取windows字體輪廓線

       class PointCollectSink : CallbackBase,SimplifiedGeometrySink
       {
           public class GlyphContour
           {
               public List<RawVector2> Points = new List<RawVector2>();
               public bool IsHole;
               public GlyphContour Parent;
               public List<GlyphContour> Holes = new List<GlyphContour>();
           }
      
           public List<GlyphContour> Contours { get; } = new List<GlyphContour>();
           GlyphContour _currentContour;
      
           public List<RawVector2> Points
           {
               get
               {
                   return _points;
               }
           }
           List<RawVector2> _points;
      
           public PointCollectSink(List<RawVector2> points) 
           {
               _points = points;
           }
      
      
           public void AddBeziers(BezierSegment[] beziers)
           {
               if(_currentContour!=null && beziers != null)
               {
                   foreach(var b in beziers)
                   {
                       _currentContour.Points.Add(b.Point1);
                       _currentContour.Points.Add(b.Point2);
                       _currentContour.Points.Add(b.Point3);
                   }
               }
           }
      
      
           public void AddLines(RawVector2[] ointsRef)
           {
               _points.AddRange(ointsRef);
               if(_currentContour!=null && ointsRef != null)
               {
                   _currentContour.Points.AddRange(ointsRef);
               }
           }
      
      
           public void BeginFigure(RawVector2 startPoint, FigureBegin figureBegin)
           {
               _points.Add(startPoint);
               _currentContour = new GlyphContour();
               _currentContour.Points.Add(startPoint);
           }
      
           public void Close()
           {
               
           }
      
      
      
           public void EndFigure(FigureEnd figureEnd)
           {
               if(figureEnd==FigureEnd.Closed && _points.Count > 0)
               {
                   _points.Add(_points[0]);
               }
               if (_currentContour != null && figureEnd==FigureEnd.Closed && _currentContour.Points.Count > 0) 
               {
                   _currentContour.Points.Add(_currentContour.Points[0]);
               }
               float area = SignedArea(_currentContour.Points);
               _currentContour.IsHole = area < 0;
               Contours.Add(_currentContour);
               _currentContour = null;
           }
      
           private float SignedArea(List<RawVector2> points)
           {
               float a = 0;
               for(int i = 0; i < points.Count; i++)
               {
                   var p1= points[i];
                   var p2 = points[(i + 1) % points.Count];
                   a += (p1.X*p2.Y-p1.Y*p2.X);
               }
               return a;
           }
      
           public void SetFillMode(FillMode fillMode)
           {
               
           }
      
           public void SetSegmentFlags(PathSegment vertexFlags)
           {
               
           }
       }
       static  void Main(string[] args)
       {
           //var a1 = new TestCrossEle();
           //List<TestCrossEle> aa = new List<TestCrossEle>();
           //aa.Add(a1);
           //a1 = null;
           char ch = 'A'; // 要測試的漢字
           float emSize = 100.0f;           // 字號 (DIP)
           float flattenTolerance = 1f; // 展平精度(越小越精細)
      
           using (var dwFactory = new SharpDX.DirectWrite.Factory())
           using (var d2dFactory = new SharpDX.Direct2D1.Factory())
           {
               var fontCollection = dwFactory.GetSystemFontCollection(false);
      
               // 候選的常見中文字體,按需增減
               string[] candidates = new[]
               {
               "Microsoft YaHei", "SimSun", "NSimSun", "Microsoft JhengHei",
               "PMingLiU", "MS Gothic", "Arial Unicode MS", "Noto Sans CJK SC"
           };
      
               FontFace chosenFace = null;
               string chosenName = null;
      
               // 逐個候選字體查找是否包含所需 glyph
               foreach (var name in candidates)
               {
                   int familyIndex;
                   if (!fontCollection.FindFamilyName(name, out familyIndex))
                       continue;
      
                   var family = fontCollection.GetFontFamily(familyIndex);
                   var font = family.GetFirstMatchingFont(FontWeight.Normal, FontStretch.Normal, FontStyle.Normal);
      
                   // 臨時創建 FontFace 測試 glyph 是否存在
                   using (var testFace = new FontFace(font))
                   {
                       short[] glyphs = testFace.GetGlyphIndices(new int[] { ch });
                       if (glyphs != null && glyphs.Length > 0 && glyphs[0] != 0) // 注意:0 通常表示缺字
                       {
                           // 重新用該 Font 創建一個不在 using 中立即釋放的 FontFace
                           chosenFace = new FontFace(font);
                           chosenName = name;
                           break;
                       }
                   }
               }
      
               // 如果候選列表沒找到,退回系統默認第一個字體(仍然可能缺字)
               if (chosenFace == null)
               {
                   Console.WriteLine("候選字體中未找到 glyph,嘗試使用系統第一個字體(可能仍缺字)。");
                   var fam = fontCollection.GetFontFamily(0);
                   var font = fam.GetFirstMatchingFont(FontWeight.Normal, FontStretch.Normal, FontStyle.Normal);
                   chosenFace = new FontFace(font);
                   chosenName = "(system fallback)";
               }
      
               Console.WriteLine("使用字體: " + chosenName);
      
               // 獲得 glyph indices
               short[] glyphIndices = chosenFace.GetGlyphIndices(new int[] { ch });
               Console.WriteLine("glyph index: " + (glyphIndices != null && glyphIndices.Length > 0 ? glyphIndices[0].ToString() : "null"));
      
               // 如果 glyph index == 0 很可能缺字,需換字體
               if (glyphIndices == null || glyphIndices.Length == 0 || glyphIndices[0] == 0)
               {
                   Console.WriteLine("警告:選定字體不包含該字符的字形(glyph index == 0)。請改用支持中文的字體。");
               }
               else
               {
                   // 寫入 PathGeometry(務必 Close writer)
                   using (var path = new PathGeometry(d2dFactory))
                   {
                       using (var writer = path.Open())
                       {
                           chosenFace.GetGlyphRunOutline(
                               emSize,        // em size
                               glyphIndices,
                               null,          // advanceWidths
                               null,          // offsets
                               glyphIndices.Length,
                               false,         // isSideways
                               false,         // isRightToLeft
                               writer
                           );
                           writer.Close();
                       }
                       
                       // 展平并收集點(實現見下)
                       var collect = new PointCollectSink(new List<RawVector2>());
                       path.Simplify(GeometrySimplificationOption.Lines, Matrix3x2.Identity, flattenTolerance, collect);
      
                       Console.WriteLine($"展平后點數: {collect.Points.Count}");
                       // 注意:Direct2D 坐標系 Y 向下(如果你要用于 3D,可能要把 Y 翻轉)
                       for (int i = 0; i < collect.Points.Count; i++)
                       {
                           var p = collect.Points[i];
                           Console.WriteLine($"{i}: {p.X:F2}, {p.Y:F2}");
                       }
                       foreach(var con in collect.Contours)
                       {
                           List<DbPt> ptss = (from n in con.Points select new DbPt(n.X,-n.Y)).ToList();
                           var liness = GMath.GetOutlines(ptss);
                           GuiFunction.GFunc.DebugSend(liness);
                       }
                   }
               }
      
               chosenFace.Dispose();
           }
          
           Console.WriteLine("完成,按任意鍵退出");
           Console.ReadKey();
      
      
      posted @ 2025-09-07 21:59  JohnYang819  閱讀(17)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产高颜值极品嫩模视频| 人妻少妇精品无码专区二区| 一区二区三区四区五区色| 男女真人国产牲交a做片野外| 精品国产一区二区三区av性色| 欧洲无码一区二区三区在线观看| 国产一区二区三区AV在线无码观看| 日韩AV无码精品一二三区| 巨大黑人极品videos精品| 91密桃精品国产91久久| 日韩人妻精品中文字幕| 久久国产精品老人性| 99在线小视频| 国产黄色一区二区三区四区| 久久久久亚洲av成人网址| 日韩av中文字幕有码| 日韩内射美女人妻一区二区三区| 国产乱码精品一区二区三| 99中文字幕精品国产| 亚洲中文字幕av天堂| 亚洲男人第一无码av网站| 亚洲无线观看国产精品| 国产日韩av二区三区| 国产中文字幕日韩精品| 天美麻花果冻视频大全英文版| 最新精品国产自偷在自线| 国产精品自在拍首页视频| 鄂托克旗| 人妻无码| 福利网午夜视频一区二区| 欧美人与zoxxxx另类| 日本一区二区三区小视频| 国产精久久一区二区三区| 色94色欧美sute亚洲线路二| 久久精品国产再热青青青| 勃利县| 久久精品国产一区二区蜜芽| 香蕉久久久久久久AV网站| 天天爽夜夜爱| 一区二区三区四区精品黄| 欧美日本激情|