Win32 API 日本語リファレンス
ホームGraphics.Printing › KERNDATA

KERNDATA

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

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

フィールド

フィールドサイズx64x86説明
dwSizeDWORD4+0+0このカーニングデータ全体のサイズをバイト単位で示す。
dwKernPairNumDWORD4+4+4KernPair配列に含まれるカーニングペアの数。
KernPairFD_KERNINGPAIR6+8+8カーニングペアを表すFD_KERNINGPAIRの可変長配列。

各言語での定義

#include <windows.h>

// FD_KERNINGPAIR  (x64 6 / x86 6 バイト)
typedef struct FD_KERNINGPAIR {
    WCHAR wcFirst;
    WCHAR wcSecond;
    SHORT fwdKern;
} FD_KERNINGPAIR;

// KERNDATA  (x64 16 / x86 16 バイト)
typedef struct KERNDATA {
    DWORD dwSize;
    DWORD dwKernPairNum;
    FD_KERNINGPAIR KernPair[1];
} KERNDATA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FD_KERNINGPAIR
{
    public char wcFirst;
    public char wcSecond;
    public short fwdKern;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KERNDATA
{
    public uint dwSize;
    public uint dwKernPairNum;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public FD_KERNINGPAIR[] KernPair;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FD_KERNINGPAIR
    Public wcFirst As Char
    Public wcSecond As Char
    Public fwdKern As Short
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KERNDATA
    Public dwSize As UInteger
    Public dwKernPairNum As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public KernPair() As FD_KERNINGPAIR
End Structure
import ctypes
from ctypes import wintypes

class FD_KERNINGPAIR(ctypes.Structure):
    _fields_ = [
        ("wcFirst", ctypes.c_wchar),
        ("wcSecond", ctypes.c_wchar),
        ("fwdKern", ctypes.c_short),
    ]

class KERNDATA(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("dwKernPairNum", wintypes.DWORD),
        ("KernPair", FD_KERNINGPAIR * 1),
    ]
#[repr(C)]
pub struct FD_KERNINGPAIR {
    pub wcFirst: u16,
    pub wcSecond: u16,
    pub fwdKern: i16,
}

#[repr(C)]
pub struct KERNDATA {
    pub dwSize: u32,
    pub dwKernPairNum: u32,
    pub KernPair: [FD_KERNINGPAIR; 1],
}
import "golang.org/x/sys/windows"

type FD_KERNINGPAIR struct {
	wcFirst uint16
	wcSecond uint16
	fwdKern int16
}

type KERNDATA struct {
	dwSize uint32
	dwKernPairNum uint32
	KernPair [1]FD_KERNINGPAIR
}
type
  FD_KERNINGPAIR = record
    wcFirst: WideChar;
    wcSecond: WideChar;
    fwdKern: Smallint;
  end;

  KERNDATA = record
    dwSize: DWORD;
    dwKernPairNum: DWORD;
    KernPair: array[0..0] of FD_KERNINGPAIR;
  end;
const FD_KERNINGPAIR = extern struct {
    wcFirst: u16,
    wcSecond: u16,
    fwdKern: i16,
};

const KERNDATA = extern struct {
    dwSize: u32,
    dwKernPairNum: u32,
    KernPair: [1]FD_KERNINGPAIR,
};
type
  FD_KERNINGPAIR {.bycopy.} = object
    wcFirst: uint16
    wcSecond: uint16
    fwdKern: int16

  KERNDATA {.bycopy.} = object
    dwSize: uint32
    dwKernPairNum: uint32
    KernPair: array[1, FD_KERNINGPAIR]
struct FD_KERNINGPAIR
{
    wchar wcFirst;
    wchar wcSecond;
    short fwdKern;
}

struct KERNDATA
{
    uint dwSize;
    uint dwKernPairNum;
    FD_KERNINGPAIR[1] KernPair;
}

HSP用 定義

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

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

#defstruct global KERNDATA
    #field int dwSize
    #field int dwKernPairNum
    #field FD_KERNINGPAIR KernPair 1
#endstruct

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