ホーム › System.Ole › FONTDESC
FONTDESC
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSizeofstruct | DWORD | 4 | +0 | +0 | この構造体のサイズをバイト単位で表す。 |
| lpstrName | LPWSTR | 8/4 | +8 | +4 | フォントのファミリ名を表すワイド文字列である。 |
| cySize | CY | 8 | +16 | +8 | フォントサイズをポイント単位で表すCY(通貨型)である。 |
| sWeight | SHORT | 2 | +24 | +16 | フォントの太さ(100〜900)を表す。 |
| sCharset | SHORT | 2 | +26 | +18 | フォントのキャラセット識別子である。 |
| fItalic | BOOL | 4 | +28 | +20 | 斜体かどうかを示すBOOLである。 |
| fUnderline | BOOL | 4 | +32 | +24 | 下線付きかどうかを示すBOOLである。 |
| fStrikethrough | BOOL | 4 | +36 | +28 | 取り消し線付きかどうかを示すBOOLである。 |
各言語での定義
#include <windows.h>
// CY (x64 8 / x86 8 バイト)
typedef struct CY {
_Anonymous_e__Struct Anonymous;
LONGLONG int64;
} CY;
// FONTDESC (x64 40 / x86 32 バイト)
typedef struct FONTDESC {
DWORD cbSizeofstruct;
LPWSTR lpstrName;
CY cySize;
SHORT sWeight;
SHORT sCharset;
BOOL fItalic;
BOOL fUnderline;
BOOL fStrikethrough;
} FONTDESC;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CY
{
public _Anonymous_e__Struct Anonymous;
public long int64;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FONTDESC
{
public uint cbSizeofstruct;
public IntPtr lpstrName;
public CY cySize;
public short sWeight;
public short sCharset;
[MarshalAs(UnmanagedType.Bool)] public bool fItalic;
[MarshalAs(UnmanagedType.Bool)] public bool fUnderline;
[MarshalAs(UnmanagedType.Bool)] public bool fStrikethrough;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CY
Public Anonymous As _Anonymous_e__Struct
Public int64 As Long
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FONTDESC
Public cbSizeofstruct As UInteger
Public lpstrName As IntPtr
Public cySize As CY
Public sWeight As Short
Public sCharset As Short
<MarshalAs(UnmanagedType.Bool)> Public fItalic As Boolean
<MarshalAs(UnmanagedType.Bool)> Public fUnderline As Boolean
<MarshalAs(UnmanagedType.Bool)> Public fStrikethrough As Boolean
End Structureimport ctypes
from ctypes import wintypes
class CY(ctypes.Structure):
_fields_ = [
("Anonymous", _Anonymous_e__Struct),
("int64", ctypes.c_longlong),
]
class FONTDESC(ctypes.Structure):
_fields_ = [
("cbSizeofstruct", wintypes.DWORD),
("lpstrName", ctypes.c_void_p),
("cySize", CY),
("sWeight", ctypes.c_short),
("sCharset", ctypes.c_short),
("fItalic", wintypes.BOOL),
("fUnderline", wintypes.BOOL),
("fStrikethrough", wintypes.BOOL),
]#[repr(C)]
pub struct CY {
pub Anonymous: _Anonymous_e__Struct,
pub int64: i64,
}
#[repr(C)]
pub struct FONTDESC {
pub cbSizeofstruct: u32,
pub lpstrName: *mut core::ffi::c_void,
pub cySize: CY,
pub sWeight: i16,
pub sCharset: i16,
pub fItalic: i32,
pub fUnderline: i32,
pub fStrikethrough: i32,
}import "golang.org/x/sys/windows"
type CY struct {
Anonymous _Anonymous_e__Struct
int64 int64
}
type FONTDESC struct {
cbSizeofstruct uint32
lpstrName uintptr
cySize CY
sWeight int16
sCharset int16
fItalic int32
fUnderline int32
fStrikethrough int32
}type
CY = record
Anonymous: _Anonymous_e__Struct;
int64: Int64;
end;
FONTDESC = record
cbSizeofstruct: DWORD;
lpstrName: Pointer;
cySize: CY;
sWeight: Smallint;
sCharset: Smallint;
fItalic: BOOL;
fUnderline: BOOL;
fStrikethrough: BOOL;
end;const CY = extern struct {
Anonymous: _Anonymous_e__Struct,
int64: i64,
};
const FONTDESC = extern struct {
cbSizeofstruct: u32,
lpstrName: ?*anyopaque,
cySize: CY,
sWeight: i16,
sCharset: i16,
fItalic: i32,
fUnderline: i32,
fStrikethrough: i32,
};type
CY {.bycopy.} = object
Anonymous: _Anonymous_e__Struct
int64: int64
FONTDESC {.bycopy.} = object
cbSizeofstruct: uint32
lpstrName: pointer
cySize: CY
sWeight: int16
sCharset: int16
fItalic: int32
fUnderline: int32
fStrikethrough: int32struct CY
{
_Anonymous_e__Struct Anonymous;
long int64;
}
struct FONTDESC
{
uint cbSizeofstruct;
void* lpstrName;
CY cySize;
short sWeight;
short sCharset;
int fItalic;
int fUnderline;
int fStrikethrough;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; FONTDESC サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; cbSizeofstruct : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; lpstrName : LPWSTR (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; cySize : CY (+8, 8byte) varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; sWeight : SHORT (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; sCharset : SHORT (+18, 2byte) wpoke st,18,値 / 値 = wpeek(st,18)
; fItalic : BOOL (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; fUnderline : BOOL (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; fStrikethrough : BOOL (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; FONTDESC サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; cbSizeofstruct : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; lpstrName : LPWSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; cySize : CY (+16, 8byte) varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; sWeight : SHORT (+24, 2byte) wpoke st,24,値 / 値 = wpeek(st,24)
; sCharset : SHORT (+26, 2byte) wpoke st,26,値 / 値 = wpeek(st,26)
; fItalic : BOOL (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; fUnderline : BOOL (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; fStrikethrough : BOOL (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global FONTDESC
#field int cbSizeofstruct
#field intptr lpstrName
#field byte cySize 8
#field short sWeight
#field short sCharset
#field bool fItalic
#field bool fUnderline
#field bool fStrikethrough
#endstruct
stdim st, FONTDESC ; NSTRUCT 変数を確保
st->cbSizeofstruct = 100
mes "cbSizeofstruct=" + st->cbSizeofstruct
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。