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

DWRITE_LINE_METRICS

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

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

フィールド

フィールドサイズx64x86説明
lengthDWORD4+0+0行に含まれるテキストの文字数(末尾空白を除く区分)。
trailingWhitespaceLengthDWORD4+4+4行末の空白文字数。
newlineLengthDWORD4+8+8行末の改行文字が占める文字数。
heightFLOAT4+12+12行の高さをDIP単位で表す値。
baselineFLOAT4+16+16行の上端からベースラインまでの距離をDIP単位で表す値。
isTrimmedBOOL4+20+20行が省略(トリミング)されているかを示すブール値。

各言語での定義

#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;
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;
}
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
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),
    ]
#[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,
}
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_METRICS = record
    length: DWORD;
    trailingWhitespaceLength: DWORD;
    newlineLength: DWORD;
    height: Single;
    baseline: Single;
    isTrimmed: BOOL;
  end;
const DWRITE_LINE_METRICS = extern struct {
    length: u32,
    trailingWhitespaceLength: u32,
    newlineLength: u32,
    height: f32,
    baseline: f32,
    isTrimmed: i32,
};
type
  DWRITE_LINE_METRICS {.bycopy.} = object
    length: uint32
    trailingWhitespaceLength: uint32
    newlineLength: uint32
    height: float32
    baseline: float32
    isTrimmed: int32
struct DWRITE_LINE_METRICS
{
    uint length;
    uint trailingWhitespaceLength;
    uint newlineLength;
    float height;
    float baseline;
    int isTrimmed;
}

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_METRICS サイズ: 24 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; length : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; trailingWhitespaceLength : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; newlineLength : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; height : FLOAT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; baseline : FLOAT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; isTrimmed : BOOL (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DWRITE_LINE_METRICS
    #field int length
    #field int trailingWhitespaceLength
    #field int newlineLength
    #field float height
    #field float baseline
    #field bool isTrimmed
#endstruct

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