ホーム › Devices.Display › FONTOBJ_cGetGlyphs
FONTOBJ_cGetGlyphs
関数フォントオブジェクトから指定グリフのビットマップ情報を取得する。
シグネチャ
// GDI32.dll
#include <windows.h>
DWORD FONTOBJ_cGetGlyphs(
FONTOBJ* pfo,
DWORD iMode,
DWORD cGlyph,
DWORD* phg,
void** ppvGlyph
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| pfo | FONTOBJ* | inout | 変換対象のグリフハンドルを含む FONTOBJ 構造体へのポインターです。 | ||||||
| iMode | DWORD | in | データをビットマップとして書き込むか、アウトラインオブジェクトとして書き込むかを指定します。このパラメーターには、次のいずれかの値を指定できます。
| ||||||
| cGlyph | DWORD | in | 変換するグリフの数を指定します。指定可能な値は 1 のみです(コードは指定された値に関係なく 1 を前提とします)。 | ||||||
| phg | DWORD* | inout | ドライバーが指定する cGlyph 個の HGLYPH 構造体の配列へのポインターです。 | ||||||
| ppvGlyph | void** | inout | GLYPHDATA 構造体のアドレスを受け取るメモリ位置へのポインターです。この構造体の最初のメンバーは GLYPHDEF 共用体であり、iMode パラメーターの値に応じて GLYPHBITS 構造体または PATHOBJ 構造体のいずれかへのポインターを格納します。iMode の値が FO_GLYPHBITS の場合、(ppvGlyph)->gdf には GLYPHBITS 構造体のアドレスが格納されます。iMode の値が FO_PATHOBJ の場合、(ppvGlyph)->gdf には PATHOBJ 構造体のアドレスが格納されます。 |
戻り値の型: DWORD
公式ドキュメント
FONTOBJ_cGetGlyphs 関数は、グリフハンドルをグリフデータへのポインターに変換する、フォントコンシューマー向けのサービスです。このポインターは、次に FONTOBJ_cGetGlyphs を呼び出すまで有効です。
戻り値
関数が成功した場合、戻り値はドライバーに渡されたポインターの数です。失敗した場合は 0 となり、エラーコードがログに記録されます。
解説(Remarks)
この関数は、ドライバーがフォントをキャッシュしている場合に使用してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
DWORD FONTOBJ_cGetGlyphs(
FONTOBJ* pfo,
DWORD iMode,
DWORD cGlyph,
DWORD* phg,
void** ppvGlyph
);[DllImport("GDI32.dll", ExactSpelling = true)]
static extern uint FONTOBJ_cGetGlyphs(
IntPtr pfo, // FONTOBJ* in/out
uint iMode, // DWORD
uint cGlyph, // DWORD
ref uint phg, // DWORD* in/out
IntPtr ppvGlyph // void** in/out
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function FONTOBJ_cGetGlyphs(
pfo As IntPtr, ' FONTOBJ* in/out
iMode As UInteger, ' DWORD
cGlyph As UInteger, ' DWORD
ByRef phg As UInteger, ' DWORD* in/out
ppvGlyph As IntPtr ' void** in/out
) As UInteger
End Function' pfo : FONTOBJ* in/out
' iMode : DWORD
' cGlyph : DWORD
' phg : DWORD* in/out
' ppvGlyph : void** in/out
Declare PtrSafe Function FONTOBJ_cGetGlyphs Lib "gdi32" ( _
ByVal pfo As LongPtr, _
ByVal iMode As Long, _
ByVal cGlyph As Long, _
ByRef phg As Long, _
ByVal ppvGlyph As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FONTOBJ_cGetGlyphs = ctypes.windll.gdi32.FONTOBJ_cGetGlyphs
FONTOBJ_cGetGlyphs.restype = wintypes.DWORD
FONTOBJ_cGetGlyphs.argtypes = [
ctypes.c_void_p, # pfo : FONTOBJ* in/out
wintypes.DWORD, # iMode : DWORD
wintypes.DWORD, # cGlyph : DWORD
ctypes.POINTER(wintypes.DWORD), # phg : DWORD* in/out
ctypes.c_void_p, # ppvGlyph : void** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
FONTOBJ_cGetGlyphs = Fiddle::Function.new(
lib['FONTOBJ_cGetGlyphs'],
[
Fiddle::TYPE_VOIDP, # pfo : FONTOBJ* in/out
-Fiddle::TYPE_INT, # iMode : DWORD
-Fiddle::TYPE_INT, # cGlyph : DWORD
Fiddle::TYPE_VOIDP, # phg : DWORD* in/out
Fiddle::TYPE_VOIDP, # ppvGlyph : void** in/out
],
-Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn FONTOBJ_cGetGlyphs(
pfo: *mut FONTOBJ, // FONTOBJ* in/out
iMode: u32, // DWORD
cGlyph: u32, // DWORD
phg: *mut u32, // DWORD* in/out
ppvGlyph: *mut *mut () // void** in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll")]
public static extern uint FONTOBJ_cGetGlyphs(IntPtr pfo, uint iMode, uint cGlyph, ref uint phg, IntPtr ppvGlyph);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_FONTOBJ_cGetGlyphs' -Namespace Win32 -PassThru
# $api::FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph)#uselib "GDI32.dll"
#func global FONTOBJ_cGetGlyphs "FONTOBJ_cGetGlyphs" sptr, sptr, sptr, sptr, sptr
; FONTOBJ_cGetGlyphs varptr(pfo), iMode, cGlyph, varptr(phg), ppvGlyph ; 戻り値は stat
; pfo : FONTOBJ* in/out -> "sptr"
; iMode : DWORD -> "sptr"
; cGlyph : DWORD -> "sptr"
; phg : DWORD* in/out -> "sptr"
; ppvGlyph : void** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global FONTOBJ_cGetGlyphs "FONTOBJ_cGetGlyphs" var, int, int, var, sptr ; res = FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph) ; pfo : FONTOBJ* in/out -> "var" ; iMode : DWORD -> "int" ; cGlyph : DWORD -> "int" ; phg : DWORD* in/out -> "var" ; ppvGlyph : void** in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global FONTOBJ_cGetGlyphs "FONTOBJ_cGetGlyphs" sptr, int, int, sptr, sptr ; res = FONTOBJ_cGetGlyphs(varptr(pfo), iMode, cGlyph, varptr(phg), ppvGlyph) ; pfo : FONTOBJ* in/out -> "sptr" ; iMode : DWORD -> "int" ; cGlyph : DWORD -> "int" ; phg : DWORD* in/out -> "sptr" ; ppvGlyph : void** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD FONTOBJ_cGetGlyphs(FONTOBJ* pfo, DWORD iMode, DWORD cGlyph, DWORD* phg, void** ppvGlyph) #uselib "GDI32.dll" #cfunc global FONTOBJ_cGetGlyphs "FONTOBJ_cGetGlyphs" var, int, int, var, intptr ; res = FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph) ; pfo : FONTOBJ* in/out -> "var" ; iMode : DWORD -> "int" ; cGlyph : DWORD -> "int" ; phg : DWORD* in/out -> "var" ; ppvGlyph : void** in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD FONTOBJ_cGetGlyphs(FONTOBJ* pfo, DWORD iMode, DWORD cGlyph, DWORD* phg, void** ppvGlyph) #uselib "GDI32.dll" #cfunc global FONTOBJ_cGetGlyphs "FONTOBJ_cGetGlyphs" intptr, int, int, intptr, intptr ; res = FONTOBJ_cGetGlyphs(varptr(pfo), iMode, cGlyph, varptr(phg), ppvGlyph) ; pfo : FONTOBJ* in/out -> "intptr" ; iMode : DWORD -> "int" ; cGlyph : DWORD -> "int" ; phg : DWORD* in/out -> "intptr" ; ppvGlyph : void** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procFONTOBJ_cGetGlyphs = gdi32.NewProc("FONTOBJ_cGetGlyphs")
)
// pfo (FONTOBJ* in/out), iMode (DWORD), cGlyph (DWORD), phg (DWORD* in/out), ppvGlyph (void** in/out)
r1, _, err := procFONTOBJ_cGetGlyphs.Call(
uintptr(pfo),
uintptr(iMode),
uintptr(cGlyph),
uintptr(phg),
uintptr(ppvGlyph),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction FONTOBJ_cGetGlyphs(
pfo: Pointer; // FONTOBJ* in/out
iMode: DWORD; // DWORD
cGlyph: DWORD; // DWORD
phg: Pointer; // DWORD* in/out
ppvGlyph: Pointer // void** in/out
): DWORD; stdcall;
external 'GDI32.dll' name 'FONTOBJ_cGetGlyphs';result := DllCall("GDI32\FONTOBJ_cGetGlyphs"
, "Ptr", pfo ; FONTOBJ* in/out
, "UInt", iMode ; DWORD
, "UInt", cGlyph ; DWORD
, "Ptr", phg ; DWORD* in/out
, "Ptr", ppvGlyph ; void** in/out
, "UInt") ; return: DWORD●FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph) = DLL("GDI32.dll", "dword FONTOBJ_cGetGlyphs(void*, dword, dword, void*, void*)")
# 呼び出し: FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph)
# pfo : FONTOBJ* in/out -> "void*"
# iMode : DWORD -> "dword"
# cGlyph : DWORD -> "dword"
# phg : DWORD* in/out -> "void*"
# ppvGlyph : void** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdi32" fn FONTOBJ_cGetGlyphs(
pfo: [*c]FONTOBJ, // FONTOBJ* in/out
iMode: u32, // DWORD
cGlyph: u32, // DWORD
phg: [*c]u32, // DWORD* in/out
ppvGlyph: ?*anyopaque // void** in/out
) callconv(std.os.windows.WINAPI) u32;proc FONTOBJ_cGetGlyphs(
pfo: ptr FONTOBJ, # FONTOBJ* in/out
iMode: uint32, # DWORD
cGlyph: uint32, # DWORD
phg: ptr uint32, # DWORD* in/out
ppvGlyph: pointer # void** in/out
): uint32 {.importc: "FONTOBJ_cGetGlyphs", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
uint FONTOBJ_cGetGlyphs(
FONTOBJ* pfo, // FONTOBJ* in/out
uint iMode, // DWORD
uint cGlyph, // DWORD
uint* phg, // DWORD* in/out
void** ppvGlyph // void** in/out
);ccall((:FONTOBJ_cGetGlyphs, "GDI32.dll"), stdcall, UInt32,
(Ptr{FONTOBJ}, UInt32, UInt32, Ptr{UInt32}, Ptr{Cvoid}),
pfo, iMode, cGlyph, phg, ppvGlyph)
# pfo : FONTOBJ* in/out -> Ptr{FONTOBJ}
# iMode : DWORD -> UInt32
# cGlyph : DWORD -> UInt32
# phg : DWORD* in/out -> Ptr{UInt32}
# ppvGlyph : void** in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t FONTOBJ_cGetGlyphs(
void* pfo,
uint32_t iMode,
uint32_t cGlyph,
uint32_t* phg,
void** ppvGlyph);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph)
-- pfo : FONTOBJ* in/out
-- iMode : DWORD
-- cGlyph : DWORD
-- phg : DWORD* in/out
-- ppvGlyph : void** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const FONTOBJ_cGetGlyphs = lib.func('__stdcall', 'FONTOBJ_cGetGlyphs', 'uint32_t', ['void *', 'uint32_t', 'uint32_t', 'uint32_t *', 'void *']);
// FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph)
// pfo : FONTOBJ* in/out -> 'void *'
// iMode : DWORD -> 'uint32_t'
// cGlyph : DWORD -> 'uint32_t'
// phg : DWORD* in/out -> 'uint32_t *'
// ppvGlyph : void** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GDI32.dll", {
FONTOBJ_cGetGlyphs: { parameters: ["pointer", "u32", "u32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph)
// pfo : FONTOBJ* in/out -> "pointer"
// iMode : DWORD -> "u32"
// cGlyph : DWORD -> "u32"
// phg : DWORD* in/out -> "pointer"
// ppvGlyph : void** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t FONTOBJ_cGetGlyphs(
void* pfo,
uint32_t iMode,
uint32_t cGlyph,
uint32_t* phg,
void** ppvGlyph);
C, "GDI32.dll");
// $ffi->FONTOBJ_cGetGlyphs(pfo, iMode, cGlyph, phg, ppvGlyph);
// pfo : FONTOBJ* in/out
// iMode : DWORD
// cGlyph : DWORD
// phg : DWORD* in/out
// ppvGlyph : void** in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
int FONTOBJ_cGetGlyphs(
Pointer pfo, // FONTOBJ* in/out
int iMode, // DWORD
int cGlyph, // DWORD
IntByReference phg, // DWORD* in/out
Pointer ppvGlyph // void** in/out
);
}@[Link("gdi32")]
lib LibGDI32
fun FONTOBJ_cGetGlyphs = FONTOBJ_cGetGlyphs(
pfo : FONTOBJ*, # FONTOBJ* in/out
iMode : UInt32, # DWORD
cGlyph : UInt32, # DWORD
phg : UInt32*, # DWORD* in/out
ppvGlyph : Void** # void** in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef FONTOBJ_cGetGlyphsNative = Uint32 Function(Pointer<Void>, Uint32, Uint32, Pointer<Uint32>, Pointer<Void>);
typedef FONTOBJ_cGetGlyphsDart = int Function(Pointer<Void>, int, int, Pointer<Uint32>, Pointer<Void>);
final FONTOBJ_cGetGlyphs = DynamicLibrary.open('GDI32.dll')
.lookupFunction<FONTOBJ_cGetGlyphsNative, FONTOBJ_cGetGlyphsDart>('FONTOBJ_cGetGlyphs');
// pfo : FONTOBJ* in/out -> Pointer<Void>
// iMode : DWORD -> Uint32
// cGlyph : DWORD -> Uint32
// phg : DWORD* in/out -> Pointer<Uint32>
// ppvGlyph : void** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function FONTOBJ_cGetGlyphs(
pfo: Pointer; // FONTOBJ* in/out
iMode: DWORD; // DWORD
cGlyph: DWORD; // DWORD
phg: Pointer; // DWORD* in/out
ppvGlyph: Pointer // void** in/out
): DWORD; stdcall;
external 'GDI32.dll' name 'FONTOBJ_cGetGlyphs';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "FONTOBJ_cGetGlyphs"
c_FONTOBJ_cGetGlyphs :: Ptr () -> Word32 -> Word32 -> Ptr Word32 -> Ptr () -> IO Word32
-- pfo : FONTOBJ* in/out -> Ptr ()
-- iMode : DWORD -> Word32
-- cGlyph : DWORD -> Word32
-- phg : DWORD* in/out -> Ptr Word32
-- ppvGlyph : void** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let fontobj_cgetglyphs =
foreign "FONTOBJ_cGetGlyphs"
((ptr void) @-> uint32_t @-> uint32_t @-> (ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* pfo : FONTOBJ* in/out -> (ptr void) *)
(* iMode : DWORD -> uint32_t *)
(* cGlyph : DWORD -> uint32_t *)
(* phg : DWORD* in/out -> (ptr uint32_t) *)
(* ppvGlyph : void** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("FONTOBJ_cGetGlyphs" fontobj-c-get-glyphs :convention :stdcall) :uint32
(pfo :pointer) ; FONTOBJ* in/out
(i-mode :uint32) ; DWORD
(c-glyph :uint32) ; DWORD
(phg :pointer) ; DWORD* in/out
(ppv-glyph :pointer)) ; void** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $FONTOBJ_cGetGlyphs = Win32::API::More->new('GDI32',
'DWORD FONTOBJ_cGetGlyphs(LPVOID pfo, DWORD iMode, DWORD cGlyph, LPVOID phg, LPVOID ppvGlyph)');
# my $ret = $FONTOBJ_cGetGlyphs->Call($pfo, $iMode, $cGlyph, $phg, $ppvGlyph);
# pfo : FONTOBJ* in/out -> LPVOID
# iMode : DWORD -> DWORD
# cGlyph : DWORD -> DWORD
# phg : DWORD* in/out -> LPVOID
# ppvGlyph : void** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f FONTOBJ_cGetAllGlyphHandles — フォントオブジェクトの全グリフのハンドルを取得する。
- s GLYPHBITS
- s IFIMETRICS
- s PATHOBJ
使用する型