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

DWRITE_LINE_METRICS1

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

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

フィールド

フィールドサイズx64x86説明
BaseDWRITE_LINE_METRICS24+0+0基本行メトリクス(DWRITE_LINE_METRICS)を埋め込んだ構造体。
leadingBeforeFLOAT4+24+24行の前(上)に追加される行間スペースをDIP単位で表す値。
leadingAfterFLOAT4+28+28行の後(下)に追加される行間スペースをDIP単位で表す値。

各言語での定義

#include <windows.h>

// DWRITE_LINE_METRICS  (x64 24 / x86 24 バイト)
typedef struct DWRITE_LINE_METRICS {
    DWORD length;
    DWORD trailingWhitespaceLength;
    DWORD newlineLength;
    FLOAT height;
    FLOAT baseline;
    BOOL isTrimmed;
} DWRITE_LINE_METRICS;

// DWRITE_LINE_METRICS1  (x64 32 / x86 32 バイト)
typedef struct DWRITE_LINE_METRICS1 {
    DWRITE_LINE_METRICS Base;
    FLOAT leadingBefore;
    FLOAT leadingAfter;
} DWRITE_LINE_METRICS1;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_LINE_METRICS
{
    public uint length;
    public uint trailingWhitespaceLength;
    public uint newlineLength;
    public float height;
    public float baseline;
    [MarshalAs(UnmanagedType.Bool)] public bool isTrimmed;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_LINE_METRICS1
{
    public DWRITE_LINE_METRICS Base;
    public float leadingBefore;
    public float leadingAfter;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_LINE_METRICS
    Public length As UInteger
    Public trailingWhitespaceLength As UInteger
    Public newlineLength As UInteger
    Public height As Single
    Public baseline As Single
    <MarshalAs(UnmanagedType.Bool)> Public isTrimmed As Boolean
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_LINE_METRICS1
    Public Base As DWRITE_LINE_METRICS
    Public leadingBefore As Single
    Public leadingAfter As Single
End Structure
import ctypes
from ctypes import wintypes

class DWRITE_LINE_METRICS(ctypes.Structure):
    _fields_ = [
        ("length", wintypes.DWORD),
        ("trailingWhitespaceLength", wintypes.DWORD),
        ("newlineLength", wintypes.DWORD),
        ("height", ctypes.c_float),
        ("baseline", ctypes.c_float),
        ("isTrimmed", wintypes.BOOL),
    ]

class DWRITE_LINE_METRICS1(ctypes.Structure):
    _fields_ = [
        ("Base", DWRITE_LINE_METRICS),
        ("leadingBefore", ctypes.c_float),
        ("leadingAfter", ctypes.c_float),
    ]
#[repr(C)]
pub struct DWRITE_LINE_METRICS {
    pub length: u32,
    pub trailingWhitespaceLength: u32,
    pub newlineLength: u32,
    pub height: f32,
    pub baseline: f32,
    pub isTrimmed: i32,
}

#[repr(C)]
pub struct DWRITE_LINE_METRICS1 {
    pub Base: DWRITE_LINE_METRICS,
    pub leadingBefore: f32,
    pub leadingAfter: f32,
}
import "golang.org/x/sys/windows"

type DWRITE_LINE_METRICS struct {
	length uint32
	trailingWhitespaceLength uint32
	newlineLength uint32
	height float32
	baseline float32
	isTrimmed int32
}

type DWRITE_LINE_METRICS1 struct {
	Base DWRITE_LINE_METRICS
	leadingBefore float32
	leadingAfter float32
}
type
  DWRITE_LINE_METRICS = record
    length: DWORD;
    trailingWhitespaceLength: DWORD;
    newlineLength: DWORD;
    height: Single;
    baseline: Single;
    isTrimmed: BOOL;
  end;

  DWRITE_LINE_METRICS1 = record
    Base: DWRITE_LINE_METRICS;
    leadingBefore: Single;
    leadingAfter: Single;
  end;
const DWRITE_LINE_METRICS = extern struct {
    length: u32,
    trailingWhitespaceLength: u32,
    newlineLength: u32,
    height: f32,
    baseline: f32,
    isTrimmed: i32,
};

const DWRITE_LINE_METRICS1 = extern struct {
    Base: DWRITE_LINE_METRICS,
    leadingBefore: f32,
    leadingAfter: f32,
};
type
  DWRITE_LINE_METRICS {.bycopy.} = object
    length: uint32
    trailingWhitespaceLength: uint32
    newlineLength: uint32
    height: float32
    baseline: float32
    isTrimmed: int32

  DWRITE_LINE_METRICS1 {.bycopy.} = object
    Base: DWRITE_LINE_METRICS
    leadingBefore: float32
    leadingAfter: float32
struct DWRITE_LINE_METRICS
{
    uint length;
    uint trailingWhitespaceLength;
    uint newlineLength;
    float height;
    float baseline;
    int isTrimmed;
}

struct DWRITE_LINE_METRICS1
{
    DWRITE_LINE_METRICS Base;
    float leadingBefore;
    float leadingAfter;
}

HSP用 定義

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

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

#defstruct global DWRITE_LINE_METRICS1
    #field DWRITE_LINE_METRICS Base
    #field float leadingBefore
    #field float leadingAfter
#endstruct

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