ホーム › Graphics.Gdi › TEXTMETRICA
TEXTMETRICA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| tmHeight | INT | 4 | +0 | +0 | 文字の高さ(アセント+ディセント)。 |
| tmAscent | INT | 4 | +4 | +4 | ベースラインより上の文字の高さ(アセント)。 |
| tmDescent | INT | 4 | +8 | +8 | ベースラインより下の文字の高さ(ディセント)。 |
| tmInternalLeading | INT | 4 | +12 | +12 | アセント内に含まれる内部レディング(余白)。 |
| tmExternalLeading | INT | 4 | +16 | +16 | 行間に追加すべき外部レディング(余白)。 |
| tmAveCharWidth | INT | 4 | +20 | +20 | 小文字の平均文字幅。 |
| tmMaxCharWidth | INT | 4 | +24 | +24 | フォント内で最も広い文字の幅。 |
| tmWeight | INT | 4 | +28 | +28 | フォントの太さ(100〜900、400が標準)。 |
| tmOverhang | INT | 4 | +32 | +32 | 合成スタイル適用時に追加される文字幅(オーバーハング)。 |
| tmDigitizedAspectX | INT | 4 | +36 | +36 | フォント設計時の水平アスペクト比。 |
| tmDigitizedAspectY | INT | 4 | +40 | +40 | フォント設計時の垂直アスペクト比。 |
| tmFirstChar | BYTE | 1 | +44 | +44 | フォントで定義された最初の文字コード。 |
| tmLastChar | BYTE | 1 | +45 | +45 | フォントで定義された最後の文字コード。 |
| tmDefaultChar | BYTE | 1 | +46 | +46 | 未定義文字の代替に使う既定文字コード。 |
| tmBreakChar | BYTE | 1 | +47 | +47 | 単語区切りに使う文字コード(通常は空白)。 |
| tmItalic | BYTE | 1 | +48 | +48 | 斜体かを示すフラグ。非0で斜体。 |
| tmUnderlined | BYTE | 1 | +49 | +49 | 下線付きかを示すフラグ。非0で下線あり。 |
| tmStruckOut | BYTE | 1 | +50 | +50 | 取り消し線付きかを示すフラグ。非0で取り消し線あり。 |
| tmPitchAndFamily | TMPF_FLAGS | 1 | +51 | +51 | ピッチとフォントファミリの情報を示すTMPF_FLAGS。 |
| tmCharSet | BYTE | 1 | +52 | +52 | フォントの文字セットを示す値。 |
各言語での定義
#include <windows.h>
// TEXTMETRICA (x64 56 / x86 56 バイト)
typedef struct TEXTMETRICA {
INT tmHeight;
INT tmAscent;
INT tmDescent;
INT tmInternalLeading;
INT tmExternalLeading;
INT tmAveCharWidth;
INT tmMaxCharWidth;
INT tmWeight;
INT tmOverhang;
INT tmDigitizedAspectX;
INT tmDigitizedAspectY;
BYTE tmFirstChar;
BYTE tmLastChar;
BYTE tmDefaultChar;
BYTE tmBreakChar;
BYTE tmItalic;
BYTE tmUnderlined;
BYTE tmStruckOut;
TMPF_FLAGS tmPitchAndFamily;
BYTE tmCharSet;
} TEXTMETRICA;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TEXTMETRICA
{
public int tmHeight;
public int tmAscent;
public int tmDescent;
public int tmInternalLeading;
public int tmExternalLeading;
public int tmAveCharWidth;
public int tmMaxCharWidth;
public int tmWeight;
public int tmOverhang;
public int tmDigitizedAspectX;
public int tmDigitizedAspectY;
public byte tmFirstChar;
public byte tmLastChar;
public byte tmDefaultChar;
public byte tmBreakChar;
public byte tmItalic;
public byte tmUnderlined;
public byte tmStruckOut;
public byte tmPitchAndFamily;
public byte tmCharSet;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TEXTMETRICA
Public tmHeight As Integer
Public tmAscent As Integer
Public tmDescent As Integer
Public tmInternalLeading As Integer
Public tmExternalLeading As Integer
Public tmAveCharWidth As Integer
Public tmMaxCharWidth As Integer
Public tmWeight As Integer
Public tmOverhang As Integer
Public tmDigitizedAspectX As Integer
Public tmDigitizedAspectY As Integer
Public tmFirstChar As Byte
Public tmLastChar As Byte
Public tmDefaultChar As Byte
Public tmBreakChar As Byte
Public tmItalic As Byte
Public tmUnderlined As Byte
Public tmStruckOut As Byte
Public tmPitchAndFamily As Byte
Public tmCharSet As Byte
End Structureimport ctypes
from ctypes import wintypes
class TEXTMETRICA(ctypes.Structure):
_fields_ = [
("tmHeight", ctypes.c_int),
("tmAscent", ctypes.c_int),
("tmDescent", ctypes.c_int),
("tmInternalLeading", ctypes.c_int),
("tmExternalLeading", ctypes.c_int),
("tmAveCharWidth", ctypes.c_int),
("tmMaxCharWidth", ctypes.c_int),
("tmWeight", ctypes.c_int),
("tmOverhang", ctypes.c_int),
("tmDigitizedAspectX", ctypes.c_int),
("tmDigitizedAspectY", ctypes.c_int),
("tmFirstChar", ctypes.c_ubyte),
("tmLastChar", ctypes.c_ubyte),
("tmDefaultChar", ctypes.c_ubyte),
("tmBreakChar", ctypes.c_ubyte),
("tmItalic", ctypes.c_ubyte),
("tmUnderlined", ctypes.c_ubyte),
("tmStruckOut", ctypes.c_ubyte),
("tmPitchAndFamily", ctypes.c_ubyte),
("tmCharSet", ctypes.c_ubyte),
]#[repr(C)]
pub struct TEXTMETRICA {
pub tmHeight: i32,
pub tmAscent: i32,
pub tmDescent: i32,
pub tmInternalLeading: i32,
pub tmExternalLeading: i32,
pub tmAveCharWidth: i32,
pub tmMaxCharWidth: i32,
pub tmWeight: i32,
pub tmOverhang: i32,
pub tmDigitizedAspectX: i32,
pub tmDigitizedAspectY: i32,
pub tmFirstChar: u8,
pub tmLastChar: u8,
pub tmDefaultChar: u8,
pub tmBreakChar: u8,
pub tmItalic: u8,
pub tmUnderlined: u8,
pub tmStruckOut: u8,
pub tmPitchAndFamily: u8,
pub tmCharSet: u8,
}import "golang.org/x/sys/windows"
type TEXTMETRICA struct {
tmHeight int32
tmAscent int32
tmDescent int32
tmInternalLeading int32
tmExternalLeading int32
tmAveCharWidth int32
tmMaxCharWidth int32
tmWeight int32
tmOverhang int32
tmDigitizedAspectX int32
tmDigitizedAspectY int32
tmFirstChar byte
tmLastChar byte
tmDefaultChar byte
tmBreakChar byte
tmItalic byte
tmUnderlined byte
tmStruckOut byte
tmPitchAndFamily byte
tmCharSet byte
}type
TEXTMETRICA = record
tmHeight: Integer;
tmAscent: Integer;
tmDescent: Integer;
tmInternalLeading: Integer;
tmExternalLeading: Integer;
tmAveCharWidth: Integer;
tmMaxCharWidth: Integer;
tmWeight: Integer;
tmOverhang: Integer;
tmDigitizedAspectX: Integer;
tmDigitizedAspectY: Integer;
tmFirstChar: Byte;
tmLastChar: Byte;
tmDefaultChar: Byte;
tmBreakChar: Byte;
tmItalic: Byte;
tmUnderlined: Byte;
tmStruckOut: Byte;
tmPitchAndFamily: Byte;
tmCharSet: Byte;
end;const TEXTMETRICA = extern struct {
tmHeight: i32,
tmAscent: i32,
tmDescent: i32,
tmInternalLeading: i32,
tmExternalLeading: i32,
tmAveCharWidth: i32,
tmMaxCharWidth: i32,
tmWeight: i32,
tmOverhang: i32,
tmDigitizedAspectX: i32,
tmDigitizedAspectY: i32,
tmFirstChar: u8,
tmLastChar: u8,
tmDefaultChar: u8,
tmBreakChar: u8,
tmItalic: u8,
tmUnderlined: u8,
tmStruckOut: u8,
tmPitchAndFamily: u8,
tmCharSet: u8,
};type
TEXTMETRICA {.bycopy.} = object
tmHeight: int32
tmAscent: int32
tmDescent: int32
tmInternalLeading: int32
tmExternalLeading: int32
tmAveCharWidth: int32
tmMaxCharWidth: int32
tmWeight: int32
tmOverhang: int32
tmDigitizedAspectX: int32
tmDigitizedAspectY: int32
tmFirstChar: uint8
tmLastChar: uint8
tmDefaultChar: uint8
tmBreakChar: uint8
tmItalic: uint8
tmUnderlined: uint8
tmStruckOut: uint8
tmPitchAndFamily: uint8
tmCharSet: uint8struct TEXTMETRICA
{
int tmHeight;
int tmAscent;
int tmDescent;
int tmInternalLeading;
int tmExternalLeading;
int tmAveCharWidth;
int tmMaxCharWidth;
int tmWeight;
int tmOverhang;
int tmDigitizedAspectX;
int tmDigitizedAspectY;
ubyte tmFirstChar;
ubyte tmLastChar;
ubyte tmDefaultChar;
ubyte tmBreakChar;
ubyte tmItalic;
ubyte tmUnderlined;
ubyte tmStruckOut;
ubyte tmPitchAndFamily;
ubyte tmCharSet;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TEXTMETRICA サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; tmHeight : INT (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; tmAscent : INT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; tmDescent : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; tmInternalLeading : INT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; tmExternalLeading : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; tmAveCharWidth : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; tmMaxCharWidth : INT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; tmWeight : INT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; tmOverhang : INT (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; tmDigitizedAspectX : INT (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; tmDigitizedAspectY : INT (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; tmFirstChar : BYTE (+44, 1byte) poke st,44,値 / 値 = peek(st,44)
; tmLastChar : BYTE (+45, 1byte) poke st,45,値 / 値 = peek(st,45)
; tmDefaultChar : BYTE (+46, 1byte) poke st,46,値 / 値 = peek(st,46)
; tmBreakChar : BYTE (+47, 1byte) poke st,47,値 / 値 = peek(st,47)
; tmItalic : BYTE (+48, 1byte) poke st,48,値 / 値 = peek(st,48)
; tmUnderlined : BYTE (+49, 1byte) poke st,49,値 / 値 = peek(st,49)
; tmStruckOut : BYTE (+50, 1byte) poke st,50,値 / 値 = peek(st,50)
; tmPitchAndFamily : TMPF_FLAGS (+51, 1byte) poke st,51,値 / 値 = peek(st,51)
; tmCharSet : BYTE (+52, 1byte) poke st,52,値 / 値 = peek(st,52)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global TEXTMETRICA
#field int tmHeight
#field int tmAscent
#field int tmDescent
#field int tmInternalLeading
#field int tmExternalLeading
#field int tmAveCharWidth
#field int tmMaxCharWidth
#field int tmWeight
#field int tmOverhang
#field int tmDigitizedAspectX
#field int tmDigitizedAspectY
#field byte tmFirstChar
#field byte tmLastChar
#field byte tmDefaultChar
#field byte tmBreakChar
#field byte tmItalic
#field byte tmUnderlined
#field byte tmStruckOut
#field byte tmPitchAndFamily
#field byte tmCharSet
#endstruct
stdim st, TEXTMETRICA ; NSTRUCT 変数を確保
st->tmHeight = 100
mes "tmHeight=" + st->tmHeight