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

DWRITE_COLOR_GLYPH_RUN1

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

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

フィールド

フィールドサイズx64x86説明
BaseDWRITE_COLOR_GLYPH_RUN88/64+0+0基本の色付きグリフラン(DWRITE_COLOR_GLYPH_RUN)を埋め込んだ構造体。
glyphImageFormatDWRITE_GLYPH_IMAGE_FORMATS4+88+64グリフ画像の形式(TrueType/CFF/SVG/PNGなど)を示す列挙フラグ。
measuringModeDWRITE_MEASURING_MODE4+92+68テキスト測定モード(自然/GDI互換など)を示す列挙値。

各言語での定義

#include <windows.h>

// DWRITE_GLYPH_RUN  (x64 48 / x86 32 バイト)
typedef struct DWRITE_GLYPH_RUN {
    IDWriteFontFace* fontFace;
    FLOAT fontEmSize;
    DWORD glyphCount;
    WORD* glyphIndices;
    FLOAT* glyphAdvances;
    DWRITE_GLYPH_OFFSET* glyphOffsets;
    BOOL isSideways;
    DWORD bidiLevel;
} DWRITE_GLYPH_RUN;

// DWRITE_COLOR_F  (x64 16 / x86 16 バイト)
typedef struct DWRITE_COLOR_F {
    FLOAT r;
    FLOAT g;
    FLOAT b;
    FLOAT a;
} DWRITE_COLOR_F;

// DWRITE_COLOR_GLYPH_RUN  (x64 88 / x86 64 バイト)
typedef struct DWRITE_COLOR_GLYPH_RUN {
    DWRITE_GLYPH_RUN glyphRun;
    DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription;
    FLOAT baselineOriginX;
    FLOAT baselineOriginY;
    DWRITE_COLOR_F runColor;
    WORD paletteIndex;
} DWRITE_COLOR_GLYPH_RUN;

// DWRITE_COLOR_GLYPH_RUN1  (x64 96 / x86 72 バイト)
typedef struct DWRITE_COLOR_GLYPH_RUN1 {
    DWRITE_COLOR_GLYPH_RUN Base;
    DWRITE_GLYPH_IMAGE_FORMATS glyphImageFormat;
    DWRITE_MEASURING_MODE measuringMode;
} DWRITE_COLOR_GLYPH_RUN1;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_GLYPH_RUN
{
    public IntPtr fontFace;
    public float fontEmSize;
    public uint glyphCount;
    public IntPtr glyphIndices;
    public IntPtr glyphAdvances;
    public IntPtr glyphOffsets;
    [MarshalAs(UnmanagedType.Bool)] public bool isSideways;
    public uint bidiLevel;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_COLOR_F
{
    public float r;
    public float g;
    public float b;
    public float a;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_COLOR_GLYPH_RUN
{
    public DWRITE_GLYPH_RUN glyphRun;
    public IntPtr glyphRunDescription;
    public float baselineOriginX;
    public float baselineOriginY;
    public DWRITE_COLOR_F runColor;
    public ushort paletteIndex;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_COLOR_GLYPH_RUN1
{
    public DWRITE_COLOR_GLYPH_RUN Base;
    public int glyphImageFormat;
    public int measuringMode;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_GLYPH_RUN
    Public fontFace As IntPtr
    Public fontEmSize As Single
    Public glyphCount As UInteger
    Public glyphIndices As IntPtr
    Public glyphAdvances As IntPtr
    Public glyphOffsets As IntPtr
    <MarshalAs(UnmanagedType.Bool)> Public isSideways As Boolean
    Public bidiLevel As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_COLOR_F
    Public r As Single
    Public g As Single
    Public b As Single
    Public a As Single
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_COLOR_GLYPH_RUN
    Public glyphRun As DWRITE_GLYPH_RUN
    Public glyphRunDescription As IntPtr
    Public baselineOriginX As Single
    Public baselineOriginY As Single
    Public runColor As DWRITE_COLOR_F
    Public paletteIndex As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_COLOR_GLYPH_RUN1
    Public Base As DWRITE_COLOR_GLYPH_RUN
    Public glyphImageFormat As Integer
    Public measuringMode As Integer
End Structure
import ctypes
from ctypes import wintypes

class DWRITE_GLYPH_RUN(ctypes.Structure):
    _fields_ = [
        ("fontFace", ctypes.c_void_p),
        ("fontEmSize", ctypes.c_float),
        ("glyphCount", wintypes.DWORD),
        ("glyphIndices", ctypes.c_void_p),
        ("glyphAdvances", ctypes.c_void_p),
        ("glyphOffsets", ctypes.c_void_p),
        ("isSideways", wintypes.BOOL),
        ("bidiLevel", wintypes.DWORD),
    ]

class DWRITE_COLOR_F(ctypes.Structure):
    _fields_ = [
        ("r", ctypes.c_float),
        ("g", ctypes.c_float),
        ("b", ctypes.c_float),
        ("a", ctypes.c_float),
    ]

class DWRITE_COLOR_GLYPH_RUN(ctypes.Structure):
    _fields_ = [
        ("glyphRun", DWRITE_GLYPH_RUN),
        ("glyphRunDescription", ctypes.c_void_p),
        ("baselineOriginX", ctypes.c_float),
        ("baselineOriginY", ctypes.c_float),
        ("runColor", DWRITE_COLOR_F),
        ("paletteIndex", ctypes.c_ushort),
    ]

class DWRITE_COLOR_GLYPH_RUN1(ctypes.Structure):
    _fields_ = [
        ("Base", DWRITE_COLOR_GLYPH_RUN),
        ("glyphImageFormat", ctypes.c_int),
        ("measuringMode", ctypes.c_int),
    ]
#[repr(C)]
pub struct DWRITE_GLYPH_RUN {
    pub fontFace: *mut core::ffi::c_void,
    pub fontEmSize: f32,
    pub glyphCount: u32,
    pub glyphIndices: *mut core::ffi::c_void,
    pub glyphAdvances: *mut core::ffi::c_void,
    pub glyphOffsets: *mut core::ffi::c_void,
    pub isSideways: i32,
    pub bidiLevel: u32,
}

#[repr(C)]
pub struct DWRITE_COLOR_F {
    pub r: f32,
    pub g: f32,
    pub b: f32,
    pub a: f32,
}

#[repr(C)]
pub struct DWRITE_COLOR_GLYPH_RUN {
    pub glyphRun: DWRITE_GLYPH_RUN,
    pub glyphRunDescription: *mut core::ffi::c_void,
    pub baselineOriginX: f32,
    pub baselineOriginY: f32,
    pub runColor: DWRITE_COLOR_F,
    pub paletteIndex: u16,
}

#[repr(C)]
pub struct DWRITE_COLOR_GLYPH_RUN1 {
    pub Base: DWRITE_COLOR_GLYPH_RUN,
    pub glyphImageFormat: i32,
    pub measuringMode: i32,
}
import "golang.org/x/sys/windows"

type DWRITE_GLYPH_RUN struct {
	fontFace uintptr
	fontEmSize float32
	glyphCount uint32
	glyphIndices uintptr
	glyphAdvances uintptr
	glyphOffsets uintptr
	isSideways int32
	bidiLevel uint32
}

type DWRITE_COLOR_F struct {
	r float32
	g float32
	b float32
	a float32
}

type DWRITE_COLOR_GLYPH_RUN struct {
	glyphRun DWRITE_GLYPH_RUN
	glyphRunDescription uintptr
	baselineOriginX float32
	baselineOriginY float32
	runColor DWRITE_COLOR_F
	paletteIndex uint16
}

type DWRITE_COLOR_GLYPH_RUN1 struct {
	Base DWRITE_COLOR_GLYPH_RUN
	glyphImageFormat int32
	measuringMode int32
}
type
  DWRITE_GLYPH_RUN = record
    fontFace: Pointer;
    fontEmSize: Single;
    glyphCount: DWORD;
    glyphIndices: Pointer;
    glyphAdvances: Pointer;
    glyphOffsets: Pointer;
    isSideways: BOOL;
    bidiLevel: DWORD;
  end;

  DWRITE_COLOR_F = record
    r: Single;
    g: Single;
    b: Single;
    a: Single;
  end;

  DWRITE_COLOR_GLYPH_RUN = record
    glyphRun: DWRITE_GLYPH_RUN;
    glyphRunDescription: Pointer;
    baselineOriginX: Single;
    baselineOriginY: Single;
    runColor: DWRITE_COLOR_F;
    paletteIndex: Word;
  end;

  DWRITE_COLOR_GLYPH_RUN1 = record
    Base: DWRITE_COLOR_GLYPH_RUN;
    glyphImageFormat: Integer;
    measuringMode: Integer;
  end;
const DWRITE_GLYPH_RUN = extern struct {
    fontFace: ?*anyopaque,
    fontEmSize: f32,
    glyphCount: u32,
    glyphIndices: ?*anyopaque,
    glyphAdvances: ?*anyopaque,
    glyphOffsets: ?*anyopaque,
    isSideways: i32,
    bidiLevel: u32,
};

const DWRITE_COLOR_F = extern struct {
    r: f32,
    g: f32,
    b: f32,
    a: f32,
};

const DWRITE_COLOR_GLYPH_RUN = extern struct {
    glyphRun: DWRITE_GLYPH_RUN,
    glyphRunDescription: ?*anyopaque,
    baselineOriginX: f32,
    baselineOriginY: f32,
    runColor: DWRITE_COLOR_F,
    paletteIndex: u16,
};

const DWRITE_COLOR_GLYPH_RUN1 = extern struct {
    Base: DWRITE_COLOR_GLYPH_RUN,
    glyphImageFormat: i32,
    measuringMode: i32,
};
type
  DWRITE_GLYPH_RUN {.bycopy.} = object
    fontFace: pointer
    fontEmSize: float32
    glyphCount: uint32
    glyphIndices: pointer
    glyphAdvances: pointer
    glyphOffsets: pointer
    isSideways: int32
    bidiLevel: uint32

  DWRITE_COLOR_F {.bycopy.} = object
    r: float32
    g: float32
    b: float32
    a: float32

  DWRITE_COLOR_GLYPH_RUN {.bycopy.} = object
    glyphRun: DWRITE_GLYPH_RUN
    glyphRunDescription: pointer
    baselineOriginX: float32
    baselineOriginY: float32
    runColor: DWRITE_COLOR_F
    paletteIndex: uint16

  DWRITE_COLOR_GLYPH_RUN1 {.bycopy.} = object
    Base: DWRITE_COLOR_GLYPH_RUN
    glyphImageFormat: int32
    measuringMode: int32
struct DWRITE_GLYPH_RUN
{
    void* fontFace;
    float fontEmSize;
    uint glyphCount;
    void* glyphIndices;
    void* glyphAdvances;
    void* glyphOffsets;
    int isSideways;
    uint bidiLevel;
}

struct DWRITE_COLOR_F
{
    float r;
    float g;
    float b;
    float a;
}

struct DWRITE_COLOR_GLYPH_RUN
{
    DWRITE_GLYPH_RUN glyphRun;
    void* glyphRunDescription;
    float baselineOriginX;
    float baselineOriginY;
    DWRITE_COLOR_F runColor;
    ushort paletteIndex;
}

struct DWRITE_COLOR_GLYPH_RUN1
{
    DWRITE_COLOR_GLYPH_RUN Base;
    int glyphImageFormat;
    int measuringMode;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DWRITE_COLOR_GLYPH_RUN1 サイズ: 72 バイト(x86)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; Base : DWRITE_COLOR_GLYPH_RUN (+0, 64byte)  varptr(st)+0 を基点に操作(64byte:入れ子/配列)
; glyphImageFormat : DWRITE_GLYPH_IMAGE_FORMATS (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; measuringMode : DWRITE_MEASURING_MODE (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DWRITE_COLOR_GLYPH_RUN1 サイズ: 96 バイト(x64)
dim st, 24    ; 4byte整数×24(構造体サイズ 96 / 4 切り上げ)
; Base : DWRITE_COLOR_GLYPH_RUN (+0, 88byte)  varptr(st)+0 を基点に操作(88byte:入れ子/配列)
; glyphImageFormat : DWRITE_GLYPH_IMAGE_FORMATS (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; measuringMode : DWRITE_MEASURING_MODE (+92, 4byte)  st.23 = 値  /  値 = st.23   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DWRITE_GLYPH_RUN
    #field intptr fontFace
    #field float fontEmSize
    #field int glyphCount
    #field intptr glyphIndices
    #field intptr glyphAdvances
    #field intptr glyphOffsets
    #field bool isSideways
    #field int bidiLevel
#endstruct

#defstruct global DWRITE_COLOR_F
    #field float r
    #field float g
    #field float b
    #field float a
#endstruct

#defstruct global DWRITE_COLOR_GLYPH_RUN
    #field DWRITE_GLYPH_RUN glyphRun
    #field intptr glyphRunDescription
    #field float baselineOriginX
    #field float baselineOriginY
    #field DWRITE_COLOR_F runColor
    #field short paletteIndex
#endstruct

#defstruct global DWRITE_COLOR_GLYPH_RUN1
    #field DWRITE_COLOR_GLYPH_RUN Base
    #field int glyphImageFormat
    #field int measuringMode
#endstruct

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