ホーム › 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 単位あたりのフォントデザイン単位の数。フォントファイルは、フォントデザイン単位という独自の座標系を使用します。フォントデザイン単位は、グリフのサイズ設定と配置に使用される仮想的な正方形である em スクエアにおける最小の測定単位です。em スクエアという概念は、フォントサイズやデバイス変換のセマンティクスを定義する際の基準となる拡大縮小係数として使用されます。また、1 em スクエアのサイズは、段落のインデント値の計算にもよく使用されます。 |
| ascent | WORD | 2 | +2 | +2 | フォントフェイスのアセント値 (フォントデザイン単位)。アセントは、文字配置ボックスの上端から英語ベースラインまでの距離です。 |
| descent | WORD | 2 | +4 | +4 | フォントフェイスのディセント値 (フォントデザイン単位)。ディセントは、文字配置ボックスの下端から英語ベースラインまでの距離です。 |
| lineGap | SHORT | 2 | +6 | +6 | ラインギャップ (フォントデザイン単位)。可読性を高めるために行間へ追加することが推奨される空白です。推奨される行送り (ベースライン間の距離) は、ascent、descent、lineGap の合計です。ラインギャップは通常は正の値または 0 ですが、負の値になることもあり、その場合、推奨される行送りは文字配置ボックスの高さより小さくなります。 |
| capHeight | WORD | 2 | +8 | +8 | フォントフェイスのキャップハイト値 (フォントデザイン単位)。キャップハイトは、英語ベースラインから一般的な英大文字の上端までの距離です。キャップハイト値を算出する際は、大文字の "H" が基準文字としてよく使用されます。 |
| xHeight | WORD | 2 | +10 | +10 | フォントフェイスの x ハイト値 (フォントデザイン単位)。x ハイトは、英語ベースラインから小文字 "x" (または類似の小文字) の上端までの距離です。 |
| underlinePosition | SHORT | 2 | +12 | +12 | フォントフェイスの下線位置の値 (フォントデザイン単位)。下線位置は、英語ベースラインを基準とした下線の位置です。下線をベースラインより下に配置するため、この値は通常は負の値になります。 |
| underlineThickness | WORD | 2 | +14 | +14 | フォントフェイスで推奨される下線の太さの値 (フォントデザイン単位)。 |
| strikethroughPosition | SHORT | 2 | +16 | +16 | フォントフェイスの取り消し線位置の値 (フォントデザイン単位)。取り消し線位置は、英語ベースラインを基準とした取り消し線の位置です。取り消し線をベースラインより上に配置するため、この値は通常は正の値になります。 |
| strikethroughThickness | WORD | 2 | +18 | +18 | フォントフェイスで推奨される取り消し線の太さの値 (フォントデザイン単位)。 |
公式ドキュメント
DWRITE_FONT_METRICS 構造体は、フォントフェイス内のすべてのグリフに適用されるメトリックを指定します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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