当前位置: 首页>>代码示例>>C#>>正文


C# IScanner.ScanChar方法代码示例

本文整理汇总了C#中IScanner.ScanChar方法的典型用法代码示例。如果您正苦于以下问题:C# IScanner.ScanChar方法的具体用法?C# IScanner.ScanChar怎么用?C# IScanner.ScanChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScanner的用法示例。


在下文中一共展示了IScanner.ScanChar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Scan

        /**
          <summary>Executes scanning on this operation.</summary>
          <param name="state">Graphics state context.</param>
          <param name="textScanner">Scanner to be notified about text contents.
          In case it's null, the operation is applied to the graphics state context.</param>
        */
        public void Scan(
      ContentScanner.GraphicsState state,
      IScanner textScanner
      )
        {
            /*
            TODO: I really dislike this solution -- it's a temporary hack until the event-driven
            parsing mechanism is implemented...
              */
              /*
            TODO: support to vertical writing mode.
              */

              IContentContext context = state.Scanner.ContentContext;
              double contextHeight = context.Box.Height;
              Font font = state.Font;
              double fontSize = state.FontSize;
              double scale = state.Scale / 100;
              double scaledFactor = Font.GetScalingFactor(fontSize) * scale;
              double wordSpace = state.WordSpace * scale;
              double charSpace = state.CharSpace * scale;
              Matrix ctm = state.Ctm.Clone();
              Matrix tm = state.Tm;
              if(this is ShowTextToNextLine)
              {
            ShowTextToNextLine showTextToNextLine = (ShowTextToNextLine)this;
            double? newWordSpace = showTextToNextLine.WordSpace;
            if(newWordSpace != null)
            {
              if(textScanner == null)
              {state.WordSpace = newWordSpace.Value;}
              wordSpace = newWordSpace.Value * scale;
            }
            double? newCharSpace = showTextToNextLine.CharSpace;
            if(newCharSpace != null)
            {
              if(textScanner == null)
              {state.CharSpace = newCharSpace.Value;}
              charSpace = newCharSpace.Value * scale;
            }
            tm = state.Tlm.Clone();
            tm.Translate(0, (float)state.Lead);
              }
              else
              {tm = state.Tm.Clone();}

              foreach(object textElement in Value)
              {
            if(textElement is byte[]) // Text string.
            {
              string textString = font.Decode((byte[])textElement);
              foreach(char textChar in textString)
              {
            double charWidth = font.GetWidth(textChar) * scaledFactor;

            if(textScanner != null)
            {
              /*
                NOTE: The text rendering matrix is recomputed before each glyph is painted
                during a text-showing operation.
              */
              Matrix trm = ctm.Clone(); trm.Multiply(tm);
              double charHeight = font.GetHeight(textChar,fontSize);
              drawing::RectangleF charBox = new drawing::RectangleF(
                trm.Elements[4],
                (float)(contextHeight - trm.Elements[5] - font.GetAscent(fontSize) * trm.Elements[3]),
                (float)charWidth * trm.Elements[0],
                (float)charHeight * trm.Elements[3]
                );
              textScanner.ScanChar(textChar,charBox);
            }

            /*
              NOTE: After the glyph is painted, the text matrix is updated
              according to the glyph displacement and any applicable spacing parameter.
            */
            tm.Translate((float)(charWidth + charSpace + (textChar == ' ' ? wordSpace : 0)), 0);
              }
            }
            else // Text position adjustment.
            {tm.Translate((float)(-Convert.ToSingle(textElement) * scaledFactor), 0);}
              }

              if(textScanner == null)
              {
            state.Tm = tm;

            if(this is ShowTextToNextLine)
            {state.Tlm = tm.Clone();}
              }
        }
开发者ID:josuecorrea,项目名称:DanfeSharp,代码行数:97,代码来源:ShowText.cs


注:本文中的IScanner.ScanChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。