ホーム › Graphics.Gdi › EMREXTCREATEFONTINDIRECTW
EMREXTCREATEFONTINDIRECTW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| emr | EMR | 8 | +0 | +0 | 共通レコードヘッダを表すEMR構造体。 |
| ihFont | DWORD | 4 | +8 | +8 | 作成するフォントのハンドルテーブル内インデックスを表す。 |
| elfw | EXTLOGFONTW | 320 | +12 | +12 | 作成する論理フォントの拡張情報を表すEXTLOGFONTW構造体。 |
各言語での定義
#include <windows.h>
// EMR (x64 8 / x86 8 バイト)
typedef struct EMR {
ENHANCED_METAFILE_RECORD_TYPE iType;
DWORD nSize;
} EMR;
// LOGFONTW (x64 92 / x86 92 バイト)
typedef struct LOGFONTW {
INT lfHeight;
INT lfWidth;
INT lfEscapement;
INT lfOrientation;
INT lfWeight;
BYTE lfItalic;
BYTE lfUnderline;
BYTE lfStrikeOut;
FONT_CHARSET lfCharSet;
FONT_OUTPUT_PRECISION lfOutPrecision;
FONT_CLIP_PRECISION lfClipPrecision;
FONT_QUALITY lfQuality;
BYTE lfPitchAndFamily;
WCHAR lfFaceName[32];
} LOGFONTW;
// PANOSE (x64 10 / x86 10 バイト)
typedef struct PANOSE {
PAN_FAMILY_TYPE bFamilyType;
PAN_SERIF_STYLE bSerifStyle;
PAN_WEIGHT bWeight;
PAN_PROPORTION bProportion;
PAN_CONTRAST bContrast;
PAN_STROKE_VARIATION bStrokeVariation;
PAN_ARM_STYLE bArmStyle;
PAN_LETT_FORM bLetterform;
PAN_MIDLINE bMidline;
PAN_XHEIGHT bXHeight;
} PANOSE;
// EXTLOGFONTW (x64 320 / x86 320 バイト)
typedef struct EXTLOGFONTW {
LOGFONTW elfLogFont;
WCHAR elfFullName[64];
WCHAR elfStyle[32];
DWORD elfVersion;
DWORD elfStyleSize;
DWORD elfMatch;
DWORD elfReserved;
BYTE elfVendorId[4];
DWORD elfCulture;
PANOSE elfPanose;
} EXTLOGFONTW;
// EMREXTCREATEFONTINDIRECTW (x64 332 / x86 332 バイト)
typedef struct EMREXTCREATEFONTINDIRECTW {
EMR emr;
DWORD ihFont;
EXTLOGFONTW elfw;
} EMREXTCREATEFONTINDIRECTW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMR
{
public uint iType;
public uint nSize;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LOGFONTW
{
public int lfHeight;
public int lfWidth;
public int lfEscapement;
public int lfOrientation;
public int lfWeight;
public byte lfItalic;
public byte lfUnderline;
public byte lfStrikeOut;
public byte lfCharSet;
public byte lfOutPrecision;
public byte lfClipPrecision;
public byte lfQuality;
public byte lfPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string lfFaceName;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PANOSE
{
public byte bFamilyType;
public byte bSerifStyle;
public byte bWeight;
public byte bProportion;
public byte bContrast;
public byte bStrokeVariation;
public byte bArmStyle;
public byte bLetterform;
public byte bMidline;
public byte bXHeight;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EXTLOGFONTW
{
public LOGFONTW elfLogFont;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string elfFullName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string elfStyle;
public uint elfVersion;
public uint elfStyleSize;
public uint elfMatch;
public uint elfReserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] elfVendorId;
public uint elfCulture;
public PANOSE elfPanose;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMREXTCREATEFONTINDIRECTW
{
public EMR emr;
public uint ihFont;
public EXTLOGFONTW elfw;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMR
Public iType As UInteger
Public nSize As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LOGFONTW
Public lfHeight As Integer
Public lfWidth As Integer
Public lfEscapement As Integer
Public lfOrientation As Integer
Public lfWeight As Integer
Public lfItalic As Byte
Public lfUnderline As Byte
Public lfStrikeOut As Byte
Public lfCharSet As Byte
Public lfOutPrecision As Byte
Public lfClipPrecision As Byte
Public lfQuality As Byte
Public lfPitchAndFamily As Byte
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public lfFaceName As String
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PANOSE
Public bFamilyType As Byte
Public bSerifStyle As Byte
Public bWeight As Byte
Public bProportion As Byte
Public bContrast As Byte
Public bStrokeVariation As Byte
Public bArmStyle As Byte
Public bLetterform As Byte
Public bMidline As Byte
Public bXHeight As Byte
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EXTLOGFONTW
Public elfLogFont As LOGFONTW
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> Public elfFullName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public elfStyle As String
Public elfVersion As UInteger
Public elfStyleSize As UInteger
Public elfMatch As UInteger
Public elfReserved As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public elfVendorId() As Byte
Public elfCulture As UInteger
Public elfPanose As PANOSE
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMREXTCREATEFONTINDIRECTW
Public emr As EMR
Public ihFont As UInteger
Public elfw As EXTLOGFONTW
End Structureimport ctypes
from ctypes import wintypes
class EMR(ctypes.Structure):
_fields_ = [
("iType", wintypes.DWORD),
("nSize", wintypes.DWORD),
]
class LOGFONTW(ctypes.Structure):
_fields_ = [
("lfHeight", ctypes.c_int),
("lfWidth", ctypes.c_int),
("lfEscapement", ctypes.c_int),
("lfOrientation", ctypes.c_int),
("lfWeight", ctypes.c_int),
("lfItalic", ctypes.c_ubyte),
("lfUnderline", ctypes.c_ubyte),
("lfStrikeOut", ctypes.c_ubyte),
("lfCharSet", ctypes.c_ubyte),
("lfOutPrecision", ctypes.c_ubyte),
("lfClipPrecision", ctypes.c_ubyte),
("lfQuality", ctypes.c_ubyte),
("lfPitchAndFamily", ctypes.c_ubyte),
("lfFaceName", ctypes.c_wchar * 32),
]
class PANOSE(ctypes.Structure):
_fields_ = [
("bFamilyType", ctypes.c_ubyte),
("bSerifStyle", ctypes.c_ubyte),
("bWeight", ctypes.c_ubyte),
("bProportion", ctypes.c_ubyte),
("bContrast", ctypes.c_ubyte),
("bStrokeVariation", ctypes.c_ubyte),
("bArmStyle", ctypes.c_ubyte),
("bLetterform", ctypes.c_ubyte),
("bMidline", ctypes.c_ubyte),
("bXHeight", ctypes.c_ubyte),
]
class EXTLOGFONTW(ctypes.Structure):
_fields_ = [
("elfLogFont", LOGFONTW),
("elfFullName", ctypes.c_wchar * 64),
("elfStyle", ctypes.c_wchar * 32),
("elfVersion", wintypes.DWORD),
("elfStyleSize", wintypes.DWORD),
("elfMatch", wintypes.DWORD),
("elfReserved", wintypes.DWORD),
("elfVendorId", ctypes.c_ubyte * 4),
("elfCulture", wintypes.DWORD),
("elfPanose", PANOSE),
]
class EMREXTCREATEFONTINDIRECTW(ctypes.Structure):
_fields_ = [
("emr", EMR),
("ihFont", wintypes.DWORD),
("elfw", EXTLOGFONTW),
]#[repr(C)]
pub struct EMR {
pub iType: u32,
pub nSize: u32,
}
#[repr(C)]
pub struct LOGFONTW {
pub lfHeight: i32,
pub lfWidth: i32,
pub lfEscapement: i32,
pub lfOrientation: i32,
pub lfWeight: i32,
pub lfItalic: u8,
pub lfUnderline: u8,
pub lfStrikeOut: u8,
pub lfCharSet: u8,
pub lfOutPrecision: u8,
pub lfClipPrecision: u8,
pub lfQuality: u8,
pub lfPitchAndFamily: u8,
pub lfFaceName: [u16; 32],
}
#[repr(C)]
pub struct PANOSE {
pub bFamilyType: u8,
pub bSerifStyle: u8,
pub bWeight: u8,
pub bProportion: u8,
pub bContrast: u8,
pub bStrokeVariation: u8,
pub bArmStyle: u8,
pub bLetterform: u8,
pub bMidline: u8,
pub bXHeight: u8,
}
#[repr(C)]
pub struct EXTLOGFONTW {
pub elfLogFont: LOGFONTW,
pub elfFullName: [u16; 64],
pub elfStyle: [u16; 32],
pub elfVersion: u32,
pub elfStyleSize: u32,
pub elfMatch: u32,
pub elfReserved: u32,
pub elfVendorId: [u8; 4],
pub elfCulture: u32,
pub elfPanose: PANOSE,
}
#[repr(C)]
pub struct EMREXTCREATEFONTINDIRECTW {
pub emr: EMR,
pub ihFont: u32,
pub elfw: EXTLOGFONTW,
}import "golang.org/x/sys/windows"
type EMR struct {
iType uint32
nSize uint32
}
type LOGFONTW struct {
lfHeight int32
lfWidth int32
lfEscapement int32
lfOrientation int32
lfWeight int32
lfItalic byte
lfUnderline byte
lfStrikeOut byte
lfCharSet byte
lfOutPrecision byte
lfClipPrecision byte
lfQuality byte
lfPitchAndFamily byte
lfFaceName [32]uint16
}
type PANOSE struct {
bFamilyType byte
bSerifStyle byte
bWeight byte
bProportion byte
bContrast byte
bStrokeVariation byte
bArmStyle byte
bLetterform byte
bMidline byte
bXHeight byte
}
type EXTLOGFONTW struct {
elfLogFont LOGFONTW
elfFullName [64]uint16
elfStyle [32]uint16
elfVersion uint32
elfStyleSize uint32
elfMatch uint32
elfReserved uint32
elfVendorId [4]byte
elfCulture uint32
elfPanose PANOSE
}
type EMREXTCREATEFONTINDIRECTW struct {
emr EMR
ihFont uint32
elfw EXTLOGFONTW
}type
EMR = record
iType: DWORD;
nSize: DWORD;
end;
LOGFONTW = record
lfHeight: Integer;
lfWidth: Integer;
lfEscapement: Integer;
lfOrientation: Integer;
lfWeight: Integer;
lfItalic: Byte;
lfUnderline: Byte;
lfStrikeOut: Byte;
lfCharSet: Byte;
lfOutPrecision: Byte;
lfClipPrecision: Byte;
lfQuality: Byte;
lfPitchAndFamily: Byte;
lfFaceName: array[0..31] of WideChar;
end;
PANOSE = record
bFamilyType: Byte;
bSerifStyle: Byte;
bWeight: Byte;
bProportion: Byte;
bContrast: Byte;
bStrokeVariation: Byte;
bArmStyle: Byte;
bLetterform: Byte;
bMidline: Byte;
bXHeight: Byte;
end;
EXTLOGFONTW = record
elfLogFont: LOGFONTW;
elfFullName: array[0..63] of WideChar;
elfStyle: array[0..31] of WideChar;
elfVersion: DWORD;
elfStyleSize: DWORD;
elfMatch: DWORD;
elfReserved: DWORD;
elfVendorId: array[0..3] of Byte;
elfCulture: DWORD;
elfPanose: PANOSE;
end;
EMREXTCREATEFONTINDIRECTW = record
emr: EMR;
ihFont: DWORD;
elfw: EXTLOGFONTW;
end;const EMR = extern struct {
iType: u32,
nSize: u32,
};
const LOGFONTW = extern struct {
lfHeight: i32,
lfWidth: i32,
lfEscapement: i32,
lfOrientation: i32,
lfWeight: i32,
lfItalic: u8,
lfUnderline: u8,
lfStrikeOut: u8,
lfCharSet: u8,
lfOutPrecision: u8,
lfClipPrecision: u8,
lfQuality: u8,
lfPitchAndFamily: u8,
lfFaceName: [32]u16,
};
const PANOSE = extern struct {
bFamilyType: u8,
bSerifStyle: u8,
bWeight: u8,
bProportion: u8,
bContrast: u8,
bStrokeVariation: u8,
bArmStyle: u8,
bLetterform: u8,
bMidline: u8,
bXHeight: u8,
};
const EXTLOGFONTW = extern struct {
elfLogFont: LOGFONTW,
elfFullName: [64]u16,
elfStyle: [32]u16,
elfVersion: u32,
elfStyleSize: u32,
elfMatch: u32,
elfReserved: u32,
elfVendorId: [4]u8,
elfCulture: u32,
elfPanose: PANOSE,
};
const EMREXTCREATEFONTINDIRECTW = extern struct {
emr: EMR,
ihFont: u32,
elfw: EXTLOGFONTW,
};type
EMR {.bycopy.} = object
iType: uint32
nSize: uint32
LOGFONTW {.bycopy.} = object
lfHeight: int32
lfWidth: int32
lfEscapement: int32
lfOrientation: int32
lfWeight: int32
lfItalic: uint8
lfUnderline: uint8
lfStrikeOut: uint8
lfCharSet: uint8
lfOutPrecision: uint8
lfClipPrecision: uint8
lfQuality: uint8
lfPitchAndFamily: uint8
lfFaceName: array[32, uint16]
PANOSE {.bycopy.} = object
bFamilyType: uint8
bSerifStyle: uint8
bWeight: uint8
bProportion: uint8
bContrast: uint8
bStrokeVariation: uint8
bArmStyle: uint8
bLetterform: uint8
bMidline: uint8
bXHeight: uint8
EXTLOGFONTW {.bycopy.} = object
elfLogFont: LOGFONTW
elfFullName: array[64, uint16]
elfStyle: array[32, uint16]
elfVersion: uint32
elfStyleSize: uint32
elfMatch: uint32
elfReserved: uint32
elfVendorId: array[4, uint8]
elfCulture: uint32
elfPanose: PANOSE
EMREXTCREATEFONTINDIRECTW {.bycopy.} = object
emr: EMR
ihFont: uint32
elfw: EXTLOGFONTWstruct EMR
{
uint iType;
uint nSize;
}
struct LOGFONTW
{
int lfHeight;
int lfWidth;
int lfEscapement;
int lfOrientation;
int lfWeight;
ubyte lfItalic;
ubyte lfUnderline;
ubyte lfStrikeOut;
ubyte lfCharSet;
ubyte lfOutPrecision;
ubyte lfClipPrecision;
ubyte lfQuality;
ubyte lfPitchAndFamily;
wchar[32] lfFaceName;
}
struct PANOSE
{
ubyte bFamilyType;
ubyte bSerifStyle;
ubyte bWeight;
ubyte bProportion;
ubyte bContrast;
ubyte bStrokeVariation;
ubyte bArmStyle;
ubyte bLetterform;
ubyte bMidline;
ubyte bXHeight;
}
struct EXTLOGFONTW
{
LOGFONTW elfLogFont;
wchar[64] elfFullName;
wchar[32] elfStyle;
uint elfVersion;
uint elfStyleSize;
uint elfMatch;
uint elfReserved;
ubyte[4] elfVendorId;
uint elfCulture;
PANOSE elfPanose;
}
struct EMREXTCREATEFONTINDIRECTW
{
EMR emr;
uint ihFont;
EXTLOGFONTW elfw;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EMREXTCREATEFONTINDIRECTW サイズ: 332 バイト(x64)
dim st, 83 ; 4byte整数×83(構造体サイズ 332 / 4 切り上げ)
; emr : EMR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; ihFont : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; elfw : EXTLOGFONTW (+12, 320byte) varptr(st)+12 を基点に操作(320byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global EMR
#field int iType
#field int nSize
#endstruct
#defstruct global LOGFONTW
#field int lfHeight
#field int lfWidth
#field int lfEscapement
#field int lfOrientation
#field int lfWeight
#field byte lfItalic
#field byte lfUnderline
#field byte lfStrikeOut
#field byte lfCharSet
#field byte lfOutPrecision
#field byte lfClipPrecision
#field byte lfQuality
#field byte lfPitchAndFamily
#field wchar lfFaceName 32
#endstruct
#defstruct global PANOSE
#field byte bFamilyType
#field byte bSerifStyle
#field byte bWeight
#field byte bProportion
#field byte bContrast
#field byte bStrokeVariation
#field byte bArmStyle
#field byte bLetterform
#field byte bMidline
#field byte bXHeight
#endstruct
#defstruct global EXTLOGFONTW
#field LOGFONTW elfLogFont
#field wchar elfFullName 64
#field wchar elfStyle 32
#field int elfVersion
#field int elfStyleSize
#field int elfMatch
#field int elfReserved
#field byte elfVendorId 4
#field int elfCulture
#field PANOSE elfPanose
#endstruct
#defstruct global EMREXTCREATEFONTINDIRECTW
#field EMR emr
#field int ihFont
#field EXTLOGFONTW elfw
#endstruct
stdim st, EMREXTCREATEFONTINDIRECTW ; NSTRUCT 変数を確保
st->ihFont = 100
mes "ihFont=" + st->ihFont