OSDN Git Service

文字の表示がにじむ問題を修正した
authorgdkhd812 <jbh03215@htmil.co.jp>
Sun, 8 Sep 2013 10:32:57 +0000 (19:32 +0900)
committergdkhd812 <jbh03215@htmil.co.jp>
Sun, 8 Sep 2013 10:32:57 +0000 (19:32 +0900)
Common/Direct2D/D2DRenderCommon.cs
Common/Direct2D/MyTextLayout.cs

index 5d52d74..079781f 100644 (file)
@@ -584,21 +584,12 @@ namespace FooEditEngine
         {
             if (this.render == null || this.render.IsDisposed)
                 return;
-            DW.TextLayout layout = new DW.TextLayout(this.DWFactory, str, this.format, (float)layoutRect.Width, (float)layoutRect.Height);
-            switch (align)
-            {
-                case StringAlignment.Left:
-                    layout.TextAlignment = DW.TextAlignment.Leading;
-                    break;
-                case StringAlignment.Center:
-                    layout.TextAlignment = DW.TextAlignment.Center;
-                    break;
-                case StringAlignment.Right:
-                    layout.TextAlignment = DW.TextAlignment.Trailing;
-                    break;
-            }
+            float dpix, dpiy;
+            this.GetDpi(out dpix,out dpiy);
+            MyTextLayout layout = new MyTextLayout(this.DWFactory, str, this.format, (float)layoutRect.Width, (float)layoutRect.Height,dpix,false);
+            layout.StringAlignment = align;
             D2D.SolidColorBrush brush = this.Brushes.Get(this.Foreground);
-            this.render.DrawTextLayout(new Vector2((float)x, (float)y), layout, brush);
+            layout.Draw(this.render, (float)x, (float)y, brush);
             layout.Dispose();
         }
 
@@ -728,12 +719,16 @@ namespace FooEditEngine
 
         public ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable<Marker> MarkerRanges)
         {
+            float dpix,dpiy;
+            this.GetDpi(out dpix,out dpiy);
+
             bool hasNewLine = str.Length > 0 && str[str.Length - 1] == Document.NewLine;
             MyTextLayout newLayout = new MyTextLayout(this.DWFactory,
                 str,
                 this.format,
                 this.ClipRect.Width,
                 this.ClipRect.Height,
+                dpiy,
                 hasNewLine && this._ShowLineBreak);
             ParseLayout(newLayout, str);
             if (syntaxCollection != null)
index d2ccf01..24a326c 100644 (file)
@@ -21,8 +21,9 @@ namespace FooEditEngine
         double _height = double.NaN;
         double _width = double.NaN;
         int lineBreakIndex = 0;
+        StringAlignment _strAlign;
 
-        internal MyTextLayout(DW.Factory dwFactory,string str,DW.TextFormat format,double width,double height,bool showLineBreak)
+        internal MyTextLayout(DW.Factory dwFactory,string str,DW.TextFormat format,double width,double height,float dip,bool showLineBreak)
         {
             str = str.Trim(Document.NewLine);   //取り除かないとキャレットの動きがおかしくなる
             if (showLineBreak)
@@ -34,7 +35,9 @@ namespace FooEditEngine
                 str,
                 format,
                 (float)width,
-                (float)height);
+                (float)height,
+                dip,
+                true);
             this.Disposed = false;
             this.ShowLineBreak = showLineBreak;
         }
@@ -155,11 +158,40 @@ namespace FooEditEngine
             }
         }
 
+        public StringAlignment StringAlignment
+        {
+            get
+            {
+                return this._strAlign;
+            }
+            set
+            {
+                this._strAlign = value;
+                switch (value)
+                {
+                    case StringAlignment.Left:
+                        layout.TextAlignment = DW.TextAlignment.Leading;
+                        break;
+                    case StringAlignment.Center:
+                        layout.TextAlignment = DW.TextAlignment.Center;
+                        break;
+                    case StringAlignment.Right:
+                        layout.TextAlignment = DW.TextAlignment.Trailing;
+                        break;
+                }
+            }
+        }
+
         public void Draw(DW.TextRenderer render, float x, float y)
         {
             this.layout.Draw(render, x, y);
         }
 
+        public void Draw(D2D.RenderTarget render, float x, float y, D2D.Brush brush)
+        {
+            render.DrawTextLayout(new Vector2((float)x, (float)y), this.layout, brush);
+        }
+
         public void Dispose()
         {
             this.layout.Dispose();