文字データ(色などメタデータも含む)
		internal UguiNovelTextGeneratorAddtionalRuby( List<UguiNovelTextCharacter> characters, int index, Font rubyFont, float rubySizeScale)
		{
			UguiNovelTextCharacter original = characters[index];
			int rubySize = Mathf.CeilToInt(rubySizeScale * original.FontSize);
			stringData.Add(original);
			for (int i = index + 1; i < characters.Count; ++i)
			{
				UguiNovelTextCharacter c = characters[i];
				if (!c.CustomInfo.IsRuby || c.CustomInfo.IsRubyTop) break;
				stringData.Add(c);
			}
			
			//カラー情報のみコピー
			CharData.CustomCharaInfo rubyInfo = new CharData.CustomCharaInfo();
			rubyInfo.IsColor = original.charData.CustomInfo.IsColor;
			rubyInfo.color = original.charData.CustomInfo.color;
			if (original.charData.CustomInfo.IsEmphasisMark)
			{
				for (int i = 0; i < stringData.Count; ++i)
				{
					CharData data = new CharData(original.charData.CustomInfo.rubyStr[0], rubyInfo);
					rubyList.Add(new UguiNovelTextCharacter(data, rubyFont, rubySize, original.FontStyle ));
				}
			}
			else
			{
				foreach (char c in original.charData.CustomInfo.rubyStr)
				{
					CharData data = new CharData(c, rubyInfo);
					rubyList.Add(new UguiNovelTextCharacter(data, rubyFont, rubySize, original.FontStyle ));
				}
			}
		}
		void InitSub(Type type, UguiNovelTextGenerator generator)
		{
			this.type = type;
			//ダッシュ('—')の文字を作成
			CharData.CustomCharaInfo custom = new CharData.CustomCharaInfo();
			custom.IsDash = true;
			custom.DashSize = 1;
			CharData data = new CharData(CharData.Dash, custom);
			characteData = new UguiNovelTextCharacter(data, generator);
		}
Exemplo n.º 3
0
		//サイズ指定のスペースの追加
		bool TryAddSpace(string arg)
		{
			int size;
			if (!int.TryParse(arg, out size))
			{
				return false;
			}

			CharData.CustomCharaInfo custom = new CharData.CustomCharaInfo();
			custom.IsSpace = true;
			custom.SpaceSize = size;
			CharData data = new CharData(' ', custom);
			charList.Add(data);
			return true;
		}
Exemplo n.º 4
0
		//絵文字を追加
		bool TryAddEmoji(string arg)
		{
			if(string.IsNullOrEmpty(arg))
			{
				return false;
			}

			CharData.CustomCharaInfo custom = new CharData.CustomCharaInfo();
			custom.IsEmoji = true;
			custom.EmojiKey = arg;
			CharData data = new CharData('□', custom);
			charList.Add(data);
			return true;
		}
Exemplo n.º 5
0
		//棒線(ダッシュ、ダーシ)を追加
		void AddDash(string arg)
		{
			int size;
			if (!int.TryParse(arg, out size))
			{
				size = 1;
			}
			CharData.CustomCharaInfo custom = new CharData.CustomCharaInfo();
			custom.IsDash = true;
			custom.DashSize = size;
			CharData data = new CharData(CharData.Dash, custom);
			charList.Add(data);
		}
Exemplo n.º 6
0
		//本来二文字ぶんの改行文字を追加
		void AddDoubleLineBreak()
		{
			CharData.CustomCharaInfo custom = new CharData.CustomCharaInfo();
			custom.IsDobleWord = true;
			CharData data = new CharData('\n', custom);
			charList.Add(data);
		}
Exemplo n.º 7
0
		//文字を追加
		void AddChar(char c)
		{
			CharData data = new CharData(c, customInfo);
			charList.Add(data);
			customInfo.ClearTopInfo();
		}
Exemplo n.º 8
0
        //文字を追加
        void AddChar(char c, Color color, int size)
        {
            CharData data = new CharData(c, color, size);

            charList.Add(data);
        }
Exemplo n.º 9
0
 //コンストラクタ
 public UguiNovelTextCharacter(CharData charData, Font font, int fontSize, int bmpFontSize, FontStyle fontStyle)
 {
     Init(charData, font, fontSize, bmpFontSize, fontStyle, -1);
 }
Exemplo n.º 10
0
        /// Unityのリッチテキストフォーマットのテキストを初期化する
        public void InitUnityRitchText()
        {
            //作成ずみならなにもしない
            if (!string.IsNullOrEmpty(unityRitchText))
            {
                return;
            }

            unityRitchText = "";
            CharData.CustomCharaInfo curentCustomInfo = new CharData.CustomCharaInfo();

            //タグの前後関係を正しくするためにStackを使う
            Stack <string> endTagStack = new Stack <string>();

            for (int i = 0; i < CharList.Count; ++i)
            {
                CharData c = CharList[i];
                if (c.CustomInfo.IsEndBold(curentCustomInfo))
                {
                    unityRitchText += endTagStack.Pop();
                }
                if (c.CustomInfo.IsEndItalic(curentCustomInfo))
                {
                    unityRitchText += endTagStack.Pop();
                }
                if (c.CustomInfo.IsEndSize(curentCustomInfo))
                {
                    unityRitchText += endTagStack.Pop();
                }
                if (c.CustomInfo.IsEndColor(curentCustomInfo))
                {
                    unityRitchText += endTagStack.Pop();
                }

                if (c.CustomInfo.IsBeginColor(curentCustomInfo))
                {
//					unityRitchText += "<color=#" + ColorUtil.ToColorString(c.CustomInfo.color) + ">";
                    unityRitchText += "<color=" + c.CustomInfo.colorStr + ">";
                    endTagStack.Push(ColorEndTag);
                }
                if (c.CustomInfo.IsBeginSize(curentCustomInfo))
                {
                    unityRitchText += "<size=" + c.CustomInfo.size + ">";
                    endTagStack.Push(SizeEndTag);
                }
                if (c.CustomInfo.IsBeginItalic(curentCustomInfo))
                {
                    unityRitchText += "<i>";
                    endTagStack.Push(ItalicEndTag);
                }
                if (c.CustomInfo.IsBeginBold(curentCustomInfo))
                {
                    unityRitchText += "<b>";
                    endTagStack.Push(BoldEndTag);
                }

                c.UnityRitchTextIndex = unityRitchText.Length;
                unityRitchText       += c.Char;
                if (c.CustomInfo.IsDoubleWord)
                {
                    unityRitchText += " ";
                }
                curentCustomInfo = c.CustomInfo;
            }
            if (curentCustomInfo.IsBold)
            {
                unityRitchText += endTagStack.Pop();
            }
            if (curentCustomInfo.IsItalic)
            {
                unityRitchText += endTagStack.Pop();
            }
            if (curentCustomInfo.IsSize)
            {
                unityRitchText += endTagStack.Pop();
            }
            if (curentCustomInfo.IsColor)
            {
                unityRitchText += endTagStack.Pop();
            }
        }
Exemplo n.º 11
0
			public float w;							//表示幅

			public CharacterRenderInfo(CharData charInfo, FontRenderInfo fontInfo, float x, float y, float w, bool isAutoLineBreak)
			{
				this.charInfo = charInfo;
				this.fontInfo = fontInfo;
				this.x = x;
				this.y = y;
				this.w = w;
				this.isAutoLineBreak = isAutoLineBreak;
			}
		//初期化
		void Init(CharData charData, Font font, int fontSize, FontStyle fontStyle, float spacing  )
		{
			this.charData = charData;

			//フォントサイズの設定
			this.fontSize = this.defaultFontSize = charData.CustomInfo.GetCustomedSize(fontSize);			
			//フォントスタイルの設定
			this.fontStyle = charData.CustomInfo.GetCustomedStyle(fontStyle);

			if (charData.IsBr)
			{
				//改行文字の場合は、
				//'\'などの文字である場合があるので、幅0にして非表示
				width = 0;
			}
			else if (char.IsWhiteSpace(charData.Char))
			{
				//スペースの場合は、幅を固定する
				if (spacing >= 0)
				{
					width = spacing;
				}
				else
				{
					width = fontSize / 3;
				}
			}
		}
		//コンストラクタ
		public UguiNovelTextCharacter(CharData charData, Font font, int fontSize, FontStyle fontStyle )
		{
			Init(charData, font, fontSize, fontStyle, 0);
		}
		//コンストラクタ
		public UguiNovelTextCharacter(CharData charData, UguiNovelTextGenerator generator )
		{
			Init(charData, generator.NovelText.font, generator.NovelText.fontSize, generator.NovelText.fontStyle, generator.Space );

			//上つき文字、下つき文字
			if (charData.CustomInfo.IsSuperOrSubScript)
			{
				this.fontSize = Mathf.FloorToInt(generator.SupOrSubSizeScale*this.fontSize);
			}

			//スペースの指定
			if (charData.CustomInfo.IsSpace)
			{
				width = charData.CustomInfo.SpaceSize;
			}

			//絵文字
			if (generator.EmojiData)
			{
				//スプライトを使うか
				if (CustomInfo.IsEmoji || generator.EmojiData.Contains(Char))
				{
					IsSprite = true;
				}

				//絵文字の制御
				if (IsSprite)
				{
					Sprite sprite = FindSpirte(generator);
					if (sprite)
					{
						float scale = sprite.rect.width / generator.EmojiData.Size;
						width = scale * fontSize;
					}
					else
					{
						Debug.LogError("Not found Emoji[" + Char + "]" + ":" + (int)Char);
					}
				}
			}
		}