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

DWRITE_TEXT_METRICS

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

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

フィールド

フィールドサイズx64x86説明
leftFLOAT4+0+0グリフのオーバーハングを除いた、レイアウトボックスを基準とする書式設定済みテキストの最も左の点を示す値です。
topFLOAT4+4+4グリフのオーバーハングを除いた、レイアウトボックスを基準とする書式設定済みテキストの最も上の点を示す値です。
widthFLOAT4+8+8各行末尾の後続する空白を無視した、書式設定済みテキストの幅を示す値です。
widthIncludingTrailingWhitespaceFLOAT4+12+12各行末尾の後続する空白を考慮に入れた、書式設定済みテキストの幅です。
heightFLOAT4+16+16書式設定済みテキストの高さです。空の文字列の高さは、既定のフォントと同じ値に設定されます。
layoutWidthFLOAT4+20+20レイアウトに与えられた初期の幅です。テキストが折り返されたかどうかに応じて、テキストの内容の幅より大きくなることも小さくなることもあります。
layoutHeightFLOAT4+24+24レイアウトに与えられた初期の高さです。テキストの長さに応じて、テキストの内容の高さより大きくなることも小さくなることもあります。
maxBidiReorderingDepthDWORD4+28+28テキストのいずれかの行における並べ替え回数の最大値で、必要となるヒットテスト用ボックスの最大数を計算するために使用されます。レイアウトに双方向テキストが含まれない場合、またはテキストがまったく無い場合、最小レベルは 1 です。
lineCountDWORD4+32+32行の総数です。

公式ドキュメント

レイアウト後のテキストに関連付けられたメトリックを格納します。 すべての座標はデバイス非依存ピクセル (DIP) 単位です。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// DWRITE_TEXT_METRICS  (x64 36 / x86 36 バイト)
typedef struct DWRITE_TEXT_METRICS {
    FLOAT left;
    FLOAT top;
    FLOAT width;
    FLOAT widthIncludingTrailingWhitespace;
    FLOAT height;
    FLOAT layoutWidth;
    FLOAT layoutHeight;
    DWORD maxBidiReorderingDepth;
    DWORD lineCount;
} DWRITE_TEXT_METRICS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_TEXT_METRICS
{
    public float left;
    public float top;
    public float width;
    public float widthIncludingTrailingWhitespace;
    public float height;
    public float layoutWidth;
    public float layoutHeight;
    public uint maxBidiReorderingDepth;
    public uint lineCount;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_TEXT_METRICS
    Public left As Single
    Public top As Single
    Public width As Single
    Public widthIncludingTrailingWhitespace As Single
    Public height As Single
    Public layoutWidth As Single
    Public layoutHeight As Single
    Public maxBidiReorderingDepth As UInteger
    Public lineCount As UInteger
End Structure
import ctypes
from ctypes import wintypes

class DWRITE_TEXT_METRICS(ctypes.Structure):
    _fields_ = [
        ("left", ctypes.c_float),
        ("top", ctypes.c_float),
        ("width", ctypes.c_float),
        ("widthIncludingTrailingWhitespace", ctypes.c_float),
        ("height", ctypes.c_float),
        ("layoutWidth", ctypes.c_float),
        ("layoutHeight", ctypes.c_float),
        ("maxBidiReorderingDepth", wintypes.DWORD),
        ("lineCount", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DWRITE_TEXT_METRICS {
    pub left: f32,
    pub top: f32,
    pub width: f32,
    pub widthIncludingTrailingWhitespace: f32,
    pub height: f32,
    pub layoutWidth: f32,
    pub layoutHeight: f32,
    pub maxBidiReorderingDepth: u32,
    pub lineCount: u32,
}
import "golang.org/x/sys/windows"

type DWRITE_TEXT_METRICS struct {
	left float32
	top float32
	width float32
	widthIncludingTrailingWhitespace float32
	height float32
	layoutWidth float32
	layoutHeight float32
	maxBidiReorderingDepth uint32
	lineCount uint32
}
type
  DWRITE_TEXT_METRICS = record
    left: Single;
    top: Single;
    width: Single;
    widthIncludingTrailingWhitespace: Single;
    height: Single;
    layoutWidth: Single;
    layoutHeight: Single;
    maxBidiReorderingDepth: DWORD;
    lineCount: DWORD;
  end;
const DWRITE_TEXT_METRICS = extern struct {
    left: f32,
    top: f32,
    width: f32,
    widthIncludingTrailingWhitespace: f32,
    height: f32,
    layoutWidth: f32,
    layoutHeight: f32,
    maxBidiReorderingDepth: u32,
    lineCount: u32,
};
type
  DWRITE_TEXT_METRICS {.bycopy.} = object
    left: float32
    top: float32
    width: float32
    widthIncludingTrailingWhitespace: float32
    height: float32
    layoutWidth: float32
    layoutHeight: float32
    maxBidiReorderingDepth: uint32
    lineCount: uint32
struct DWRITE_TEXT_METRICS
{
    float left;
    float top;
    float width;
    float widthIncludingTrailingWhitespace;
    float height;
    float layoutWidth;
    float layoutHeight;
    uint maxBidiReorderingDepth;
    uint lineCount;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DWRITE_TEXT_METRICS サイズ: 36 バイト(x64)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; left : FLOAT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; top : FLOAT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; width : FLOAT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; widthIncludingTrailingWhitespace : FLOAT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; height : FLOAT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; layoutWidth : FLOAT (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; layoutHeight : FLOAT (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; maxBidiReorderingDepth : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; lineCount : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DWRITE_TEXT_METRICS
    #field float left
    #field float top
    #field float width
    #field float widthIncludingTrailingWhitespace
    #field float height
    #field float layoutWidth
    #field float layoutHeight
    #field int maxBidiReorderingDepth
    #field int lineCount
#endstruct

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