/*------------------------------------------------------------------------- * 文字列の描画時のサイズを得る * ---------------------------------------------------------------------------*/ public Rectangle MeasureText(font_type type, string str, Color color) { Microsoft.DirectX.Direct3D.Font font; if (type == font_type.normal) { font = m_font; } else { font = m_font_small; } Sprite sprite = (m_is_use_font_sprite)? m_font_sprite: null; return(font.MeasureString(sprite, str, DrawTextFormat.None, color)); }
/*------------------------------------------------------------------------- * 文字列の描画 * ---------------------------------------------------------------------------*/ public void DrawText(font_type type, string str, int x, int y, Color color) { Microsoft.DirectX.Direct3D.Font font; if (type == font_type.normal) { font = m_font; } else { font = m_font_small; } Sprite sprite = (m_is_use_font_sprite)? m_font_sprite: null; font.DrawText(sprite, str, new Point(x, y + 1), color); }
/*------------------------------------------------------------------------- * 文字列の描画 * センタリング * xが真中にくるように描画される * ---------------------------------------------------------------------------*/ public void DrawTextC(font_type type, string str, int x, int y, Color color) { Microsoft.DirectX.Direct3D.Font font; if (type == font_type.normal) { font = m_font; } else { font = m_font_small; } Sprite sprite = (m_is_use_font_sprite)? m_font_sprite: null; Rectangle rect = font.MeasureString(sprite, str, DrawTextFormat.None, color); font.DrawText(sprite, str, new Point(x - (rect.Width / 2), y + 1), color); }