<Compile Include="カウンタ\定間隔進行.cs" />
<Compile Include="フォルダ.cs" />
<Compile Include="メディア\XML.cs" />
+ <Compile Include="メディア\テクスチャフォント.cs" />
<Compile Include="メディア\ビットマップ付きテクスチャ.cs" />
<Compile Include="メディア\動画.cs" />
<Compile Include="メディア\描画可能画像.cs" />
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+
+namespace FDK.メディア
+{
+ /// <summary>
+ /// 任意個の文字を格納した一枚のテクスチャ画像と、それぞれの文字領域の矩形リストから、文字列を連続するテクスチャ画像で表示する。
+ /// </summary>
+ public class テクスチャフォント : FDK.Activity
+ {
+ public テクスチャフォント( string 文字盤の画像ファイルパス, string 文字矩形リストファイルパス ) : this( 文字盤の画像ファイルパス, new FDK.メディア.矩形リスト( 文字矩形リストファイルパス ) )
+ {
+ }
+ public テクスチャフォント( string 文字盤の画像ファイルパス, FDK.メディア.矩形リスト 文字矩形リスト )
+ {
+ this.子リスト.Add( this.文字盤 = new テクスチャ( 文字盤の画像ファイルパス ) );
+ this.文字矩形リスト = 文字矩形リスト;
+ }
+ /// <param name="文字列全体のワールド変換行列">スケーリングは、等倍にした「あと」の拡大縮小率を指定すること。</param>
+ public void 描画する( FDK.メディア.デバイスリソース dr, string 表示文字列, SharpDX.Matrix 文字列全体のワールド変換行列 )
+ {
+ if( 表示文字列.Nullまたは空である() )
+ return;
+
+ // 有効文字(矩形リストに登録されている文字)の矩形、文字数を抽出し、文字列全体のサイズを計算する。
+ var 有効文字矩形s =
+ from 文字 in 表示文字列
+ where ( this.文字矩形リスト.文字列to矩形.ContainsKey( new string( new char[] { 文字 } ) ) )
+ select this.文字矩形リスト.文字列to矩形[ new string( new char[] { 文字 } ) ];
+
+ int 有効文字数 = 有効文字矩形s.Count();
+ if( 0 == 有効文字数 )
+ return;
+
+ var 文字列全体のサイズdpx = SharpDX.Size2F.Empty;
+ foreach( var 文字矩形 in 有効文字矩形s )
+ {
+ 文字列全体のサイズdpx.Width += 文字矩形.Width;
+ if( 文字列全体のサイズdpx.Height < 文字矩形.Height )
+ 文字列全体のサイズdpx.Height = 文字矩形.Height; // 文字列全体の高さは、最大の文字高に一致。
+ }
+
+ // 描画する。
+ float 左端dpx = 0f;
+ for( int i = 0; i < 有効文字数; i++ )
+ {
+ var 文字矩形 = 有効文字矩形s.ElementAt( i );
+
+ float 中央X = 0f - ( 文字列全体のサイズdpx.Width / 2f ) + 左端dpx + ( 文字矩形.Width / 2f );
+ var world = SharpDX.Matrix.Scaling( 文字列全体のサイズdpx.Width, 文字列全体のサイズdpx.Height, 1f )
+ * SharpDX.Matrix.Translation( 中央X, 0f, 0f )
+ * 文字列全体のワールド変換行列;
+
+ this.文字盤.進行描画する( dr, world, 文字矩形 );
+
+ 左端dpx += 文字矩形.Width;
+ }
+ }
+
+ protected FDK.メディア.テクスチャ 文字盤 = null;
+ protected FDK.メディア.矩形リスト 文字矩形リスト = null;
+ }
+}