ホーム › Graphics.GdiPlus › GdipCreateFont
GdipCreateFont
関数フォントファミリーとサイズからフォントを作成する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipCreateFont(
const GpFontFamily* fontFamily,
FLOAT emSize,
INT style,
Unit unit,
GpFont** font
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| fontFamily | GpFontFamily* | in |
| emSize | FLOAT | in |
| style | INT | in |
| unit | Unit | in |
| font | GpFont** | inout |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipCreateFont(
const GpFontFamily* fontFamily,
FLOAT emSize,
INT style,
Unit unit,
GpFont** font
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipCreateFont(
IntPtr fontFamily, // GpFontFamily*
float emSize, // FLOAT
int style, // INT
int unit, // Unit
IntPtr font // GpFont** in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipCreateFont(
fontFamily As IntPtr, ' GpFontFamily*
emSize As Single, ' FLOAT
style As Integer, ' INT
unit As Integer, ' Unit
font As IntPtr ' GpFont** in/out
) As Integer
End Function' fontFamily : GpFontFamily*
' emSize : FLOAT
' style : INT
' unit : Unit
' font : GpFont** in/out
Declare PtrSafe Function GdipCreateFont Lib "gdiplus" ( _
ByVal fontFamily As LongPtr, _
ByVal emSize As Single, _
ByVal style As Long, _
ByVal unit As Long, _
ByVal font As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipCreateFont = ctypes.windll.gdiplus.GdipCreateFont
GdipCreateFont.restype = ctypes.c_int
GdipCreateFont.argtypes = [
ctypes.c_void_p, # fontFamily : GpFontFamily*
ctypes.c_float, # emSize : FLOAT
ctypes.c_int, # style : INT
ctypes.c_int, # unit : Unit
ctypes.c_void_p, # font : GpFont** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipCreateFont = Fiddle::Function.new(
lib['GdipCreateFont'],
[
Fiddle::TYPE_VOIDP, # fontFamily : GpFontFamily*
Fiddle::TYPE_FLOAT, # emSize : FLOAT
Fiddle::TYPE_INT, # style : INT
Fiddle::TYPE_INT, # unit : Unit
Fiddle::TYPE_VOIDP, # font : GpFont** in/out
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipCreateFont(
fontFamily: *const GpFontFamily, // GpFontFamily*
emSize: f32, // FLOAT
style: i32, // INT
unit: i32, // Unit
font: *mut *mut GpFont // GpFont** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipCreateFont(IntPtr fontFamily, float emSize, int style, int unit, IntPtr font);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreateFont' -Namespace Win32 -PassThru
# $api::GdipCreateFont(fontFamily, emSize, style, unit, font)#uselib "gdiplus.dll"
#func global GdipCreateFont "GdipCreateFont" sptr, float, sptr, sptr, sptr
; GdipCreateFont varptr(fontFamily), emSize, style, unit, varptr(font) ; 戻り値は stat
; fontFamily : GpFontFamily* -> "sptr"
; emSize : FLOAT -> "float"
; style : INT -> "sptr"
; unit : Unit -> "sptr"
; font : GpFont** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipCreateFont "GdipCreateFont" var, float, int, int, var ; res = GdipCreateFont(fontFamily, emSize, style, unit, font) ; fontFamily : GpFontFamily* -> "var" ; emSize : FLOAT -> "float" ; style : INT -> "int" ; unit : Unit -> "int" ; font : GpFont** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipCreateFont "GdipCreateFont" sptr, float, int, int, sptr ; res = GdipCreateFont(varptr(fontFamily), emSize, style, unit, varptr(font)) ; fontFamily : GpFontFamily* -> "sptr" ; emSize : FLOAT -> "float" ; style : INT -> "int" ; unit : Unit -> "int" ; font : GpFont** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipCreateFont(GpFontFamily* fontFamily, FLOAT emSize, INT style, Unit unit, GpFont** font) #uselib "gdiplus.dll" #cfunc global GdipCreateFont "GdipCreateFont" var, float, int, int, var ; res = GdipCreateFont(fontFamily, emSize, style, unit, font) ; fontFamily : GpFontFamily* -> "var" ; emSize : FLOAT -> "float" ; style : INT -> "int" ; unit : Unit -> "int" ; font : GpFont** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipCreateFont(GpFontFamily* fontFamily, FLOAT emSize, INT style, Unit unit, GpFont** font) #uselib "gdiplus.dll" #cfunc global GdipCreateFont "GdipCreateFont" intptr, float, int, int, intptr ; res = GdipCreateFont(varptr(fontFamily), emSize, style, unit, varptr(font)) ; fontFamily : GpFontFamily* -> "intptr" ; emSize : FLOAT -> "float" ; style : INT -> "int" ; unit : Unit -> "int" ; font : GpFont** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipCreateFont = gdiplus.NewProc("GdipCreateFont")
)
// fontFamily (GpFontFamily*), emSize (FLOAT), style (INT), unit (Unit), font (GpFont** in/out)
r1, _, err := procGdipCreateFont.Call(
uintptr(fontFamily),
uintptr(math.Float32bits(emSize)),
uintptr(style),
uintptr(unit),
uintptr(font),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Status
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。function GdipCreateFont(
fontFamily: Pointer; // GpFontFamily*
emSize: Single; // FLOAT
style: Integer; // INT
unit: Integer; // Unit
font: Pointer // GpFont** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreateFont';result := DllCall("gdiplus\GdipCreateFont"
, "Ptr", fontFamily ; GpFontFamily*
, "Float", emSize ; FLOAT
, "Int", style ; INT
, "Int", unit ; Unit
, "Ptr", font ; GpFont** in/out
, "Int") ; return: Status●GdipCreateFont(fontFamily, emSize, style, unit, font) = DLL("gdiplus.dll", "int GdipCreateFont(void*, float, int, int, void*)")
# 呼び出し: GdipCreateFont(fontFamily, emSize, style, unit, font)
# fontFamily : GpFontFamily* -> "void*"
# emSize : FLOAT -> "float"
# style : INT -> "int"
# unit : Unit -> "int"
# font : GpFont** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。