Win32 API 日本語リファレンス
ホームSystem.Console › CONSOLE_FONT_INFOEX

CONSOLE_FONT_INFOEX

構造体
サイズx64: 84 バイト / x86: 84 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のバイトサイズ。呼び出し前に設定する。
nFontDWORD4+4+4フォントテーブル内のフォントインデックス。
dwFontSizeCOORD4+8+8フォントの幅と高さをピクセルで表すサイズ(COORD)。
FontFamilyDWORD4+12+12フォントファミリを示す値(FF_系定数)。
FontWeightDWORD4+16+16フォントの太さ(100〜1000、400が標準)。
FaceNameWCHAR64+20+20フォントのフェイス名(ワイド文字配列)。

各言語での定義

#include <windows.h>

// COORD  (x64 4 / x86 4 バイト)
typedef struct COORD {
    SHORT X;
    SHORT Y;
} COORD;

// CONSOLE_FONT_INFOEX  (x64 84 / x86 84 バイト)
typedef struct CONSOLE_FONT_INFOEX {
    DWORD cbSize;
    DWORD nFont;
    COORD dwFontSize;
    DWORD FontFamily;
    DWORD FontWeight;
    WCHAR FaceName[32];
} CONSOLE_FONT_INFOEX;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct COORD
{
    public short X;
    public short Y;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CONSOLE_FONT_INFOEX
{
    public uint cbSize;
    public uint nFont;
    public COORD dwFontSize;
    public uint FontFamily;
    public uint FontWeight;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string FaceName;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure COORD
    Public X As Short
    Public Y As Short
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CONSOLE_FONT_INFOEX
    Public cbSize As UInteger
    Public nFont As UInteger
    Public dwFontSize As COORD
    Public FontFamily As UInteger
    Public FontWeight As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public FaceName As String
End Structure
import ctypes
from ctypes import wintypes

class COORD(ctypes.Structure):
    _fields_ = [
        ("X", ctypes.c_short),
        ("Y", ctypes.c_short),
    ]

class CONSOLE_FONT_INFOEX(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("nFont", wintypes.DWORD),
        ("dwFontSize", COORD),
        ("FontFamily", wintypes.DWORD),
        ("FontWeight", wintypes.DWORD),
        ("FaceName", ctypes.c_wchar * 32),
    ]
#[repr(C)]
pub struct COORD {
    pub X: i16,
    pub Y: i16,
}

#[repr(C)]
pub struct CONSOLE_FONT_INFOEX {
    pub cbSize: u32,
    pub nFont: u32,
    pub dwFontSize: COORD,
    pub FontFamily: u32,
    pub FontWeight: u32,
    pub FaceName: [u16; 32],
}
import "golang.org/x/sys/windows"

type COORD struct {
	X int16
	Y int16
}

type CONSOLE_FONT_INFOEX struct {
	cbSize uint32
	nFont uint32
	dwFontSize COORD
	FontFamily uint32
	FontWeight uint32
	FaceName [32]uint16
}
type
  COORD = record
    X: Smallint;
    Y: Smallint;
  end;

  CONSOLE_FONT_INFOEX = record
    cbSize: DWORD;
    nFont: DWORD;
    dwFontSize: COORD;
    FontFamily: DWORD;
    FontWeight: DWORD;
    FaceName: array[0..31] of WideChar;
  end;
const COORD = extern struct {
    X: i16,
    Y: i16,
};

const CONSOLE_FONT_INFOEX = extern struct {
    cbSize: u32,
    nFont: u32,
    dwFontSize: COORD,
    FontFamily: u32,
    FontWeight: u32,
    FaceName: [32]u16,
};
type
  COORD {.bycopy.} = object
    X: int16
    Y: int16

  CONSOLE_FONT_INFOEX {.bycopy.} = object
    cbSize: uint32
    nFont: uint32
    dwFontSize: COORD
    FontFamily: uint32
    FontWeight: uint32
    FaceName: array[32, uint16]
struct COORD
{
    short X;
    short Y;
}

struct CONSOLE_FONT_INFOEX
{
    uint cbSize;
    uint nFont;
    COORD dwFontSize;
    uint FontFamily;
    uint FontWeight;
    wchar[32] FaceName;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CONSOLE_FONT_INFOEX サイズ: 84 バイト(x64)
dim st, 21    ; 4byte整数×21(構造体サイズ 84 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; nFont : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwFontSize : COORD (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; FontFamily : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; FontWeight : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; FaceName : WCHAR (+20, 64byte)  varptr(st)+20 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global COORD
    #field short X
    #field short Y
#endstruct

#defstruct global CONSOLE_FONT_INFOEX
    #field int cbSize
    #field int nFont
    #field COORD dwFontSize
    #field int FontFamily
    #field int FontWeight
    #field wchar FaceName 32
#endstruct

stdim st, CONSOLE_FONT_INFOEX        ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize