示例#1
0
        /// <summary>
        /// Reads the letter.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="textReader">The text reader.</param>
        /// <returns></returns>
        private FIGcharacter ReadCharacter(UnicodeChar code, TextReader textReader)
        {
            var characterLines = new List <string>();
            // we guess the end mark (I need to read the doc twice).
            char?endMark = null;

            for (; ;)
            {
                var rawCharacterLine = textReader.ReadLine();
                if (rawCharacterLine == null)
                {
                    return(null);
                }
                if (!endMark.HasValue)
                {
                    endMark = rawCharacterLine.Last();
                }
                var endMarksCount = CountTrailing(rawCharacterLine, endMark.Value);
                var characterLine = rawCharacterLine.Substring(0, rawCharacterLine.Length - endMarksCount);
                characterLines.Add(characterLine);
                if (endMarksCount == 2)
                {
                    break;
                }
            }
            return(new FIGcharacter(code, characterLines));
        }
示例#2
0
        protected virtual ProcessCharResult ProcessNormalUnicodeChar(UnicodeChar unicodeChar)
        {
            //既に画面右端にキャレットがあるのに文字が来たら改行をする
            int tw = GetDocument().TerminalWidth;

            if (_manipulator.CaretColumn + (unicodeChar.IsWideWidth ? 2 : 1) > tw)
            {
                _manipulator.EOLType = EOLType.Continue;
                GLine lineUpdated = GetDocument().UpdateCurrentLine(_manipulator);
                if (lineUpdated != null)
                {
                    this.LogService.TextLogger.WriteLine(lineUpdated);
                }
                GetDocument().LineFeed();
                _manipulator.Load(GetDocument().CurrentLine, 0);
            }

            //画面のリサイズがあったときは、_manipulatorのバッファサイズが不足の可能性がある
            if (tw > _manipulator.BufferSize)
            {
                _manipulator.ExpandBuffer(tw);
            }

            //通常文字の処理
            _manipulator.PutChar(unicodeChar, _currentdecoration);

            return(ProcessCharResult.Processed);
        }
        public string Visit(UnicodeChar node)
        {
            var chr = node.AnchorToken.Lexeme;
            var sb  = new StringBuilder();

            var unicodeChr = chr.Substring(3, 6);

            int decValue = Convert.ToInt32(unicodeChr, 16);

            sb.Append($"    i32.const {decValue}\n");

            return(sb.ToString());
        }
示例#4
0
        /// <summary>
        /// Writes the specified char.
        /// This is the base for rendering
        /// </summary>
        /// <param name="c">The c.</param>
        /// <exception cref="System.InvalidOperationException">A font is needed!</exception>
        public void Write(UnicodeChar c)
        {
            if (Font == null)
            {
                throw new InvalidOperationException("A font is needed!");
            }
            if (!Font.Characters.TryGetValue(c, out var character))
            {
                return;
            }
            AdjustDrawingBoardHeight();
            var rowOffset    = Baseline - Font.Baseline;
            var columnOffset = Caret;

            columnOffset = AdjustCaret(character, DrawingBoard, columnOffset, rowOffset, Blender);
            Draw(character, DrawingBoard, columnOffset, rowOffset, Blender);
            Caret = columnOffset + character.Width;
        }
示例#5
0
        public unsafe ImageSource GetText(int fontId, string text, short hueId)
        {
            UnicodeFont font = _fonts[fontId];

            int width  = font.GetWidth(text);
            int height = font.GetHeight(text);

            WriteableBitmap bmp = new WriteableBitmap(width, height, 96, 96, PixelFormats.Bgr555, null);

            bmp.Lock();

            ushort *line  = (ushort *)bmp.BackBuffer;
            int     delta = bmp.BackBufferStride >> 1;

            int dx = 2;

            for (int i = 0; i < text.Length; ++i)
            {
                int         c  = (int)text[i] % 0x10000;
                UnicodeChar ch = font.Chars[c];

                int charWidth  = ch.Width;
                int charHeight = ch.Height;

                byte[] data = ch.Bytes;

                if (c == 32)
                {
                    dx += 5;
                    continue;
                }
                else
                {
                    dx += ch.XOffset;
                }

                for (int dy = 0; dy < charHeight; ++dy)
                {
                    ushort *dest = (line + (delta * (dy + (height - charHeight)))) + (dx);

                    for (int k = 0; k < charWidth; ++k)
                    {
                        int offset = k / 8 + dy * ((charWidth + 7) / 8);

                        if (offset > data.Length)
                        {
                            continue;
                        }

                        if ((data[offset] & (1 << (7 - (k % 8)))) != 0)
                        {
                            *dest++ = 0x8000;
                        }
                        else
                        {
                            *dest++ = 0x0000;
                        }
                    }
                }

                dx += ch.Width;
            }

            bmp.AddDirtyRect(new Int32Rect(0, 0, width, height));
            bmp.Unlock();

            return(bmp);
        }
 public void Visit(UnicodeChar node)
 {
 }
示例#7
0
        public unsafe Bitmap GetText(int fontId, string text, short hueId)
        {
            UnicodeFont font = _fonts[fontId];

            int width  = font.GetWidth(text);
            int height = font.GetHeight(text);

            Bitmap     bmp = new Bitmap(width, height, PixelFormat.Format16bppArgb1555);
            BitmapData bd  = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format16bppArgb1555);

            ushort *line  = (ushort *)bd.Scan0;
            int     delta = bd.Stride >> 1;

            int dx = 2;

            for (int i = 0; i < text.Length; ++i)
            {
                int         c  = (int)text[i] % 0x10000;
                UnicodeChar ch = font.Chars[c];

                int charWidth  = ch.Width;
                int charHeight = ch.Height;

                byte[] data = ch.Bytes;

                if (c == 32)
                {
                    dx += 5;
                    continue;
                }
                else
                {
                    dx += ch.XOffset;
                }

                for (int dy = 0; dy < charHeight; ++dy)
                {
                    ushort *dest = (line + (delta * (dy + (height - charHeight)))) + (dx);

                    for (int k = 0; k < charWidth; ++k)
                    {
                        int offset = k / 8 + dy * ((charWidth + 7) / 8);

                        if (offset > data.Length)
                        {
                            continue;
                        }

                        if ((data[offset] & (1 << (7 - (k % 8)))) != 0)
                        {
                            *dest++ = 0x8000;
                        }
                        else
                        {
                            *dest++ = 0x0000;
                        }
                    }
                }

                dx += ch.Width;
            }

            bmp.UnlockBits(bd);

            return(bmp);
        }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FIGcharacter"/> class.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <param name="rows">The rows.</param>
 public FIGcharacter(UnicodeChar code, IList <string> rows)
 {
     Code  = code;
     Rows  = rows;
     Width = rows.Aggregate(0, (w, l) => Math.Max(w, l.Length));
 }
示例#9
0
        public unsafe Texture GetText(int fontId, string text, short hueId)
        {
            UnicodeFont font = _fonts[fontId];

            int width  = font.GetWidth(text);
            int height = font.GetHeight(text);

            Texture       texture = new Texture(_device, width, height, 0, Usage.None, Format.A1R5G5B5, Pool.Managed);
            DataRectangle rect    = texture.LockRectangle(0, LockFlags.None);

            ushort *line  = (ushort *)rect.DataPointer;
            int     delta = rect.Pitch >> 1;

            int dx = 2;

            for (int i = 0; i < text.Length; ++i)
            {
                int         c  = (int)text[i] % 0x10000;
                UnicodeChar ch = font.Chars[c];

                int charWidth  = ch.Width;
                int charHeight = ch.Height;

                byte[] data = ch.Bytes;

                if (c == 32)
                {
                    dx += 5;
                    continue;
                }
                else
                {
                    dx += ch.XOffset;
                }

                for (int dy = 0; dy < charHeight; ++dy)
                {
                    ushort *dest = (line + (delta * (dy + (height - charHeight)))) + (dx);

                    for (int k = 0; k < charWidth; ++k)
                    {
                        int offset = k / 8 + dy * ((charWidth + 7) / 8);

                        if (offset > data.Length)
                        {
                            continue;
                        }

                        if ((data[offset] & (1 << (7 - (k % 8)))) != 0)
                        {
                            *dest++ = 0x8000;
                        }
                        else
                        {
                            *dest++ = 0x0000;
                        }
                    }
                }

                dx += ch.Width;
            }

            texture.UnlockRectangle(0);

            return(texture);
        }