Win32 API 日本語リファレンス
ホームGlobalization › ENUMTEXTMETRICW

ENUMTEXTMETRICW

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

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

フィールド

フィールドサイズx64x86説明
etmNewTextMetricExNEWTEXTMETRICEXW100+0+0列挙されたフォントの拡張テキストメトリック情報(Unicode)。
etmAxesListAXESLISTW648+100+100マルチプルマスターフォントの可変軸一覧を保持するAXESLISTW構造体。

各言語での定義

#include <windows.h>

// NEWTEXTMETRICW  (x64 76 / x86 76 バイト)
typedef struct NEWTEXTMETRICW {
    INT tmHeight;
    INT tmAscent;
    INT tmDescent;
    INT tmInternalLeading;
    INT tmExternalLeading;
    INT tmAveCharWidth;
    INT tmMaxCharWidth;
    INT tmWeight;
    INT tmOverhang;
    INT tmDigitizedAspectX;
    INT tmDigitizedAspectY;
    WCHAR tmFirstChar;
    WCHAR tmLastChar;
    WCHAR tmDefaultChar;
    WCHAR tmBreakChar;
    BYTE tmItalic;
    BYTE tmUnderlined;
    BYTE tmStruckOut;
    TMPF_FLAGS tmPitchAndFamily;
    BYTE tmCharSet;
    DWORD ntmFlags;
    DWORD ntmSizeEM;
    DWORD ntmCellHeight;
    DWORD ntmAvgWidth;
} NEWTEXTMETRICW;

// FONTSIGNATURE  (x64 24 / x86 24 バイト)
typedef struct FONTSIGNATURE {
    DWORD fsUsb[4];
    DWORD fsCsb[2];
} FONTSIGNATURE;

// NEWTEXTMETRICEXW  (x64 100 / x86 100 バイト)
typedef struct NEWTEXTMETRICEXW {
    NEWTEXTMETRICW ntmTm;
    FONTSIGNATURE ntmFontSig;
} NEWTEXTMETRICEXW;

// AXISINFOW  (x64 40 / x86 40 バイト)
typedef struct AXISINFOW {
    INT axMinValue;
    INT axMaxValue;
    WCHAR axAxisName[16];
} AXISINFOW;

// AXESLISTW  (x64 648 / x86 648 バイト)
typedef struct AXESLISTW {
    DWORD axlReserved;
    DWORD axlNumAxes;
    AXISINFOW axlAxisInfo[16];
} AXESLISTW;

// ENUMTEXTMETRICW  (x64 748 / x86 748 バイト)
typedef struct ENUMTEXTMETRICW {
    NEWTEXTMETRICEXW etmNewTextMetricEx;
    AXESLISTW etmAxesList;
} ENUMTEXTMETRICW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NEWTEXTMETRICW
{
    public int tmHeight;
    public int tmAscent;
    public int tmDescent;
    public int tmInternalLeading;
    public int tmExternalLeading;
    public int tmAveCharWidth;
    public int tmMaxCharWidth;
    public int tmWeight;
    public int tmOverhang;
    public int tmDigitizedAspectX;
    public int tmDigitizedAspectY;
    public char tmFirstChar;
    public char tmLastChar;
    public char tmDefaultChar;
    public char tmBreakChar;
    public byte tmItalic;
    public byte tmUnderlined;
    public byte tmStruckOut;
    public byte tmPitchAndFamily;
    public byte tmCharSet;
    public uint ntmFlags;
    public uint ntmSizeEM;
    public uint ntmCellHeight;
    public uint ntmAvgWidth;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FONTSIGNATURE
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint[] fsUsb;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] fsCsb;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NEWTEXTMETRICEXW
{
    public NEWTEXTMETRICW ntmTm;
    public FONTSIGNATURE ntmFontSig;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AXISINFOW
{
    public int axMinValue;
    public int axMaxValue;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string axAxisName;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AXESLISTW
{
    public uint axlReserved;
    public uint axlNumAxes;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public AXISINFOW[] axlAxisInfo;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ENUMTEXTMETRICW
{
    public NEWTEXTMETRICEXW etmNewTextMetricEx;
    public AXESLISTW etmAxesList;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NEWTEXTMETRICW
    Public tmHeight As Integer
    Public tmAscent As Integer
    Public tmDescent As Integer
    Public tmInternalLeading As Integer
    Public tmExternalLeading As Integer
    Public tmAveCharWidth As Integer
    Public tmMaxCharWidth As Integer
    Public tmWeight As Integer
    Public tmOverhang As Integer
    Public tmDigitizedAspectX As Integer
    Public tmDigitizedAspectY As Integer
    Public tmFirstChar As Char
    Public tmLastChar As Char
    Public tmDefaultChar As Char
    Public tmBreakChar As Char
    Public tmItalic As Byte
    Public tmUnderlined As Byte
    Public tmStruckOut As Byte
    Public tmPitchAndFamily As Byte
    Public tmCharSet As Byte
    Public ntmFlags As UInteger
    Public ntmSizeEM As UInteger
    Public ntmCellHeight As UInteger
    Public ntmAvgWidth As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FONTSIGNATURE
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public fsUsb() As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public fsCsb() As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NEWTEXTMETRICEXW
    Public ntmTm As NEWTEXTMETRICW
    Public ntmFontSig As FONTSIGNATURE
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure AXISINFOW
    Public axMinValue As Integer
    Public axMaxValue As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=16)> Public axAxisName As String
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure AXESLISTW
    Public axlReserved As UInteger
    Public axlNumAxes As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public axlAxisInfo() As AXISINFOW
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ENUMTEXTMETRICW
    Public etmNewTextMetricEx As NEWTEXTMETRICEXW
    Public etmAxesList As AXESLISTW
End Structure
import ctypes
from ctypes import wintypes

class NEWTEXTMETRICW(ctypes.Structure):
    _fields_ = [
        ("tmHeight", ctypes.c_int),
        ("tmAscent", ctypes.c_int),
        ("tmDescent", ctypes.c_int),
        ("tmInternalLeading", ctypes.c_int),
        ("tmExternalLeading", ctypes.c_int),
        ("tmAveCharWidth", ctypes.c_int),
        ("tmMaxCharWidth", ctypes.c_int),
        ("tmWeight", ctypes.c_int),
        ("tmOverhang", ctypes.c_int),
        ("tmDigitizedAspectX", ctypes.c_int),
        ("tmDigitizedAspectY", ctypes.c_int),
        ("tmFirstChar", ctypes.c_wchar),
        ("tmLastChar", ctypes.c_wchar),
        ("tmDefaultChar", ctypes.c_wchar),
        ("tmBreakChar", ctypes.c_wchar),
        ("tmItalic", ctypes.c_ubyte),
        ("tmUnderlined", ctypes.c_ubyte),
        ("tmStruckOut", ctypes.c_ubyte),
        ("tmPitchAndFamily", ctypes.c_ubyte),
        ("tmCharSet", ctypes.c_ubyte),
        ("ntmFlags", wintypes.DWORD),
        ("ntmSizeEM", wintypes.DWORD),
        ("ntmCellHeight", wintypes.DWORD),
        ("ntmAvgWidth", wintypes.DWORD),
    ]

class FONTSIGNATURE(ctypes.Structure):
    _fields_ = [
        ("fsUsb", wintypes.DWORD * 4),
        ("fsCsb", wintypes.DWORD * 2),
    ]

class NEWTEXTMETRICEXW(ctypes.Structure):
    _fields_ = [
        ("ntmTm", NEWTEXTMETRICW),
        ("ntmFontSig", FONTSIGNATURE),
    ]

class AXISINFOW(ctypes.Structure):
    _fields_ = [
        ("axMinValue", ctypes.c_int),
        ("axMaxValue", ctypes.c_int),
        ("axAxisName", ctypes.c_wchar * 16),
    ]

class AXESLISTW(ctypes.Structure):
    _fields_ = [
        ("axlReserved", wintypes.DWORD),
        ("axlNumAxes", wintypes.DWORD),
        ("axlAxisInfo", AXISINFOW * 16),
    ]

class ENUMTEXTMETRICW(ctypes.Structure):
    _fields_ = [
        ("etmNewTextMetricEx", NEWTEXTMETRICEXW),
        ("etmAxesList", AXESLISTW),
    ]
#[repr(C)]
pub struct NEWTEXTMETRICW {
    pub tmHeight: i32,
    pub tmAscent: i32,
    pub tmDescent: i32,
    pub tmInternalLeading: i32,
    pub tmExternalLeading: i32,
    pub tmAveCharWidth: i32,
    pub tmMaxCharWidth: i32,
    pub tmWeight: i32,
    pub tmOverhang: i32,
    pub tmDigitizedAspectX: i32,
    pub tmDigitizedAspectY: i32,
    pub tmFirstChar: u16,
    pub tmLastChar: u16,
    pub tmDefaultChar: u16,
    pub tmBreakChar: u16,
    pub tmItalic: u8,
    pub tmUnderlined: u8,
    pub tmStruckOut: u8,
    pub tmPitchAndFamily: u8,
    pub tmCharSet: u8,
    pub ntmFlags: u32,
    pub ntmSizeEM: u32,
    pub ntmCellHeight: u32,
    pub ntmAvgWidth: u32,
}

#[repr(C)]
pub struct FONTSIGNATURE {
    pub fsUsb: [u32; 4],
    pub fsCsb: [u32; 2],
}

#[repr(C)]
pub struct NEWTEXTMETRICEXW {
    pub ntmTm: NEWTEXTMETRICW,
    pub ntmFontSig: FONTSIGNATURE,
}

#[repr(C)]
pub struct AXISINFOW {
    pub axMinValue: i32,
    pub axMaxValue: i32,
    pub axAxisName: [u16; 16],
}

#[repr(C)]
pub struct AXESLISTW {
    pub axlReserved: u32,
    pub axlNumAxes: u32,
    pub axlAxisInfo: [AXISINFOW; 16],
}

#[repr(C)]
pub struct ENUMTEXTMETRICW {
    pub etmNewTextMetricEx: NEWTEXTMETRICEXW,
    pub etmAxesList: AXESLISTW,
}
import "golang.org/x/sys/windows"

type NEWTEXTMETRICW struct {
	tmHeight int32
	tmAscent int32
	tmDescent int32
	tmInternalLeading int32
	tmExternalLeading int32
	tmAveCharWidth int32
	tmMaxCharWidth int32
	tmWeight int32
	tmOverhang int32
	tmDigitizedAspectX int32
	tmDigitizedAspectY int32
	tmFirstChar uint16
	tmLastChar uint16
	tmDefaultChar uint16
	tmBreakChar uint16
	tmItalic byte
	tmUnderlined byte
	tmStruckOut byte
	tmPitchAndFamily byte
	tmCharSet byte
	ntmFlags uint32
	ntmSizeEM uint32
	ntmCellHeight uint32
	ntmAvgWidth uint32
}

type FONTSIGNATURE struct {
	fsUsb [4]uint32
	fsCsb [2]uint32
}

type NEWTEXTMETRICEXW struct {
	ntmTm NEWTEXTMETRICW
	ntmFontSig FONTSIGNATURE
}

type AXISINFOW struct {
	axMinValue int32
	axMaxValue int32
	axAxisName [16]uint16
}

type AXESLISTW struct {
	axlReserved uint32
	axlNumAxes uint32
	axlAxisInfo [16]AXISINFOW
}

type ENUMTEXTMETRICW struct {
	etmNewTextMetricEx NEWTEXTMETRICEXW
	etmAxesList AXESLISTW
}
type
  NEWTEXTMETRICW = record
    tmHeight: Integer;
    tmAscent: Integer;
    tmDescent: Integer;
    tmInternalLeading: Integer;
    tmExternalLeading: Integer;
    tmAveCharWidth: Integer;
    tmMaxCharWidth: Integer;
    tmWeight: Integer;
    tmOverhang: Integer;
    tmDigitizedAspectX: Integer;
    tmDigitizedAspectY: Integer;
    tmFirstChar: WideChar;
    tmLastChar: WideChar;
    tmDefaultChar: WideChar;
    tmBreakChar: WideChar;
    tmItalic: Byte;
    tmUnderlined: Byte;
    tmStruckOut: Byte;
    tmPitchAndFamily: Byte;
    tmCharSet: Byte;
    ntmFlags: DWORD;
    ntmSizeEM: DWORD;
    ntmCellHeight: DWORD;
    ntmAvgWidth: DWORD;
  end;

  FONTSIGNATURE = record
    fsUsb: array[0..3] of DWORD;
    fsCsb: array[0..1] of DWORD;
  end;

  NEWTEXTMETRICEXW = record
    ntmTm: NEWTEXTMETRICW;
    ntmFontSig: FONTSIGNATURE;
  end;

  AXISINFOW = record
    axMinValue: Integer;
    axMaxValue: Integer;
    axAxisName: array[0..15] of WideChar;
  end;

  AXESLISTW = record
    axlReserved: DWORD;
    axlNumAxes: DWORD;
    axlAxisInfo: array[0..15] of AXISINFOW;
  end;

  ENUMTEXTMETRICW = record
    etmNewTextMetricEx: NEWTEXTMETRICEXW;
    etmAxesList: AXESLISTW;
  end;
const NEWTEXTMETRICW = extern struct {
    tmHeight: i32,
    tmAscent: i32,
    tmDescent: i32,
    tmInternalLeading: i32,
    tmExternalLeading: i32,
    tmAveCharWidth: i32,
    tmMaxCharWidth: i32,
    tmWeight: i32,
    tmOverhang: i32,
    tmDigitizedAspectX: i32,
    tmDigitizedAspectY: i32,
    tmFirstChar: u16,
    tmLastChar: u16,
    tmDefaultChar: u16,
    tmBreakChar: u16,
    tmItalic: u8,
    tmUnderlined: u8,
    tmStruckOut: u8,
    tmPitchAndFamily: u8,
    tmCharSet: u8,
    ntmFlags: u32,
    ntmSizeEM: u32,
    ntmCellHeight: u32,
    ntmAvgWidth: u32,
};

const FONTSIGNATURE = extern struct {
    fsUsb: [4]u32,
    fsCsb: [2]u32,
};

const NEWTEXTMETRICEXW = extern struct {
    ntmTm: NEWTEXTMETRICW,
    ntmFontSig: FONTSIGNATURE,
};

const AXISINFOW = extern struct {
    axMinValue: i32,
    axMaxValue: i32,
    axAxisName: [16]u16,
};

const AXESLISTW = extern struct {
    axlReserved: u32,
    axlNumAxes: u32,
    axlAxisInfo: [16]AXISINFOW,
};

const ENUMTEXTMETRICW = extern struct {
    etmNewTextMetricEx: NEWTEXTMETRICEXW,
    etmAxesList: AXESLISTW,
};
type
  NEWTEXTMETRICW {.bycopy.} = object
    tmHeight: int32
    tmAscent: int32
    tmDescent: int32
    tmInternalLeading: int32
    tmExternalLeading: int32
    tmAveCharWidth: int32
    tmMaxCharWidth: int32
    tmWeight: int32
    tmOverhang: int32
    tmDigitizedAspectX: int32
    tmDigitizedAspectY: int32
    tmFirstChar: uint16
    tmLastChar: uint16
    tmDefaultChar: uint16
    tmBreakChar: uint16
    tmItalic: uint8
    tmUnderlined: uint8
    tmStruckOut: uint8
    tmPitchAndFamily: uint8
    tmCharSet: uint8
    ntmFlags: uint32
    ntmSizeEM: uint32
    ntmCellHeight: uint32
    ntmAvgWidth: uint32

  FONTSIGNATURE {.bycopy.} = object
    fsUsb: array[4, uint32]
    fsCsb: array[2, uint32]

  NEWTEXTMETRICEXW {.bycopy.} = object
    ntmTm: NEWTEXTMETRICW
    ntmFontSig: FONTSIGNATURE

  AXISINFOW {.bycopy.} = object
    axMinValue: int32
    axMaxValue: int32
    axAxisName: array[16, uint16]

  AXESLISTW {.bycopy.} = object
    axlReserved: uint32
    axlNumAxes: uint32
    axlAxisInfo: array[16, AXISINFOW]

  ENUMTEXTMETRICW {.bycopy.} = object
    etmNewTextMetricEx: NEWTEXTMETRICEXW
    etmAxesList: AXESLISTW
struct NEWTEXTMETRICW
{
    int tmHeight;
    int tmAscent;
    int tmDescent;
    int tmInternalLeading;
    int tmExternalLeading;
    int tmAveCharWidth;
    int tmMaxCharWidth;
    int tmWeight;
    int tmOverhang;
    int tmDigitizedAspectX;
    int tmDigitizedAspectY;
    wchar tmFirstChar;
    wchar tmLastChar;
    wchar tmDefaultChar;
    wchar tmBreakChar;
    ubyte tmItalic;
    ubyte tmUnderlined;
    ubyte tmStruckOut;
    ubyte tmPitchAndFamily;
    ubyte tmCharSet;
    uint ntmFlags;
    uint ntmSizeEM;
    uint ntmCellHeight;
    uint ntmAvgWidth;
}

struct FONTSIGNATURE
{
    uint[4] fsUsb;
    uint[2] fsCsb;
}

struct NEWTEXTMETRICEXW
{
    NEWTEXTMETRICW ntmTm;
    FONTSIGNATURE ntmFontSig;
}

struct AXISINFOW
{
    int axMinValue;
    int axMaxValue;
    wchar[16] axAxisName;
}

struct AXESLISTW
{
    uint axlReserved;
    uint axlNumAxes;
    AXISINFOW[16] axlAxisInfo;
}

struct ENUMTEXTMETRICW
{
    NEWTEXTMETRICEXW etmNewTextMetricEx;
    AXESLISTW etmAxesList;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ENUMTEXTMETRICW サイズ: 748 バイト(x64)
dim st, 187    ; 4byte整数×187(構造体サイズ 748 / 4 切り上げ)
; etmNewTextMetricEx : NEWTEXTMETRICEXW (+0, 100byte)  varptr(st)+0 を基点に操作(100byte:入れ子/配列)
; etmAxesList : AXESLISTW (+100, 648byte)  varptr(st)+100 を基点に操作(648byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global NEWTEXTMETRICW
    #field int tmHeight
    #field int tmAscent
    #field int tmDescent
    #field int tmInternalLeading
    #field int tmExternalLeading
    #field int tmAveCharWidth
    #field int tmMaxCharWidth
    #field int tmWeight
    #field int tmOverhang
    #field int tmDigitizedAspectX
    #field int tmDigitizedAspectY
    #field short tmFirstChar
    #field short tmLastChar
    #field short tmDefaultChar
    #field short tmBreakChar
    #field byte tmItalic
    #field byte tmUnderlined
    #field byte tmStruckOut
    #field byte tmPitchAndFamily
    #field byte tmCharSet
    #field int ntmFlags
    #field int ntmSizeEM
    #field int ntmCellHeight
    #field int ntmAvgWidth
#endstruct

#defstruct global FONTSIGNATURE
    #field int fsUsb 4
    #field int fsCsb 2
#endstruct

#defstruct global NEWTEXTMETRICEXW
    #field NEWTEXTMETRICW ntmTm
    #field FONTSIGNATURE ntmFontSig
#endstruct

#defstruct global AXISINFOW
    #field int axMinValue
    #field int axMaxValue
    #field wchar axAxisName 16
#endstruct

#defstruct global AXESLISTW
    #field int axlReserved
    #field int axlNumAxes
    #field AXISINFOW axlAxisInfo 16
#endstruct

#defstruct global ENUMTEXTMETRICW
    #field NEWTEXTMETRICEXW etmNewTextMetricEx
    #field AXESLISTW etmAxesList
#endstruct

stdim st, ENUMTEXTMETRICW        ; NSTRUCT 変数を確保