ホーム › Graphics.DirectWrite › DWRITE_TEXT_METRICS
DWRITE_TEXT_METRICS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| left | FLOAT | 4 | +0 | +0 | レイアウト矩形の左端からテキスト描画領域の左端までの距離。 |
| top | FLOAT | 4 | +4 | +4 | レイアウト矩形の上端からテキスト描画領域の上端までの距離。 |
| width | FLOAT | 4 | +8 | +8 | 末尾空白を含まないテキストの幅をDIP単位で表す値。 |
| widthIncludingTrailingWhitespace | FLOAT | 4 | +12 | +12 | 末尾空白を含むテキストの幅をDIP単位で表す値。 |
| height | FLOAT | 4 | +16 | +16 | 整形されたテキスト全体の高さをDIP単位で表す値。 |
| layoutWidth | FLOAT | 4 | +20 | +20 | テキストレイアウトに割り当てられた最大幅。 |
| layoutHeight | FLOAT | 4 | +24 | +24 | テキストレイアウトに割り当てられた最大高さ。 |
| maxBidiReorderingDepth | DWORD | 4 | +28 | +28 | 双方向(BiDi)並べ替えの最大ネスト深さ。 |
| lineCount | DWORD | 4 | +32 | +32 | 整形結果に含まれる行の総数。 |
各言語での定義
#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 Structureimport 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: uint32struct 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