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

DWRITE_FONT_METRICS1

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

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

フィールド

フィールドサイズx64x86説明
BaseDWRITE_FONT_METRICS20+0+0基本フォントメトリクス(DWRITE_FONT_METRICS)を埋め込んだ構造体。
glyphBoxLeftSHORT2+20+20全グリフを囲む境界ボックスの左端をデザイン単位で表す値。
glyphBoxTopSHORT2+22+22全グリフを囲む境界ボックスの上端をデザイン単位で表す値。
glyphBoxRightSHORT2+24+24全グリフを囲む境界ボックスの右端をデザイン単位で表す値。
glyphBoxBottomSHORT2+26+26全グリフを囲む境界ボックスの下端をデザイン単位で表す値。
subscriptPositionXSHORT2+28+28下付き文字の水平位置をデザイン単位で表す値。
subscriptPositionYSHORT2+30+30下付き文字の垂直位置をデザイン単位で表す値。
subscriptSizeXSHORT2+32+32下付き文字の水平サイズをデザイン単位で表す値。
subscriptSizeYSHORT2+34+34下付き文字の垂直サイズをデザイン単位で表す値。
superscriptPositionXSHORT2+36+36上付き文字の水平位置をデザイン単位で表す値。
superscriptPositionYSHORT2+38+38上付き文字の垂直位置をデザイン単位で表す値。
superscriptSizeXSHORT2+40+40上付き文字の水平サイズをデザイン単位で表す値。
superscriptSizeYSHORT2+42+42上付き文字の垂直サイズをデザイン単位で表す値。
hasTypographicMetricsBOOL4+44+44フォントが本来の組版用メトリクスを持つかを示すブール値。

各言語での定義

#include <windows.h>

// DWRITE_FONT_METRICS  (x64 20 / x86 20 バイト)
typedef struct DWRITE_FONT_METRICS {
    WORD designUnitsPerEm;
    WORD ascent;
    WORD descent;
    SHORT lineGap;
    WORD capHeight;
    WORD xHeight;
    SHORT underlinePosition;
    WORD underlineThickness;
    SHORT strikethroughPosition;
    WORD strikethroughThickness;
} DWRITE_FONT_METRICS;

// DWRITE_FONT_METRICS1  (x64 48 / x86 48 バイト)
typedef struct DWRITE_FONT_METRICS1 {
    DWRITE_FONT_METRICS Base;
    SHORT glyphBoxLeft;
    SHORT glyphBoxTop;
    SHORT glyphBoxRight;
    SHORT glyphBoxBottom;
    SHORT subscriptPositionX;
    SHORT subscriptPositionY;
    SHORT subscriptSizeX;
    SHORT subscriptSizeY;
    SHORT superscriptPositionX;
    SHORT superscriptPositionY;
    SHORT superscriptSizeX;
    SHORT superscriptSizeY;
    BOOL hasTypographicMetrics;
} DWRITE_FONT_METRICS1;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_FONT_METRICS
{
    public ushort designUnitsPerEm;
    public ushort ascent;
    public ushort descent;
    public short lineGap;
    public ushort capHeight;
    public ushort xHeight;
    public short underlinePosition;
    public ushort underlineThickness;
    public short strikethroughPosition;
    public ushort strikethroughThickness;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_FONT_METRICS1
{
    public DWRITE_FONT_METRICS Base;
    public short glyphBoxLeft;
    public short glyphBoxTop;
    public short glyphBoxRight;
    public short glyphBoxBottom;
    public short subscriptPositionX;
    public short subscriptPositionY;
    public short subscriptSizeX;
    public short subscriptSizeY;
    public short superscriptPositionX;
    public short superscriptPositionY;
    public short superscriptSizeX;
    public short superscriptSizeY;
    [MarshalAs(UnmanagedType.Bool)] public bool hasTypographicMetrics;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_FONT_METRICS
    Public designUnitsPerEm As UShort
    Public ascent As UShort
    Public descent As UShort
    Public lineGap As Short
    Public capHeight As UShort
    Public xHeight As UShort
    Public underlinePosition As Short
    Public underlineThickness As UShort
    Public strikethroughPosition As Short
    Public strikethroughThickness As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_FONT_METRICS1
    Public Base As DWRITE_FONT_METRICS
    Public glyphBoxLeft As Short
    Public glyphBoxTop As Short
    Public glyphBoxRight As Short
    Public glyphBoxBottom As Short
    Public subscriptPositionX As Short
    Public subscriptPositionY As Short
    Public subscriptSizeX As Short
    Public subscriptSizeY As Short
    Public superscriptPositionX As Short
    Public superscriptPositionY As Short
    Public superscriptSizeX As Short
    Public superscriptSizeY As Short
    <MarshalAs(UnmanagedType.Bool)> Public hasTypographicMetrics As Boolean
End Structure
import ctypes
from ctypes import wintypes

class DWRITE_FONT_METRICS(ctypes.Structure):
    _fields_ = [
        ("designUnitsPerEm", ctypes.c_ushort),
        ("ascent", ctypes.c_ushort),
        ("descent", ctypes.c_ushort),
        ("lineGap", ctypes.c_short),
        ("capHeight", ctypes.c_ushort),
        ("xHeight", ctypes.c_ushort),
        ("underlinePosition", ctypes.c_short),
        ("underlineThickness", ctypes.c_ushort),
        ("strikethroughPosition", ctypes.c_short),
        ("strikethroughThickness", ctypes.c_ushort),
    ]

class DWRITE_FONT_METRICS1(ctypes.Structure):
    _fields_ = [
        ("Base", DWRITE_FONT_METRICS),
        ("glyphBoxLeft", ctypes.c_short),
        ("glyphBoxTop", ctypes.c_short),
        ("glyphBoxRight", ctypes.c_short),
        ("glyphBoxBottom", ctypes.c_short),
        ("subscriptPositionX", ctypes.c_short),
        ("subscriptPositionY", ctypes.c_short),
        ("subscriptSizeX", ctypes.c_short),
        ("subscriptSizeY", ctypes.c_short),
        ("superscriptPositionX", ctypes.c_short),
        ("superscriptPositionY", ctypes.c_short),
        ("superscriptSizeX", ctypes.c_short),
        ("superscriptSizeY", ctypes.c_short),
        ("hasTypographicMetrics", wintypes.BOOL),
    ]
#[repr(C)]
pub struct DWRITE_FONT_METRICS {
    pub designUnitsPerEm: u16,
    pub ascent: u16,
    pub descent: u16,
    pub lineGap: i16,
    pub capHeight: u16,
    pub xHeight: u16,
    pub underlinePosition: i16,
    pub underlineThickness: u16,
    pub strikethroughPosition: i16,
    pub strikethroughThickness: u16,
}

#[repr(C)]
pub struct DWRITE_FONT_METRICS1 {
    pub Base: DWRITE_FONT_METRICS,
    pub glyphBoxLeft: i16,
    pub glyphBoxTop: i16,
    pub glyphBoxRight: i16,
    pub glyphBoxBottom: i16,
    pub subscriptPositionX: i16,
    pub subscriptPositionY: i16,
    pub subscriptSizeX: i16,
    pub subscriptSizeY: i16,
    pub superscriptPositionX: i16,
    pub superscriptPositionY: i16,
    pub superscriptSizeX: i16,
    pub superscriptSizeY: i16,
    pub hasTypographicMetrics: i32,
}
import "golang.org/x/sys/windows"

type DWRITE_FONT_METRICS struct {
	designUnitsPerEm uint16
	ascent uint16
	descent uint16
	lineGap int16
	capHeight uint16
	xHeight uint16
	underlinePosition int16
	underlineThickness uint16
	strikethroughPosition int16
	strikethroughThickness uint16
}

type DWRITE_FONT_METRICS1 struct {
	Base DWRITE_FONT_METRICS
	glyphBoxLeft int16
	glyphBoxTop int16
	glyphBoxRight int16
	glyphBoxBottom int16
	subscriptPositionX int16
	subscriptPositionY int16
	subscriptSizeX int16
	subscriptSizeY int16
	superscriptPositionX int16
	superscriptPositionY int16
	superscriptSizeX int16
	superscriptSizeY int16
	hasTypographicMetrics int32
}
type
  DWRITE_FONT_METRICS = record
    designUnitsPerEm: Word;
    ascent: Word;
    descent: Word;
    lineGap: Smallint;
    capHeight: Word;
    xHeight: Word;
    underlinePosition: Smallint;
    underlineThickness: Word;
    strikethroughPosition: Smallint;
    strikethroughThickness: Word;
  end;

  DWRITE_FONT_METRICS1 = record
    Base: DWRITE_FONT_METRICS;
    glyphBoxLeft: Smallint;
    glyphBoxTop: Smallint;
    glyphBoxRight: Smallint;
    glyphBoxBottom: Smallint;
    subscriptPositionX: Smallint;
    subscriptPositionY: Smallint;
    subscriptSizeX: Smallint;
    subscriptSizeY: Smallint;
    superscriptPositionX: Smallint;
    superscriptPositionY: Smallint;
    superscriptSizeX: Smallint;
    superscriptSizeY: Smallint;
    hasTypographicMetrics: BOOL;
  end;
const DWRITE_FONT_METRICS = extern struct {
    designUnitsPerEm: u16,
    ascent: u16,
    descent: u16,
    lineGap: i16,
    capHeight: u16,
    xHeight: u16,
    underlinePosition: i16,
    underlineThickness: u16,
    strikethroughPosition: i16,
    strikethroughThickness: u16,
};

const DWRITE_FONT_METRICS1 = extern struct {
    Base: DWRITE_FONT_METRICS,
    glyphBoxLeft: i16,
    glyphBoxTop: i16,
    glyphBoxRight: i16,
    glyphBoxBottom: i16,
    subscriptPositionX: i16,
    subscriptPositionY: i16,
    subscriptSizeX: i16,
    subscriptSizeY: i16,
    superscriptPositionX: i16,
    superscriptPositionY: i16,
    superscriptSizeX: i16,
    superscriptSizeY: i16,
    hasTypographicMetrics: i32,
};
type
  DWRITE_FONT_METRICS {.bycopy.} = object
    designUnitsPerEm: uint16
    ascent: uint16
    descent: uint16
    lineGap: int16
    capHeight: uint16
    xHeight: uint16
    underlinePosition: int16
    underlineThickness: uint16
    strikethroughPosition: int16
    strikethroughThickness: uint16

  DWRITE_FONT_METRICS1 {.bycopy.} = object
    Base: DWRITE_FONT_METRICS
    glyphBoxLeft: int16
    glyphBoxTop: int16
    glyphBoxRight: int16
    glyphBoxBottom: int16
    subscriptPositionX: int16
    subscriptPositionY: int16
    subscriptSizeX: int16
    subscriptSizeY: int16
    superscriptPositionX: int16
    superscriptPositionY: int16
    superscriptSizeX: int16
    superscriptSizeY: int16
    hasTypographicMetrics: int32
struct DWRITE_FONT_METRICS
{
    ushort designUnitsPerEm;
    ushort ascent;
    ushort descent;
    short lineGap;
    ushort capHeight;
    ushort xHeight;
    short underlinePosition;
    ushort underlineThickness;
    short strikethroughPosition;
    ushort strikethroughThickness;
}

struct DWRITE_FONT_METRICS1
{
    DWRITE_FONT_METRICS Base;
    short glyphBoxLeft;
    short glyphBoxTop;
    short glyphBoxRight;
    short glyphBoxBottom;
    short subscriptPositionX;
    short subscriptPositionY;
    short subscriptSizeX;
    short subscriptSizeY;
    short superscriptPositionX;
    short superscriptPositionY;
    short superscriptSizeX;
    short superscriptSizeY;
    int hasTypographicMetrics;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DWRITE_FONT_METRICS1 サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; Base : DWRITE_FONT_METRICS (+0, 20byte)  varptr(st)+0 を基点に操作(20byte:入れ子/配列)
; glyphBoxLeft : SHORT (+20, 2byte)  wpoke st,20,値  /  値 = wpeek(st,20)
; glyphBoxTop : SHORT (+22, 2byte)  wpoke st,22,値  /  値 = wpeek(st,22)
; glyphBoxRight : SHORT (+24, 2byte)  wpoke st,24,値  /  値 = wpeek(st,24)
; glyphBoxBottom : SHORT (+26, 2byte)  wpoke st,26,値  /  値 = wpeek(st,26)
; subscriptPositionX : SHORT (+28, 2byte)  wpoke st,28,値  /  値 = wpeek(st,28)
; subscriptPositionY : SHORT (+30, 2byte)  wpoke st,30,値  /  値 = wpeek(st,30)
; subscriptSizeX : SHORT (+32, 2byte)  wpoke st,32,値  /  値 = wpeek(st,32)
; subscriptSizeY : SHORT (+34, 2byte)  wpoke st,34,値  /  値 = wpeek(st,34)
; superscriptPositionX : SHORT (+36, 2byte)  wpoke st,36,値  /  値 = wpeek(st,36)
; superscriptPositionY : SHORT (+38, 2byte)  wpoke st,38,値  /  値 = wpeek(st,38)
; superscriptSizeX : SHORT (+40, 2byte)  wpoke st,40,値  /  値 = wpeek(st,40)
; superscriptSizeY : SHORT (+42, 2byte)  wpoke st,42,値  /  値 = wpeek(st,42)
; hasTypographicMetrics : BOOL (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DWRITE_FONT_METRICS
    #field short designUnitsPerEm
    #field short ascent
    #field short descent
    #field short lineGap
    #field short capHeight
    #field short xHeight
    #field short underlinePosition
    #field short underlineThickness
    #field short strikethroughPosition
    #field short strikethroughThickness
#endstruct

#defstruct global DWRITE_FONT_METRICS1
    #field DWRITE_FONT_METRICS Base
    #field short glyphBoxLeft
    #field short glyphBoxTop
    #field short glyphBoxRight
    #field short glyphBoxBottom
    #field short subscriptPositionX
    #field short subscriptPositionY
    #field short subscriptSizeX
    #field short subscriptSizeY
    #field short superscriptPositionX
    #field short superscriptPositionY
    #field short superscriptSizeX
    #field short superscriptSizeY
    #field bool hasTypographicMetrics
#endstruct

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