ホーム › Devices.Display › FONTDIFF
FONTDIFF
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| jReserved1 | BYTE | 1 | +0 | +0 | 予約フィールド1。未使用。 |
| jReserved2 | BYTE | 1 | +1 | +1 | 予約フィールド2。未使用。 |
| jReserved3 | BYTE | 1 | +2 | +2 | 予約フィールド3。未使用。 |
| bWeight | BYTE | 1 | +3 | +3 | PANOSE形式の太さ値。 |
| usWinWeight | WORD | 2 | +4 | +4 | Windows形式の太さ(100〜900)。 |
| fsSelection | WORD | 2 | +6 | +6 | 選択フラグ(イタリック等のスタイルビット)。 |
| fwdAveCharWidth | SHORT | 2 | +8 | +8 | 平均文字幅(設計単位)。 |
| fwdMaxCharInc | SHORT | 2 | +10 | +10 | 最大文字送り幅。 |
| ptlCaret | POINTL | 8 | +12 | +12 | キャレットの傾きベクトル(POINTL)。 |
各言語での定義
#include <windows.h>
// POINTL (x64 8 / x86 8 バイト)
typedef struct POINTL {
INT x;
INT y;
} POINTL;
// FONTDIFF (x64 20 / x86 20 バイト)
typedef struct FONTDIFF {
BYTE jReserved1;
BYTE jReserved2;
BYTE jReserved3;
BYTE bWeight;
WORD usWinWeight;
WORD fsSelection;
SHORT fwdAveCharWidth;
SHORT fwdMaxCharInc;
POINTL ptlCaret;
} FONTDIFF;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINTL
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FONTDIFF
{
public byte jReserved1;
public byte jReserved2;
public byte jReserved3;
public byte bWeight;
public ushort usWinWeight;
public ushort fsSelection;
public short fwdAveCharWidth;
public short fwdMaxCharInc;
public POINTL ptlCaret;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINTL
Public x As Integer
Public y As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FONTDIFF
Public jReserved1 As Byte
Public jReserved2 As Byte
Public jReserved3 As Byte
Public bWeight As Byte
Public usWinWeight As UShort
Public fsSelection As UShort
Public fwdAveCharWidth As Short
Public fwdMaxCharInc As Short
Public ptlCaret As POINTL
End Structureimport ctypes
from ctypes import wintypes
class POINTL(ctypes.Structure):
_fields_ = [
("x", ctypes.c_int),
("y", ctypes.c_int),
]
class FONTDIFF(ctypes.Structure):
_fields_ = [
("jReserved1", ctypes.c_ubyte),
("jReserved2", ctypes.c_ubyte),
("jReserved3", ctypes.c_ubyte),
("bWeight", ctypes.c_ubyte),
("usWinWeight", ctypes.c_ushort),
("fsSelection", ctypes.c_ushort),
("fwdAveCharWidth", ctypes.c_short),
("fwdMaxCharInc", ctypes.c_short),
("ptlCaret", POINTL),
]#[repr(C)]
pub struct POINTL {
pub x: i32,
pub y: i32,
}
#[repr(C)]
pub struct FONTDIFF {
pub jReserved1: u8,
pub jReserved2: u8,
pub jReserved3: u8,
pub bWeight: u8,
pub usWinWeight: u16,
pub fsSelection: u16,
pub fwdAveCharWidth: i16,
pub fwdMaxCharInc: i16,
pub ptlCaret: POINTL,
}import "golang.org/x/sys/windows"
type POINTL struct {
x int32
y int32
}
type FONTDIFF struct {
jReserved1 byte
jReserved2 byte
jReserved3 byte
bWeight byte
usWinWeight uint16
fsSelection uint16
fwdAveCharWidth int16
fwdMaxCharInc int16
ptlCaret POINTL
}type
POINTL = record
x: Integer;
y: Integer;
end;
FONTDIFF = record
jReserved1: Byte;
jReserved2: Byte;
jReserved3: Byte;
bWeight: Byte;
usWinWeight: Word;
fsSelection: Word;
fwdAveCharWidth: Smallint;
fwdMaxCharInc: Smallint;
ptlCaret: POINTL;
end;const POINTL = extern struct {
x: i32,
y: i32,
};
const FONTDIFF = extern struct {
jReserved1: u8,
jReserved2: u8,
jReserved3: u8,
bWeight: u8,
usWinWeight: u16,
fsSelection: u16,
fwdAveCharWidth: i16,
fwdMaxCharInc: i16,
ptlCaret: POINTL,
};type
POINTL {.bycopy.} = object
x: int32
y: int32
FONTDIFF {.bycopy.} = object
jReserved1: uint8
jReserved2: uint8
jReserved3: uint8
bWeight: uint8
usWinWeight: uint16
fsSelection: uint16
fwdAveCharWidth: int16
fwdMaxCharInc: int16
ptlCaret: POINTLstruct POINTL
{
int x;
int y;
}
struct FONTDIFF
{
ubyte jReserved1;
ubyte jReserved2;
ubyte jReserved3;
ubyte bWeight;
ushort usWinWeight;
ushort fsSelection;
short fwdAveCharWidth;
short fwdMaxCharInc;
POINTL ptlCaret;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; FONTDIFF サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; jReserved1 : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; jReserved2 : BYTE (+1, 1byte) poke st,1,値 / 値 = peek(st,1)
; jReserved3 : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; bWeight : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; usWinWeight : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; fsSelection : WORD (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; fwdAveCharWidth : SHORT (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; fwdMaxCharInc : SHORT (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; ptlCaret : POINTL (+12, 8byte) varptr(st)+12 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global POINTL
#field int x
#field int y
#endstruct
#defstruct global FONTDIFF
#field byte jReserved1
#field byte jReserved2
#field byte jReserved3
#field byte bWeight
#field short usWinWeight
#field short fsSelection
#field short fwdAveCharWidth
#field short fwdMaxCharInc
#field POINTL ptlCaret
#endstruct
stdim st, FONTDIFF ; NSTRUCT 変数を確保
st->jReserved1 = 100
mes "jReserved1=" + st->jReserved1