Win32 API 日本語リファレンス
ホームGraphics.Gdi › CreateFontW

CreateFontW

関数
高さや太さなど多数の属性を指定して論理フォントを作成する。
DLLGDI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll  (Unicode / -W)
#include <windows.h>

HFONT CreateFontW(
    INT cHeight,
    INT cWidth,
    INT cEscapement,
    INT cOrientation,
    INT cWeight,
    DWORD bItalic,
    DWORD bUnderline,
    DWORD bStrikeOut,
    DWORD iCharSet,
    DWORD iOutPrecision,
    DWORD iClipPrecision,
    DWORD iQuality,
    DWORD iPitchAndFamily,
    LPCWSTR pszFaceName   // optional
);

パラメーター

名前方向説明
cHeightINTin

フォントの文字セルまたは文字の高さ(論理単位)。文字の高さの値(em の高さとも呼ばれます)は、文字セルの高さの値から内部レディング(internal-leading)の値を引いたものです。フォントマッパーは、nHeight に指定された値を次のように解釈します。

意味
> 0
フォントマッパーはこの値をデバイス単位に変換し、利用可能なフォントのセルの高さと照合します。
0
フォントマッパーは一致を検索する際に既定の高さの値を使用します。
< 0
フォントマッパーはこの値をデバイス単位に変換し、その絶対値を利用可能なフォントの文字の高さと照合します。

すべての高さの比較において、フォントマッパーは要求されたサイズを超えない範囲で最大のフォントを探します。

このマッピングは、フォントが初めて使用されるときに行われます。

MM_TEXT マッピングモードでは、指定したポイントサイズのフォントの高さを求めるために、次の式を使用できます。


nHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
cWidthINTin要求するフォント内の文字の平均幅(論理単位)。この値が 0 の場合、フォントマッパーは最も近い一致値を選択します。最も近い一致値は、現在のデバイスのアスペクト比と、利用可能なフォントのデジタル化されたアスペクト比との差の絶対値を比較して決定されます。
cEscapementINTin

エスケープメントベクトルとデバイスの x 軸との間の角度(10 分の 1 度単位)。エスケープメントベクトルは、テキスト行のベースラインに平行です。

グラフィックスモードが GM_ADVANCED に設定されている場合、文字列のエスケープメント角を、文字列内の文字の向き(オリエンテーション)角とは独立して指定できます。

グラフィックスモードが GM_COMPATIBLE に設定されている場合、nEscapement はエスケープメントとオリエンテーションの両方を指定します。nEscapementnOrientation には同じ値を設定してください。

cOrientationINTin各文字のベースラインとデバイスの x 軸との間の角度(10 分の 1 度単位)。
cWeightINTin

フォントの太さ。0 から 1000 の範囲で指定します。例えば、400 は標準(normal)、700 は太字(bold)です。この値が 0 の場合、既定の太さが使用されます。

便宜のために、次の値が定義されています。

太さ
FW_DONTCARE
0
FW_THIN
100
FW_EXTRALIGHT
200
FW_ULTRALIGHT
200
FW_LIGHT
300
FW_NORMAL
400
FW_REGULAR
400
FW_MEDIUM
500
FW_SEMIBOLD
600
FW_DEMIBOLD
600
FW_BOLD
700
FW_EXTRABOLD
800
FW_ULTRABOLD
800
FW_HEAVY
900
FW_BLACK
900
bItalicDWORDinTRUE に設定すると、イタリック体のフォントを指定します。
bUnderlineDWORDinTRUE に設定すると、下線付きのフォントを指定します。
bStrikeOutDWORDinTRUE に設定すると、取り消し線付きのフォントを指定します。
iCharSetDWORDin

文字セット。指定可能な値の一覧については、LOGFONT 構造体lfCharSet フィールドを参照してください。

オペレーティングシステムには、他の文字セットを持つフォントが存在する場合があります。アプリケーションが未知の文字セットを持つフォントを使用する場合、そのフォントでレンダリングされる文字列を変換または解釈しようとすべきではありません。

フォント作成時に一貫した結果を得るには、OEM_CHARSETDEFAULT_CHARSET を指定しないでください。pszFaceName パラメーターで書体名を指定する場合は、iCharSet の値が pszFaceName で指定された書体の文字セットと一致していることを確認してください。

iOutPrecisionDWORDin

出力精度。出力精度は、要求されたフォントの高さ、幅、文字の向き、エスケープメント、ピッチ、フォントの種類に出力をどの程度厳密に一致させる必要があるかを定義します。次のいずれかの値を指定できます。

意味
OUT_CHARACTER_PRECIS
使用されません。
OUT_DEFAULT_PRECIS
既定のフォントマッパーの動作。
OUT_DEVICE_PRECIS
システムに同じ名前のフォントが複数含まれている場合に、フォントマッパーにデバイスフォントを選択させます。
OUT_OUTLINE_PRECIS
この値は、フォントマッパーに TrueType フォントやその他のアウトラインベースのフォントから選択させます。
OUT_PS_ONLY_PRECIS
フォントマッパーに PostScript フォントのみから選択させます。システムに PostScript フォントがインストールされていない場合、フォントマッパーは既定の動作に戻ります。
OUT_RASTER_PRECIS
システムに同じ名前のフォントが複数含まれている場合に、フォントマッパーにラスターフォントを選択させます。
OUT_STRING_PRECIS
この値はフォントマッパーでは使用されませんが、ラスターフォントを列挙する際に返されます。
OUT_STROKE_PRECIS
この値はフォントマッパーでは使用されませんが、TrueType フォント、その他のアウトラインベースのフォント、およびベクターフォントを列挙する際に返されます。
OUT_TT_ONLY_PRECIS
フォントマッパーに TrueType フォントのみから選択させます。システムに TrueType フォントがインストールされていない場合、フォントマッパーは既定の動作に戻ります。
OUT_TT_PRECIS
システムに同じ名前のフォントが複数含まれている場合に、フォントマッパーに TrueType フォントを選択させます。

アプリケーションは、OUT_DEVICE_PRECISOUT_RASTER_PRECISOUT_TT_PRECISOUT_PS_ONLY_PRECIS の各値を使用して、指定した名前のフォントがオペレーティングシステムに複数含まれている場合にフォントマッパーがどのフォントを選択するかを制御できます。例えば、オペレーティングシステムに Symbol という名前のフォントがラスター形式と TrueType 形式で含まれている場合、OUT_TT_PRECIS を指定するとフォントマッパーは TrueType 版を選択します。OUT_TT_ONLY_PRECIS を指定すると、別の名前の TrueType フォントで代替する必要がある場合であっても、フォントマッパーは TrueType フォントを選択します。

iClipPrecisionDWORDin

クリッピング精度。クリッピング精度は、クリッピング領域から部分的にはみ出した文字をどのようにクリップするかを定義します。次の値を 1 つ以上指定できます。

意味
CLIP_CHARACTER_PRECIS
使用されません。
CLIP_DEFAULT_PRECIS
既定のクリッピング動作を指定します。
CLIP_DFA_DISABLE
Windows XP SP1: フォントのフォントアソシエーションを無効にします。このフラグは、Windows Server 2003 以降のどのプラットフォームでも効果があるとは限らない点に注意してください。
CLIP_EMBEDDED
読み取り専用の埋め込みフォントを使用するには、このフラグを指定する必要があります。
CLIP_LH_ANGLES
この値を使用すると、すべてのフォントの回転は、座標系の向きが左手系か右手系かに依存します。

この値を使用しない場合、デバイスフォントは常に反時計回りに回転しますが、その他のフォントの回転は座標系の向きに依存します。

座標系の向きの詳細については、nOrientation パラメーターの説明を参照してください。

CLIP_MASK
使用されません。
CLIP_DFA_OVERRIDE
フォントのフォントアソシエーションを無効にします。これは CLIP_DFA_DISABLE と同一ですが、状況によっては問題が発生することがあります。使用が推奨されるフラグは CLIP_DFA_DISABLE です。
CLIP_STROKE_PRECIS
フォントマッパーでは使用されませんが、ラスター、ベクター、または TrueType フォントを列挙する際に返されます。

互換性のため、フォントを列挙する際には常にこの値が返されます。

CLIP_TT_ALWAYS
使用されません。
iQualityDWORDin

出力品質。出力品質は、論理フォントの属性を実際の物理フォントの属性に GDI がどの程度慎重に一致させようとするかを定義します。次のいずれかの値を指定できます。

意味
ANTIALIASED_QUALITY
フォントがアンチエイリアス(スムージング)に対応しており、フォントのサイズが小さすぎず大きすぎない場合に、フォントをアンチエイリアス処理します。
CLEARTYPE_QUALITY
設定すると、可能な場合は ClearType アンチエイリアス方式を使用してテキストがレンダリングされます。詳細については「解説」を参照してください。
DEFAULT_QUALITY
フォントの外観は問いません。
DRAFT_QUALITY
フォントの外観の重要度は、PROOF_QUALITY 値を使用した場合よりも低くなります。GDI ラスターフォントの場合、スケーリングが有効になり、より多くのフォントサイズが利用可能になりますが、品質は低下する可能性があります。必要に応じて、太字、イタリック、下線、取り消し線のフォントが合成されます。
NONANTIALIASED_QUALITY
フォントは決してアンチエイリアス処理されません。つまり、フォントスムージングは行われません。
PROOF_QUALITY
論理フォント属性の厳密な一致よりも、フォントの文字品質が重視されます。GDI ラスターフォントの場合、スケーリングは無効になり、サイズが最も近いフォントが選択されます。PROOF_QUALITY を使用した場合、選択されたフォントサイズが正確にマッピングされないことがありますが、フォントの品質は高く、外観の歪みは生じません。必要に応じて、太字、イタリック、下線、取り消し線のフォントが合成されます。

出力品質が DEFAULT_QUALITYDRAFT_QUALITY、または PROOF_QUALITY の場合、SPI_GETFONTSMOOTHING システムパラメーターが TRUE であれば、フォントはアンチエイリアス処理されます。ユーザーはこのシステムパラメーターをコントロールパネルから制御できます。(コントロールパネルでの設定項目の正確な表現は Windows のバージョンによって異なりますが、「画面のフォントの縁を滑らかにする」といった趣旨の文言になります。)

iPitchAndFamilyDWORDin

フォントのピッチとファミリ。下位 2 ビットはフォントのピッチを指定し、次のいずれかの値を指定できます。

上位 4 ビットはフォントファミリを指定し、次のいずれかの値を指定できます。
意味
FF_DECORATIVE
装飾的なフォント。Old English がその例です。
FF_DONTCARE
既定のフォントを使用します。
FF_MODERN
セリフの有無にかかわらず、ストローク幅が一定のフォント。Pica、Elite、Courier New がその例です。
FF_ROMAN
ストローク幅が可変で、セリフのあるフォント。MS Serif がその例です。
FF_SCRIPT
手書き風に見えるよう設計されたフォント。Script や Cursive がその例です。
FF_SWISS
ストローク幅が可変で、セリフのないフォント。MS?Sans Serif がその例です。

アプリケーションは、ブール OR 演算子を使用してピッチ定数とファミリ定数を結合することで、fdwPitchAndFamily パラメーターの値を指定できます。

フォントファミリは、フォントの見た目を大まかに表します。これは、要求した正確な書体が利用できない場合にフォントを指定するためのものです。

pszFaceNameLPCWSTRinoptional

フォントの書体名を指定する、null で終わる文字列へのポインター。この文字列の長さは、終端の null 文字を含めて 32 文字を超えてはなりません。EnumFontFamilies 関数を使用すると、現在利用可能なすべてのフォントの書体名を列挙できます。詳細については「解説」を参照してください。

pszFaceNameNULL または空の文字列の場合、GDI は指定された他の属性に一致する最初のフォントを使用します。

戻り値の型: HFONT

公式ドキュメント

CreateFont 関数は、指定した特性を持つ論理フォントを作成します。作成された論理フォントは、その後、任意のデバイスのフォントとして選択できます。(Unicode)

戻り値

関数が成功した場合、戻り値は論理フォントのハンドルです。

関数が失敗した場合、戻り値は NULL です。

解説(Remarks)

フォントが不要になったら、DeleteObject 関数を呼び出して削除してください。

Windows 向けにフォントを提供するベンダーの著作権を保護するため、アプリケーションは常に選択されたフォントの正確な名前を報告すべきです。利用可能なフォントはシステムによって異なる場合があるため、選択されたフォントが常に要求したフォントと同じであるとは想定しないでください。例えば、Palatino という名前のフォントを要求しても、そのフォントがシステムで利用できない場合、フォントマッパーは類似した属性を持つが名前の異なるフォントで代替します。常に選択されたフォントの名前をユーザーに報告してください。

異なる言語バージョンの OS で適切なフォントを取得するには、目的のフォント特性を LOGFONT 構造体に指定して EnumFontFamiliesEx を呼び出し、適切な書体名を取得してから、CreateFont または CreateFontIndirect を使用してフォントを作成します。

CreateFontCreateFontIndirectCreateFontIndirectEx のフォントマッパーは、ロケールに関係なく、英語の書体名とローカライズされた書体名の両方を認識します。

次の状況では ClearType アンチエイリアスはサポートされません。

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;
    switch (message)
    {
    
    
    case WM_PAINT:
        {
        RECT rect;
        HFONT hFontOriginal, hFont1, hFont2, hFont3;
        hdc = BeginPaint(hWnd, &ps);

            
            //Logical units are device dependent pixels, so this will create a handle to a logical font that is 48 pixels in height.
            //The width, when set to 0, will cause the font mapper to choose the closest matching value.
            //The font face name will be Impact.
            hFont1 = CreateFont(48,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY, VARIABLE_PITCH,TEXT("Impact"));
            hFontOriginal = (HFONT)SelectObject(hdc, hFont1);
            
            //Sets the coordinates for the rectangle in which the text is to be formatted.
            SetRect(&rect, 100,100,700,200);
            SetTextColor(hdc, RGB(255,0,0));
            DrawText(hdc, TEXT("Drawing Text with Impact"), -1,&rect, DT_NOCLIP);
            
            //Logical units are device dependent pixels, so this will create a handle to a logical font that is 36 pixels in height.
            //The width, when set to 20, will cause the font mapper to choose a font which, in this case, is stretched.
            //The font face name will be Times New Roman.  This time nEscapement is at -300 tenths of a degree (-30 degrees)
            hFont2 = CreateFont(36,20,-300,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY, VARIABLE_PITCH,TEXT("Times New Roman"));
            SelectObject(hdc,hFont2);
            
            //Sets the coordinates for the rectangle in which the text is to be formatted.
            SetRect(&rect, 100, 200, 900, 800);
            SetTextColor(hdc, RGB(0,128,0));
            DrawText(hdc, TEXT("Drawing Text with Times New Roman"), -1,&rect, DT_NOCLIP);
            
            //Logical units are device dependent pixels, so this will create a handle to a logical font that is 36 pixels in height.
            //The width, when set to 10, will cause the font mapper to choose a font which, in this case, is compressed. 
            //The font face name will be Arial. This time nEscapement is at 250 tenths of a degree (25 degrees)
            hFont3 = CreateFont(36,10,250,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Arial"));
            SelectObject(hdc,hFont3);

            //Sets the coordinates for the rectangle in which the text is to be formatted.
            SetRect(&rect, 500, 200, 1400, 600);
            SetTextColor(hdc, RGB(0,0,255));
            DrawText(hdc, TEXT("Drawing Text with Arial"), -1,&rect, DT_NOCLIP);

            SelectObject(hdc,hFontOriginal);
            DeleteObject(hFont1);
            DeleteObject(hFont2);
            DeleteObject(hFont3);
        
        EndPaint(hWnd, &ps);
        break;
        }
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

別の例については、メニューの使用の「Setting Fonts for Menu-Item Text Strings」を参照してください。

メモ

wingdi.h ヘッダーは CreateFont を、UNICODE プリプロセッサー定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコーディング非依存のエイリアスの使用と、エンコーディング非依存ではないコードを混在させると、コンパイルエラーや実行時エラーを引き起こす不一致が生じる可能性があります。詳細については、関数プロトタイプの規約を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// GDI32.dll  (Unicode / -W)
#include <windows.h>

HFONT CreateFontW(
    INT cHeight,
    INT cWidth,
    INT cEscapement,
    INT cOrientation,
    INT cWeight,
    DWORD bItalic,
    DWORD bUnderline,
    DWORD bStrikeOut,
    DWORD iCharSet,
    DWORD iOutPrecision,
    DWORD iClipPrecision,
    DWORD iQuality,
    DWORD iPitchAndFamily,
    LPCWSTR pszFaceName   // optional
);
[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr CreateFontW(
    int cHeight,   // INT
    int cWidth,   // INT
    int cEscapement,   // INT
    int cOrientation,   // INT
    int cWeight,   // INT
    uint bItalic,   // DWORD
    uint bUnderline,   // DWORD
    uint bStrikeOut,   // DWORD
    uint iCharSet,   // DWORD
    uint iOutPrecision,   // DWORD
    uint iClipPrecision,   // DWORD
    uint iQuality,   // DWORD
    uint iPitchAndFamily,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pszFaceName   // LPCWSTR optional
);
<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function CreateFontW(
    cHeight As Integer,   ' INT
    cWidth As Integer,   ' INT
    cEscapement As Integer,   ' INT
    cOrientation As Integer,   ' INT
    cWeight As Integer,   ' INT
    bItalic As UInteger,   ' DWORD
    bUnderline As UInteger,   ' DWORD
    bStrikeOut As UInteger,   ' DWORD
    iCharSet As UInteger,   ' DWORD
    iOutPrecision As UInteger,   ' DWORD
    iClipPrecision As UInteger,   ' DWORD
    iQuality As UInteger,   ' DWORD
    iPitchAndFamily As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszFaceName As String   ' LPCWSTR optional
) As IntPtr
End Function
' cHeight : INT
' cWidth : INT
' cEscapement : INT
' cOrientation : INT
' cWeight : INT
' bItalic : DWORD
' bUnderline : DWORD
' bStrikeOut : DWORD
' iCharSet : DWORD
' iOutPrecision : DWORD
' iClipPrecision : DWORD
' iQuality : DWORD
' iPitchAndFamily : DWORD
' pszFaceName : LPCWSTR optional
Declare PtrSafe Function CreateFontW Lib "gdi32" ( _
    ByVal cHeight As Long, _
    ByVal cWidth As Long, _
    ByVal cEscapement As Long, _
    ByVal cOrientation As Long, _
    ByVal cWeight As Long, _
    ByVal bItalic As Long, _
    ByVal bUnderline As Long, _
    ByVal bStrikeOut As Long, _
    ByVal iCharSet As Long, _
    ByVal iOutPrecision As Long, _
    ByVal iClipPrecision As Long, _
    ByVal iQuality As Long, _
    ByVal iPitchAndFamily As Long, _
    ByVal pszFaceName As LongPtr) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateFontW = ctypes.windll.gdi32.CreateFontW
CreateFontW.restype = ctypes.c_void_p
CreateFontW.argtypes = [
    ctypes.c_int,  # cHeight : INT
    ctypes.c_int,  # cWidth : INT
    ctypes.c_int,  # cEscapement : INT
    ctypes.c_int,  # cOrientation : INT
    ctypes.c_int,  # cWeight : INT
    wintypes.DWORD,  # bItalic : DWORD
    wintypes.DWORD,  # bUnderline : DWORD
    wintypes.DWORD,  # bStrikeOut : DWORD
    wintypes.DWORD,  # iCharSet : DWORD
    wintypes.DWORD,  # iOutPrecision : DWORD
    wintypes.DWORD,  # iClipPrecision : DWORD
    wintypes.DWORD,  # iQuality : DWORD
    wintypes.DWORD,  # iPitchAndFamily : DWORD
    wintypes.LPCWSTR,  # pszFaceName : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
CreateFontW = Fiddle::Function.new(
  lib['CreateFontW'],
  [
    Fiddle::TYPE_INT,  # cHeight : INT
    Fiddle::TYPE_INT,  # cWidth : INT
    Fiddle::TYPE_INT,  # cEscapement : INT
    Fiddle::TYPE_INT,  # cOrientation : INT
    Fiddle::TYPE_INT,  # cWeight : INT
    -Fiddle::TYPE_INT,  # bItalic : DWORD
    -Fiddle::TYPE_INT,  # bUnderline : DWORD
    -Fiddle::TYPE_INT,  # bStrikeOut : DWORD
    -Fiddle::TYPE_INT,  # iCharSet : DWORD
    -Fiddle::TYPE_INT,  # iOutPrecision : DWORD
    -Fiddle::TYPE_INT,  # iClipPrecision : DWORD
    -Fiddle::TYPE_INT,  # iQuality : DWORD
    -Fiddle::TYPE_INT,  # iPitchAndFamily : DWORD
    Fiddle::TYPE_VOIDP,  # pszFaceName : LPCWSTR optional
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "gdi32")]
extern "system" {
    fn CreateFontW(
        cHeight: i32,  // INT
        cWidth: i32,  // INT
        cEscapement: i32,  // INT
        cOrientation: i32,  // INT
        cWeight: i32,  // INT
        bItalic: u32,  // DWORD
        bUnderline: u32,  // DWORD
        bStrikeOut: u32,  // DWORD
        iCharSet: u32,  // DWORD
        iOutPrecision: u32,  // DWORD
        iClipPrecision: u32,  // DWORD
        iQuality: u32,  // DWORD
        iPitchAndFamily: u32,  // DWORD
        pszFaceName: *const u16  // LPCWSTR optional
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr CreateFontW(int cHeight, int cWidth, int cEscapement, int cOrientation, int cWeight, uint bItalic, uint bUnderline, uint bStrikeOut, uint iCharSet, uint iOutPrecision, uint iClipPrecision, uint iQuality, uint iPitchAndFamily, [MarshalAs(UnmanagedType.LPWStr)] string pszFaceName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreateFontW' -Namespace Win32 -PassThru
# $api::CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName)
#uselib "GDI32.dll"
#func global CreateFontW "CreateFontW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; CreateFontW cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName   ; 戻り値は stat
; cHeight : INT -> "wptr"
; cWidth : INT -> "wptr"
; cEscapement : INT -> "wptr"
; cOrientation : INT -> "wptr"
; cWeight : INT -> "wptr"
; bItalic : DWORD -> "wptr"
; bUnderline : DWORD -> "wptr"
; bStrikeOut : DWORD -> "wptr"
; iCharSet : DWORD -> "wptr"
; iOutPrecision : DWORD -> "wptr"
; iClipPrecision : DWORD -> "wptr"
; iQuality : DWORD -> "wptr"
; iPitchAndFamily : DWORD -> "wptr"
; pszFaceName : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global CreateFontW "CreateFontW" int, int, int, int, int, int, int, int, int, int, int, int, int, wstr
; res = CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName)
; cHeight : INT -> "int"
; cWidth : INT -> "int"
; cEscapement : INT -> "int"
; cOrientation : INT -> "int"
; cWeight : INT -> "int"
; bItalic : DWORD -> "int"
; bUnderline : DWORD -> "int"
; bStrikeOut : DWORD -> "int"
; iCharSet : DWORD -> "int"
; iOutPrecision : DWORD -> "int"
; iClipPrecision : DWORD -> "int"
; iQuality : DWORD -> "int"
; iPitchAndFamily : DWORD -> "int"
; pszFaceName : LPCWSTR optional -> "wstr"
; HFONT CreateFontW(INT cHeight, INT cWidth, INT cEscapement, INT cOrientation, INT cWeight, DWORD bItalic, DWORD bUnderline, DWORD bStrikeOut, DWORD iCharSet, DWORD iOutPrecision, DWORD iClipPrecision, DWORD iQuality, DWORD iPitchAndFamily, LPCWSTR pszFaceName)
#uselib "GDI32.dll"
#cfunc global CreateFontW "CreateFontW" int, int, int, int, int, int, int, int, int, int, int, int, int, wstr
; res = CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName)
; cHeight : INT -> "int"
; cWidth : INT -> "int"
; cEscapement : INT -> "int"
; cOrientation : INT -> "int"
; cWeight : INT -> "int"
; bItalic : DWORD -> "int"
; bUnderline : DWORD -> "int"
; bStrikeOut : DWORD -> "int"
; iCharSet : DWORD -> "int"
; iOutPrecision : DWORD -> "int"
; iClipPrecision : DWORD -> "int"
; iQuality : DWORD -> "int"
; iPitchAndFamily : DWORD -> "int"
; pszFaceName : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCreateFontW = gdi32.NewProc("CreateFontW")
)

// cHeight (INT), cWidth (INT), cEscapement (INT), cOrientation (INT), cWeight (INT), bItalic (DWORD), bUnderline (DWORD), bStrikeOut (DWORD), iCharSet (DWORD), iOutPrecision (DWORD), iClipPrecision (DWORD), iQuality (DWORD), iPitchAndFamily (DWORD), pszFaceName (LPCWSTR optional)
r1, _, err := procCreateFontW.Call(
	uintptr(cHeight),
	uintptr(cWidth),
	uintptr(cEscapement),
	uintptr(cOrientation),
	uintptr(cWeight),
	uintptr(bItalic),
	uintptr(bUnderline),
	uintptr(bStrikeOut),
	uintptr(iCharSet),
	uintptr(iOutPrecision),
	uintptr(iClipPrecision),
	uintptr(iQuality),
	uintptr(iPitchAndFamily),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFaceName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HFONT
function CreateFontW(
  cHeight: Integer;   // INT
  cWidth: Integer;   // INT
  cEscapement: Integer;   // INT
  cOrientation: Integer;   // INT
  cWeight: Integer;   // INT
  bItalic: DWORD;   // DWORD
  bUnderline: DWORD;   // DWORD
  bStrikeOut: DWORD;   // DWORD
  iCharSet: DWORD;   // DWORD
  iOutPrecision: DWORD;   // DWORD
  iClipPrecision: DWORD;   // DWORD
  iQuality: DWORD;   // DWORD
  iPitchAndFamily: DWORD;   // DWORD
  pszFaceName: PWideChar   // LPCWSTR optional
): THandle; stdcall;
  external 'GDI32.dll' name 'CreateFontW';
result := DllCall("GDI32\CreateFontW"
    , "Int", cHeight   ; INT
    , "Int", cWidth   ; INT
    , "Int", cEscapement   ; INT
    , "Int", cOrientation   ; INT
    , "Int", cWeight   ; INT
    , "UInt", bItalic   ; DWORD
    , "UInt", bUnderline   ; DWORD
    , "UInt", bStrikeOut   ; DWORD
    , "UInt", iCharSet   ; DWORD
    , "UInt", iOutPrecision   ; DWORD
    , "UInt", iClipPrecision   ; DWORD
    , "UInt", iQuality   ; DWORD
    , "UInt", iPitchAndFamily   ; DWORD
    , "WStr", pszFaceName   ; LPCWSTR optional
    , "Ptr")   ; return: HFONT
●CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName) = DLL("GDI32.dll", "void* CreateFontW(int, int, int, int, int, dword, dword, dword, dword, dword, dword, dword, dword, char*)")
# 呼び出し: CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName)
# cHeight : INT -> "int"
# cWidth : INT -> "int"
# cEscapement : INT -> "int"
# cOrientation : INT -> "int"
# cWeight : INT -> "int"
# bItalic : DWORD -> "dword"
# bUnderline : DWORD -> "dword"
# bStrikeOut : DWORD -> "dword"
# iCharSet : DWORD -> "dword"
# iOutPrecision : DWORD -> "dword"
# iClipPrecision : DWORD -> "dword"
# iQuality : DWORD -> "dword"
# iPitchAndFamily : DWORD -> "dword"
# pszFaceName : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "gdi32" fn CreateFontW(
    cHeight: i32, // INT
    cWidth: i32, // INT
    cEscapement: i32, // INT
    cOrientation: i32, // INT
    cWeight: i32, // INT
    bItalic: u32, // DWORD
    bUnderline: u32, // DWORD
    bStrikeOut: u32, // DWORD
    iCharSet: u32, // DWORD
    iOutPrecision: u32, // DWORD
    iClipPrecision: u32, // DWORD
    iQuality: u32, // DWORD
    iPitchAndFamily: u32, // DWORD
    pszFaceName: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) ?*anyopaque;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc CreateFontW(
    cHeight: int32,  # INT
    cWidth: int32,  # INT
    cEscapement: int32,  # INT
    cOrientation: int32,  # INT
    cWeight: int32,  # INT
    bItalic: uint32,  # DWORD
    bUnderline: uint32,  # DWORD
    bStrikeOut: uint32,  # DWORD
    iCharSet: uint32,  # DWORD
    iOutPrecision: uint32,  # DWORD
    iClipPrecision: uint32,  # DWORD
    iQuality: uint32,  # DWORD
    iPitchAndFamily: uint32,  # DWORD
    pszFaceName: WideCString  # LPCWSTR optional
): pointer {.importc: "CreateFontW", stdcall, dynlib: "GDI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "gdi32");
extern(Windows)
void* CreateFontW(
    int cHeight,   // INT
    int cWidth,   // INT
    int cEscapement,   // INT
    int cOrientation,   // INT
    int cWeight,   // INT
    uint bItalic,   // DWORD
    uint bUnderline,   // DWORD
    uint bStrikeOut,   // DWORD
    uint iCharSet,   // DWORD
    uint iOutPrecision,   // DWORD
    uint iClipPrecision,   // DWORD
    uint iQuality,   // DWORD
    uint iPitchAndFamily,   // DWORD
    const(wchar)* pszFaceName   // LPCWSTR optional
);
ccall((:CreateFontW, "GDI32.dll"), stdcall, Ptr{Cvoid},
      (Int32, Int32, Int32, Int32, Int32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, Cwstring),
      cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName)
# cHeight : INT -> Int32
# cWidth : INT -> Int32
# cEscapement : INT -> Int32
# cOrientation : INT -> Int32
# cWeight : INT -> Int32
# bItalic : DWORD -> UInt32
# bUnderline : DWORD -> UInt32
# bStrikeOut : DWORD -> UInt32
# iCharSet : DWORD -> UInt32
# iOutPrecision : DWORD -> UInt32
# iClipPrecision : DWORD -> UInt32
# iQuality : DWORD -> UInt32
# iPitchAndFamily : DWORD -> UInt32
# pszFaceName : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
void* CreateFontW(
    int32_t cHeight,
    int32_t cWidth,
    int32_t cEscapement,
    int32_t cOrientation,
    int32_t cWeight,
    uint32_t bItalic,
    uint32_t bUnderline,
    uint32_t bStrikeOut,
    uint32_t iCharSet,
    uint32_t iOutPrecision,
    uint32_t iClipPrecision,
    uint32_t iQuality,
    uint32_t iPitchAndFamily,
    const uint16_t* pszFaceName);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName)
-- cHeight : INT
-- cWidth : INT
-- cEscapement : INT
-- cOrientation : INT
-- cWeight : INT
-- bItalic : DWORD
-- bUnderline : DWORD
-- bStrikeOut : DWORD
-- iCharSet : DWORD
-- iOutPrecision : DWORD
-- iClipPrecision : DWORD
-- iQuality : DWORD
-- iPitchAndFamily : DWORD
-- pszFaceName : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const CreateFontW = lib.func('__stdcall', 'CreateFontW', 'void *', ['int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'str16']);
// CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName)
// cHeight : INT -> 'int32_t'
// cWidth : INT -> 'int32_t'
// cEscapement : INT -> 'int32_t'
// cOrientation : INT -> 'int32_t'
// cWeight : INT -> 'int32_t'
// bItalic : DWORD -> 'uint32_t'
// bUnderline : DWORD -> 'uint32_t'
// bStrikeOut : DWORD -> 'uint32_t'
// iCharSet : DWORD -> 'uint32_t'
// iOutPrecision : DWORD -> 'uint32_t'
// iClipPrecision : DWORD -> 'uint32_t'
// iQuality : DWORD -> 'uint32_t'
// iPitchAndFamily : DWORD -> 'uint32_t'
// pszFaceName : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("GDI32.dll", {
  CreateFontW: { parameters: ["i32", "i32", "i32", "i32", "i32", "u32", "u32", "u32", "u32", "u32", "u32", "u32", "u32", "buffer"], result: "pointer" },
});
// lib.symbols.CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName)
// cHeight : INT -> "i32"
// cWidth : INT -> "i32"
// cEscapement : INT -> "i32"
// cOrientation : INT -> "i32"
// cWeight : INT -> "i32"
// bItalic : DWORD -> "u32"
// bUnderline : DWORD -> "u32"
// bStrikeOut : DWORD -> "u32"
// iCharSet : DWORD -> "u32"
// iOutPrecision : DWORD -> "u32"
// iClipPrecision : DWORD -> "u32"
// iQuality : DWORD -> "u32"
// iPitchAndFamily : DWORD -> "u32"
// pszFaceName : LPCWSTR optional -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* CreateFontW(
    int32_t cHeight,
    int32_t cWidth,
    int32_t cEscapement,
    int32_t cOrientation,
    int32_t cWeight,
    uint32_t bItalic,
    uint32_t bUnderline,
    uint32_t bStrikeOut,
    uint32_t iCharSet,
    uint32_t iOutPrecision,
    uint32_t iClipPrecision,
    uint32_t iQuality,
    uint32_t iPitchAndFamily,
    const uint16_t* pszFaceName);
C, "GDI32.dll");
// $ffi->CreateFontW(cHeight, cWidth, cEscapement, cOrientation, cWeight, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision, iClipPrecision, iQuality, iPitchAndFamily, pszFaceName);
// cHeight : INT
// cWidth : INT
// cEscapement : INT
// cOrientation : INT
// cWeight : INT
// bItalic : DWORD
// bUnderline : DWORD
// bStrikeOut : DWORD
// iCharSet : DWORD
// iOutPrecision : DWORD
// iClipPrecision : DWORD
// iQuality : DWORD
// iPitchAndFamily : DWORD
// pszFaceName : LPCWSTR optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Gdi32 extends StdCallLibrary {
    Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class, W32APIOptions.UNICODE_OPTIONS);
    Pointer CreateFontW(
        int cHeight,   // INT
        int cWidth,   // INT
        int cEscapement,   // INT
        int cOrientation,   // INT
        int cWeight,   // INT
        int bItalic,   // DWORD
        int bUnderline,   // DWORD
        int bStrikeOut,   // DWORD
        int iCharSet,   // DWORD
        int iOutPrecision,   // DWORD
        int iClipPrecision,   // DWORD
        int iQuality,   // DWORD
        int iPitchAndFamily,   // DWORD
        WString pszFaceName   // LPCWSTR optional
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("gdi32")]
lib LibGDI32
  fun CreateFontW = CreateFontW(
    cHeight : Int32,   # INT
    cWidth : Int32,   # INT
    cEscapement : Int32,   # INT
    cOrientation : Int32,   # INT
    cWeight : Int32,   # INT
    bItalic : UInt32,   # DWORD
    bUnderline : UInt32,   # DWORD
    bStrikeOut : UInt32,   # DWORD
    iCharSet : UInt32,   # DWORD
    iOutPrecision : UInt32,   # DWORD
    iClipPrecision : UInt32,   # DWORD
    iQuality : UInt32,   # DWORD
    iPitchAndFamily : UInt32,   # DWORD
    pszFaceName : UInt16*   # LPCWSTR optional
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CreateFontWNative = Pointer<Void> Function(Int32, Int32, Int32, Int32, Int32, Uint32, Uint32, Uint32, Uint32, Uint32, Uint32, Uint32, Uint32, Pointer<Utf16>);
typedef CreateFontWDart = Pointer<Void> Function(int, int, int, int, int, int, int, int, int, int, int, int, int, Pointer<Utf16>);
final CreateFontW = DynamicLibrary.open('GDI32.dll')
    .lookupFunction<CreateFontWNative, CreateFontWDart>('CreateFontW');
// cHeight : INT -> Int32
// cWidth : INT -> Int32
// cEscapement : INT -> Int32
// cOrientation : INT -> Int32
// cWeight : INT -> Int32
// bItalic : DWORD -> Uint32
// bUnderline : DWORD -> Uint32
// bStrikeOut : DWORD -> Uint32
// iCharSet : DWORD -> Uint32
// iOutPrecision : DWORD -> Uint32
// iClipPrecision : DWORD -> Uint32
// iQuality : DWORD -> Uint32
// iPitchAndFamily : DWORD -> Uint32
// pszFaceName : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CreateFontW(
  cHeight: Integer;   // INT
  cWidth: Integer;   // INT
  cEscapement: Integer;   // INT
  cOrientation: Integer;   // INT
  cWeight: Integer;   // INT
  bItalic: DWORD;   // DWORD
  bUnderline: DWORD;   // DWORD
  bStrikeOut: DWORD;   // DWORD
  iCharSet: DWORD;   // DWORD
  iOutPrecision: DWORD;   // DWORD
  iClipPrecision: DWORD;   // DWORD
  iQuality: DWORD;   // DWORD
  iPitchAndFamily: DWORD;   // DWORD
  pszFaceName: PWideChar   // LPCWSTR optional
): THandle; stdcall;
  external 'GDI32.dll' name 'CreateFontW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CreateFontW"
  c_CreateFontW :: Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> CWString -> IO (Ptr ())
-- cHeight : INT -> Int32
-- cWidth : INT -> Int32
-- cEscapement : INT -> Int32
-- cOrientation : INT -> Int32
-- cWeight : INT -> Int32
-- bItalic : DWORD -> Word32
-- bUnderline : DWORD -> Word32
-- bStrikeOut : DWORD -> Word32
-- iCharSet : DWORD -> Word32
-- iOutPrecision : DWORD -> Word32
-- iClipPrecision : DWORD -> Word32
-- iQuality : DWORD -> Word32
-- iPitchAndFamily : DWORD -> Word32
-- pszFaceName : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let createfontw =
  foreign "CreateFontW"
    (int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint16_t) @-> returning (ptr void))
(* cHeight : INT -> int32_t *)
(* cWidth : INT -> int32_t *)
(* cEscapement : INT -> int32_t *)
(* cOrientation : INT -> int32_t *)
(* cWeight : INT -> int32_t *)
(* bItalic : DWORD -> uint32_t *)
(* bUnderline : DWORD -> uint32_t *)
(* bStrikeOut : DWORD -> uint32_t *)
(* iCharSet : DWORD -> uint32_t *)
(* iOutPrecision : DWORD -> uint32_t *)
(* iClipPrecision : DWORD -> uint32_t *)
(* iQuality : DWORD -> uint32_t *)
(* iPitchAndFamily : DWORD -> uint32_t *)
(* pszFaceName : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)

(cffi:defcfun ("CreateFontW" create-font-w :convention :stdcall) :pointer
  (c-height :int32)   ; INT
  (c-width :int32)   ; INT
  (c-escapement :int32)   ; INT
  (c-orientation :int32)   ; INT
  (c-weight :int32)   ; INT
  (b-italic :uint32)   ; DWORD
  (b-underline :uint32)   ; DWORD
  (b-strike-out :uint32)   ; DWORD
  (i-char-set :uint32)   ; DWORD
  (i-out-precision :uint32)   ; DWORD
  (i-clip-precision :uint32)   ; DWORD
  (i-quality :uint32)   ; DWORD
  (i-pitch-and-family :uint32)   ; DWORD
  (psz-face-name (:string :encoding :utf-16le)))   ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CreateFontW = Win32::API::More->new('GDI32',
    'HANDLE CreateFontW(int cHeight, int cWidth, int cEscapement, int cOrientation, int cWeight, DWORD bItalic, DWORD bUnderline, DWORD bStrikeOut, DWORD iCharSet, DWORD iOutPrecision, DWORD iClipPrecision, DWORD iQuality, DWORD iPitchAndFamily, LPCWSTR pszFaceName)');
# my $ret = $CreateFontW->Call($cHeight, $cWidth, $cEscapement, $cOrientation, $cWeight, $bItalic, $bUnderline, $bStrikeOut, $iCharSet, $iOutPrecision, $iClipPrecision, $iQuality, $iPitchAndFamily, $pszFaceName);
# cHeight : INT -> int
# cWidth : INT -> int
# cEscapement : INT -> int
# cOrientation : INT -> int
# cWeight : INT -> int
# bItalic : DWORD -> DWORD
# bUnderline : DWORD -> DWORD
# bStrikeOut : DWORD -> DWORD
# iCharSet : DWORD -> DWORD
# iOutPrecision : DWORD -> DWORD
# iClipPrecision : DWORD -> DWORD
# iQuality : DWORD -> DWORD
# iPitchAndFamily : DWORD -> DWORD
# pszFaceName : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
公式の関連項目