0001: // ----------------------------------------------------------------------------
0002: //
0003: // font.cpp - フォント描画部分
0004: // 
0005: // Copyright (c) 2001 if (if@edokko.com)
0006: // All Rights Reserved.
0007: //
0008: // ----------------------------------------------------------------------------
0009: #define STRICT
0010: 
0011: #include "main.h"
0012: #include "font.h"
0013: 
0014: 
0015: // ----------------------------------------------------------------------------
0016: void CMyFont::Init(LPDIRECT3DDEVICE8 lpD3DDEV, int w, int h)
0017: {
0018:     HDC     hTextDC = NULL;
0019:     HFONT   hFont = NULL, hOldFont = NULL;
0020:     
0021:     hTextDC = CreateCompatibleDC(NULL);
0022:     hFont = CreateFont( h, w, 0, 0,
0023:                       FW_REGULAR,
0024:                       FALSE,FALSE,FALSE,
0025:                       SHIFTJIS_CHARSET,
0026:                       OUT_DEFAULT_PRECIS,
0027:                       CLIP_DEFAULT_PRECIS,
0028:                       DEFAULT_QUALITY,
0029:                       DEFAULT_PITCH,
0030:                       "MS ゴシック"
0031:                       );
0032:     if(!hFont) return;
0033:     hOldFont = (HFONT)SelectObject(hTextDC, hFont);
0034:     
0035:     if( FAILED( D3DXCreateFont( lpD3DDEV, hFont, &m_lpFont ) ) ) {
0036:         MessageBox( 0, "D3DXCreateFontIndirect FALSE", "ok", MB_OK);
0037:         return;
0038:     }
0039:     SelectObject(hTextDC, hOldFont);
0040:     DeleteObject(hFont);
0041: }
0042: // ----------------------------------------------------------------------------
0043: // 表示ルーチン
0044: void CMyFont::Print( char *str, int x, int y, D3DCOLOR color )
0045: {
0046:     RECT rect;
0047:     rect.left = x; 
0048:     rect.right = WIDTH;
0049:     rect.top = y;
0050:     rect.bottom = HEIGHT;
0051: 
0052:     // デバイス上に、整形した ANSI テキストを描画する
0053:     m_lpFont->DrawText(str, -1, &rect
0054:                     ,DT_LEFT | DT_EXPANDTABS
0055:                     ,color
0056:                     );
0057: }
0058: // ----------------------------------------------------------------------------
0059: void CMyFont::Clean()
0060: {
0061:     RELEASE(m_lpFont);
0062: }
0063: 
0064: 
0065: