예제 #1
0
        /// <summary>
        /// Clone
        /// </summary>
        /// <returns>Cloned Entry</returns>
        public FsbFontEntry Clone()
        {
            var fsbFontEntry = new FsbFontEntry();

            fsbFontEntry.CharacterID = this.CharacterID;
            fsbFontEntry.PosX        = this.PosX;
            fsbFontEntry.PosY        = this.PosY;
            fsbFontEntry.Width       = this.Width;
            fsbFontEntry.Height      = this.Height;
            fsbFontEntry.OffsetX     = this.OffsetX;
            fsbFontEntry.OffsetY     = this.OffsetY;
            fsbFontEntry.AdvanceX    = this.AdvanceX;
            fsbFontEntry.Channel     = this.Channel;

            foreach (var kernPair in this.Kernings)
            {
                var newKernPair = new FsbFontKerningPair();

                newKernPair.CharacterID = kernPair.CharacterID;
                newKernPair.Amount      = kernPair.Amount;

                fsbFontEntry.Kernings.Add(newKernPair);
            }

            return(fsbFontEntry);
        }
예제 #2
0
        /// <summary>
        /// Streamからフォント・エントリーを読み込む。
        /// </summary>
        /// <param name="reader">Stream</param>
        public void Read(BinaryReader reader)
        {
            var entryCount = reader.ReadInt32();

            for (int i = 0; i < entryCount; i++)
            {
                var entry = new FsbFontEntry();
                entry.Read(reader);
                this.Items.Add(entry.CharacterID, entry);
            }
        }
예제 #3
0
        /// <summary>
        /// 指定したエントリーを追加する。
        /// </summary>
        /// <param name="entry">エントリー</param>
        /// <returns>追加の成否。True: 追加に成功。</returns>
        public bool AddEntry(FsbFontEntry entry)
        {
            if (this.Items.ContainsKey(entry.CharacterID))
            {
                //// Duplicate character({entry.CharacterID}).
                return(false);
            }
            else
            {
                this.Items.Add(entry.CharacterID, entry);

                return(true);
            }
        }
예제 #4
0
        /// <summary>
        /// 指定したコレクションに含まれるエントリーに全て置き換える。
        /// </summary>
        /// <param name="data">コレクション</param>
        /// <param name="offsetX">X座標のオフセット</param>
        /// <param name="offsetY">Y座標のオフセット</param>
        /// <returns>登録できなかったCharacterIDのリスト</returns>
        public List <int> UpsertEntries(
            IDictionary <int, FsbBMFontCharacter> data, int offsetX, int offsetY)
        {
            var result = new List <int>();

            foreach (var bmFontEntry in data.Values)
            {
                var newEntry = new FsbFontEntry();
                newEntry.CharacterID = bmFontEntry.CharacterID;
                newEntry.PosX        = bmFontEntry.PosX;
                newEntry.PosY        = bmFontEntry.PosY;
                newEntry.Width       = bmFontEntry.Width;
                newEntry.Height      = bmFontEntry.Height;
                newEntry.OffsetX     = bmFontEntry.OffsetX;
                newEntry.OffsetY     = bmFontEntry.OffsetY;
                newEntry.AdvanceX    = bmFontEntry.AdvanceX;
                newEntry.Channel     = bmFontEntry.Channel;
                foreach (var kerningPair in bmFontEntry.Kernings)
                {
                    var newPair = new FsbFontKerningPair();

                    newPair.CharacterID = kerningPair.Second;
                    newPair.Amount      = kerningPair.Amount;

                    newEntry.Kernings.Add(newPair);
                }

                newEntry.PosX = newEntry.PosX + offsetX;
                newEntry.PosY = newEntry.PosY + offsetY;

                var rc = this.AddEntry(newEntry);
                if (!rc)
                {
                    //// 登録できなかったCharacterIDを記録する.
                    result.Add(newEntry.CharacterID);
                }
            }

            return(result);
        }