ホーム › Graphics.GdiPlus › GdipCreateFontFromLogfontW
GdipCreateFontFromLogfontW
関数LOGFONT構造体からフォントオブジェクトを作成する(Unicode版)。
シグネチャ
// gdiplus.dll (Unicode / -W)
#include <windows.h>
Status GdipCreateFontFromLogfontW(
HDC hdc,
const LOGFONTW* logfont,
GpFont** font
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| logfont | LOGFONTW* | in |
| font | GpFont** | inout |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll (Unicode / -W)
#include <windows.h>
Status GdipCreateFontFromLogfontW(
HDC hdc,
const LOGFONTW* logfont,
GpFont** font
);[DllImport("gdiplus.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int GdipCreateFontFromLogfontW(
IntPtr hdc, // HDC
IntPtr logfont, // LOGFONTW*
IntPtr font // GpFont** in/out
);<DllImport("gdiplus.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GdipCreateFontFromLogfontW(
hdc As IntPtr, ' HDC
logfont As IntPtr, ' LOGFONTW*
font As IntPtr ' GpFont** in/out
) As Integer
End Function' hdc : HDC
' logfont : LOGFONTW*
' font : GpFont** in/out
Declare PtrSafe Function GdipCreateFontFromLogfontW Lib "gdiplus" ( _
ByVal hdc As LongPtr, _
ByVal logfont As LongPtr, _
ByVal font As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipCreateFontFromLogfontW = ctypes.windll.gdiplus.GdipCreateFontFromLogfontW
GdipCreateFontFromLogfontW.restype = ctypes.c_int
GdipCreateFontFromLogfontW.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # logfont : LOGFONTW*
ctypes.c_void_p, # font : GpFont** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipCreateFontFromLogfontW = Fiddle::Function.new(
lib['GdipCreateFontFromLogfontW'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # logfont : LOGFONTW*
Fiddle::TYPE_VOIDP, # font : GpFont** in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "gdiplus")]
extern "system" {
fn GdipCreateFontFromLogfontW(
hdc: *mut core::ffi::c_void, // HDC
logfont: *const LOGFONTW, // LOGFONTW*
font: *mut *mut GpFont // GpFont** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll", CharSet = CharSet.Unicode)]
public static extern int GdipCreateFontFromLogfontW(IntPtr hdc, IntPtr logfont, IntPtr font);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreateFontFromLogfontW' -Namespace Win32 -PassThru
# $api::GdipCreateFontFromLogfontW(hdc, logfont, font)#uselib "gdiplus.dll"
#func global GdipCreateFontFromLogfontW "GdipCreateFontFromLogfontW" wptr, wptr, wptr
; GdipCreateFontFromLogfontW hdc, varptr(logfont), varptr(font) ; 戻り値は stat
; hdc : HDC -> "wptr"
; logfont : LOGFONTW* -> "wptr"
; font : GpFont** in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipCreateFontFromLogfontW "GdipCreateFontFromLogfontW" sptr, var, var ; res = GdipCreateFontFromLogfontW(hdc, logfont, font) ; hdc : HDC -> "sptr" ; logfont : LOGFONTW* -> "var" ; font : GpFont** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipCreateFontFromLogfontW "GdipCreateFontFromLogfontW" sptr, sptr, sptr ; res = GdipCreateFontFromLogfontW(hdc, varptr(logfont), varptr(font)) ; hdc : HDC -> "sptr" ; logfont : LOGFONTW* -> "sptr" ; font : GpFont** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipCreateFontFromLogfontW(HDC hdc, LOGFONTW* logfont, GpFont** font) #uselib "gdiplus.dll" #cfunc global GdipCreateFontFromLogfontW "GdipCreateFontFromLogfontW" intptr, var, var ; res = GdipCreateFontFromLogfontW(hdc, logfont, font) ; hdc : HDC -> "intptr" ; logfont : LOGFONTW* -> "var" ; font : GpFont** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipCreateFontFromLogfontW(HDC hdc, LOGFONTW* logfont, GpFont** font) #uselib "gdiplus.dll" #cfunc global GdipCreateFontFromLogfontW "GdipCreateFontFromLogfontW" intptr, intptr, intptr ; res = GdipCreateFontFromLogfontW(hdc, varptr(logfont), varptr(font)) ; hdc : HDC -> "intptr" ; logfont : LOGFONTW* -> "intptr" ; font : GpFont** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipCreateFontFromLogfontW = gdiplus.NewProc("GdipCreateFontFromLogfontW")
)
// hdc (HDC), logfont (LOGFONTW*), font (GpFont** in/out)
r1, _, err := procGdipCreateFontFromLogfontW.Call(
uintptr(hdc),
uintptr(logfont),
uintptr(font),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipCreateFontFromLogfontW(
hdc: THandle; // HDC
logfont: Pointer; // LOGFONTW*
font: Pointer // GpFont** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreateFontFromLogfontW';result := DllCall("gdiplus\GdipCreateFontFromLogfontW"
, "Ptr", hdc ; HDC
, "Ptr", logfont ; LOGFONTW*
, "Ptr", font ; GpFont** in/out
, "Int") ; return: Status●GdipCreateFontFromLogfontW(hdc, logfont, font) = DLL("gdiplus.dll", "int GdipCreateFontFromLogfontW(void*, void*, void*)")
# 呼び出し: GdipCreateFontFromLogfontW(hdc, logfont, font)
# hdc : HDC -> "void*"
# logfont : LOGFONTW* -> "void*"
# font : GpFont** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。