예제 #1
0
        public override void render(float maxWidth, RenderCache cache, ref float x, ref uint yline, List <Line> lines, float offsetX, float offsetY)
        {
            if (d_font == null)
            {
                return;
            }

            using (PD <StringBuilder> psb = Pool.GetSB())
            {
                Helper helper = new Helper(maxWidth, cache, x, yline, lines, formatting, offsetX, offsetY, psb.value);
                helper.Draw(this, NextLineX);

                x     = helper.x;
                yline = helper.yline;
            }
        }
예제 #2
0
        public override string ToString()
        {
            using (PD <StringBuilder> psb = Pool.GetSB())
            {
                StringBuilder sb = psb.value;
                sb.AppendFormat("count:{0}", d_attrs.Count);
                sb.AppendLine();
                foreach (var itor in d_attrs)
                {
                    sb.AppendLine("key:{0} value:{1}", itor.Key, itor.Value);
                }

                string t = sb.ToString();
                sb.Length = 0;
                return(t);
            }
        }
예제 #3
0
        void ParseHyText(string text, HyperlinkNode data)
        {
            if (hyConfig == null)
            {
                hyConfig = new HyConfig(this);
            }

            // 初始化数据
            {
                hyConfig.text     = text;
                hyConfig.node     = data;
                hyConfig.startPos = 0;
                hyConfig.lenght   = text.Length;
            }

            using (PD <StringBuilder> psb = Pool.GetSB())
            {
                hyConfig.BeginParser(psb.value);
                hyConfig.Clear();
            }
        }
예제 #4
0
        public void Segment(string text, List <NodeBase.Element> widths, Func <char, float> fontwidth)
        {
            // 判断标准,如果全英文的,那么都尽量在同一行显示
            using (PD <StringBuilder> psb = Pool.GetSB())
            {
                StringBuilder sb = psb.value;
                char          current;
                CharType      lasttype = CharType.Null;
                for (int i = 0; i < text.Length; ++i)
                {
                    current = text[i];
                    CharType ct = GetCharType(current);
                    switch (ct)
                    {
                    case CharType.English:
                    {
                        switch (lasttype)
                        {
                        case CharType.Chinese:     // 中文接英文,那么先把中文的保存起来
                            widths.Add(Create(sb, fontwidth));
                            break;

                        case CharType.Punctuation:     // 英文接标点符号的
                            widths.Add(Create(sb, fontwidth));
                            break;

                        case CharType.English:
                            break;
                        }

                        sb.Append(current);
                    }
                    break;

                    case CharType.Rtl:
                    {
                        switch (lasttype)
                        {
                        case CharType.Chinese:             // 中文接英文,那么先把中文的保存起来
                            widths.Add(Create(sb, fontwidth));
                            break;

                        case CharType.Punctuation:             // 英文接标点符号的
                            widths.Add(Create(sb, fontwidth));
                            break;

                        case CharType.English:
                            break;
                        }

                        sb.Append(current);
                    }
                    break;

                    case CharType.Chinese:
                    {
                        switch (lasttype)
                        {
                        case CharType.Chinese:     // 中文接英文,那么先把中文的保存起来
                            widths.Add(Create(sb, fontwidth));
                            break;

                        case CharType.Punctuation:
                        case CharType.English:
                            break;
                        }

                        sb.Append(current);
                    }
                    break;

                    case CharType.Punctuation: // 标点符号
                    {
                        sb.Append(current);

                        widths.Add(Create(sb, fontwidth));
                    }
                    break;
                    }

                    lasttype = ct;
                }

                if (sb.Length != 0)
                {
                    widths.Add(Create(sb, fontwidth));
                }
            }
        }