ホーム › Graphics.DirectWrite › DWRITE_FONT_METRICS
DWRITE_FONT_METRICS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| designUnitsPerEm | WORD | 2 | +0 | +0 | フォントのデザイン単位でのem平方サイズ。他の値の基準となる。 |
| ascent | WORD | 2 | +2 | +2 | ベースラインから上方向の高さをデザイン単位で示す。 |
| descent | WORD | 2 | +4 | +4 | ベースラインから下方向の深さをデザイン単位で示す。 |
| lineGap | SHORT | 2 | +6 | +6 | 行間に追加する推奨スペースをデザイン単位で示す。負値も取り得る。 |
| capHeight | WORD | 2 | +8 | +8 | 大文字の高さをデザイン単位で示す。 |
| xHeight | WORD | 2 | +10 | +10 | 小文字xの高さをデザイン単位で示す。 |
| underlinePosition | SHORT | 2 | +12 | +12 | 下線の位置(ベースラインからの相対)をデザイン単位で示す。通常は負値。 |
| underlineThickness | WORD | 2 | +14 | +14 | 下線の太さをデザイン単位で示す。 |
| strikethroughPosition | SHORT | 2 | +16 | +16 | 取り消し線の位置(ベースラインからの相対)をデザイン単位で示す。 |
| strikethroughThickness | WORD | 2 | +18 | +18 | 取り消し線の太さをデザイン単位で示す。 |
各言語での定義
#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;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;
}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 Structureimport 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),
]#[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,
}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_METRICS = record
designUnitsPerEm: Word;
ascent: Word;
descent: Word;
lineGap: Smallint;
capHeight: Word;
xHeight: Word;
underlinePosition: Smallint;
underlineThickness: Word;
strikethroughPosition: Smallint;
strikethroughThickness: Word;
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,
};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: uint16struct DWRITE_FONT_METRICS
{
ushort designUnitsPerEm;
ushort ascent;
ushort descent;
short lineGap;
ushort capHeight;
ushort xHeight;
short underlinePosition;
ushort underlineThickness;
short strikethroughPosition;
ushort strikethroughThickness;
}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_METRICS サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; designUnitsPerEm : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; ascent : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; descent : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; lineGap : SHORT (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; capHeight : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; xHeight : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; underlinePosition : SHORT (+12, 2byte) wpoke st,12,値 / 値 = wpeek(st,12)
; underlineThickness : WORD (+14, 2byte) wpoke st,14,値 / 値 = wpeek(st,14)
; strikethroughPosition : SHORT (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; strikethroughThickness : WORD (+18, 2byte) wpoke st,18,値 / 値 = wpeek(st,18)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#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
stdim st, DWRITE_FONT_METRICS ; NSTRUCT 変数を確保
st->designUnitsPerEm = 100
mes "designUnitsPerEm=" + st->designUnitsPerEm