ホーム › Graphics.GdiPlus › GdipPrivateAddMemoryFont
GdipPrivateAddMemoryFont
関数メモリ上のフォントデータをプライベートコレクションに追加する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipPrivateAddMemoryFont(
GpFontCollection* fontCollection,
const void* memory,
INT length
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| fontCollection | GpFontCollection* | inout | フォントを追加する対象のプライベートフォントコレクションへのポインタ。 |
| memory | void* | in | フォントデータが格納されたメモリ領域の先頭へのポインタ。 |
| length | INT | in | メモリ上のフォントデータのバイト長を示すINT値。 |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipPrivateAddMemoryFont(
GpFontCollection* fontCollection,
const void* memory,
INT length
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipPrivateAddMemoryFont(
IntPtr fontCollection, // GpFontCollection* in/out
IntPtr memory, // void*
int length // INT
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipPrivateAddMemoryFont(
fontCollection As IntPtr, ' GpFontCollection* in/out
memory As IntPtr, ' void*
length As Integer ' INT
) As Integer
End Function' fontCollection : GpFontCollection* in/out
' memory : void*
' length : INT
Declare PtrSafe Function GdipPrivateAddMemoryFont Lib "gdiplus" ( _
ByVal fontCollection As LongPtr, _
ByVal memory As LongPtr, _
ByVal length As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipPrivateAddMemoryFont = ctypes.windll.gdiplus.GdipPrivateAddMemoryFont
GdipPrivateAddMemoryFont.restype = ctypes.c_int
GdipPrivateAddMemoryFont.argtypes = [
ctypes.c_void_p, # fontCollection : GpFontCollection* in/out
ctypes.POINTER(None), # memory : void*
ctypes.c_int, # length : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipPrivateAddMemoryFont = Fiddle::Function.new(
lib['GdipPrivateAddMemoryFont'],
[
Fiddle::TYPE_VOIDP, # fontCollection : GpFontCollection* in/out
Fiddle::TYPE_VOIDP, # memory : void*
Fiddle::TYPE_INT, # length : INT
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipPrivateAddMemoryFont(
fontCollection: *mut GpFontCollection, // GpFontCollection* in/out
memory: *const (), // void*
length: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipPrivateAddMemoryFont(IntPtr fontCollection, IntPtr memory, int length);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipPrivateAddMemoryFont' -Namespace Win32 -PassThru
# $api::GdipPrivateAddMemoryFont(fontCollection, memory, length)#uselib "gdiplus.dll"
#func global GdipPrivateAddMemoryFont "GdipPrivateAddMemoryFont" sptr, sptr, sptr
; GdipPrivateAddMemoryFont varptr(fontCollection), memory, length ; 戻り値は stat
; fontCollection : GpFontCollection* in/out -> "sptr"
; memory : void* -> "sptr"
; length : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipPrivateAddMemoryFont "GdipPrivateAddMemoryFont" var, sptr, int ; res = GdipPrivateAddMemoryFont(fontCollection, memory, length) ; fontCollection : GpFontCollection* in/out -> "var" ; memory : void* -> "sptr" ; length : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipPrivateAddMemoryFont "GdipPrivateAddMemoryFont" sptr, sptr, int ; res = GdipPrivateAddMemoryFont(varptr(fontCollection), memory, length) ; fontCollection : GpFontCollection* in/out -> "sptr" ; memory : void* -> "sptr" ; length : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipPrivateAddMemoryFont(GpFontCollection* fontCollection, void* memory, INT length) #uselib "gdiplus.dll" #cfunc global GdipPrivateAddMemoryFont "GdipPrivateAddMemoryFont" var, intptr, int ; res = GdipPrivateAddMemoryFont(fontCollection, memory, length) ; fontCollection : GpFontCollection* in/out -> "var" ; memory : void* -> "intptr" ; length : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipPrivateAddMemoryFont(GpFontCollection* fontCollection, void* memory, INT length) #uselib "gdiplus.dll" #cfunc global GdipPrivateAddMemoryFont "GdipPrivateAddMemoryFont" intptr, intptr, int ; res = GdipPrivateAddMemoryFont(varptr(fontCollection), memory, length) ; fontCollection : GpFontCollection* in/out -> "intptr" ; memory : void* -> "intptr" ; length : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipPrivateAddMemoryFont = gdiplus.NewProc("GdipPrivateAddMemoryFont")
)
// fontCollection (GpFontCollection* in/out), memory (void*), length (INT)
r1, _, err := procGdipPrivateAddMemoryFont.Call(
uintptr(fontCollection),
uintptr(memory),
uintptr(length),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipPrivateAddMemoryFont(
fontCollection: Pointer; // GpFontCollection* in/out
memory: Pointer; // void*
length: Integer // INT
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipPrivateAddMemoryFont';result := DllCall("gdiplus\GdipPrivateAddMemoryFont"
, "Ptr", fontCollection ; GpFontCollection* in/out
, "Ptr", memory ; void*
, "Int", length ; INT
, "Int") ; return: Status●GdipPrivateAddMemoryFont(fontCollection, memory, length) = DLL("gdiplus.dll", "int GdipPrivateAddMemoryFont(void*, void*, int)")
# 呼び出し: GdipPrivateAddMemoryFont(fontCollection, memory, length)
# fontCollection : GpFontCollection* in/out -> "void*"
# memory : void* -> "void*"
# length : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdiplus" fn GdipPrivateAddMemoryFont(
fontCollection: [*c]GpFontCollection, // GpFontCollection* in/out
memory: ?*anyopaque, // void*
length: i32 // INT
) callconv(std.os.windows.WINAPI) i32;proc GdipPrivateAddMemoryFont(
fontCollection: ptr GpFontCollection, # GpFontCollection* in/out
memory: pointer, # void*
length: int32 # INT
): int32 {.importc: "GdipPrivateAddMemoryFont", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipPrivateAddMemoryFont(
GpFontCollection* fontCollection, // GpFontCollection* in/out
void* memory, // void*
int length // INT
);ccall((:GdipPrivateAddMemoryFont, "gdiplus.dll"), stdcall, Int32,
(Ptr{GpFontCollection}, Ptr{Cvoid}, Int32),
fontCollection, memory, length)
# fontCollection : GpFontCollection* in/out -> Ptr{GpFontCollection}
# memory : void* -> Ptr{Cvoid}
# length : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipPrivateAddMemoryFont(
void* fontCollection,
void* memory,
int32_t length);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipPrivateAddMemoryFont(fontCollection, memory, length)
-- fontCollection : GpFontCollection* in/out
-- memory : void*
-- length : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipPrivateAddMemoryFont = lib.func('__stdcall', 'GdipPrivateAddMemoryFont', 'int32_t', ['void *', 'void *', 'int32_t']);
// GdipPrivateAddMemoryFont(fontCollection, memory, length)
// fontCollection : GpFontCollection* in/out -> 'void *'
// memory : void* -> 'void *'
// length : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipPrivateAddMemoryFont: { parameters: ["pointer", "pointer", "i32"], result: "i32" },
});
// lib.symbols.GdipPrivateAddMemoryFont(fontCollection, memory, length)
// fontCollection : GpFontCollection* in/out -> "pointer"
// memory : void* -> "pointer"
// length : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipPrivateAddMemoryFont(
void* fontCollection,
void* memory,
int32_t length);
C, "gdiplus.dll");
// $ffi->GdipPrivateAddMemoryFont(fontCollection, memory, length);
// fontCollection : GpFontCollection* in/out
// memory : void*
// length : INT
// 構造体/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 Gdiplus extends StdCallLibrary {
Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class);
int GdipPrivateAddMemoryFont(
Pointer fontCollection, // GpFontCollection* in/out
Pointer memory, // void*
int length // INT
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipPrivateAddMemoryFont = GdipPrivateAddMemoryFont(
fontCollection : GpFontCollection*, # GpFontCollection* in/out
memory : Void*, # void*
length : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipPrivateAddMemoryFontNative = Int32 Function(Pointer<Void>, Pointer<Void>, Int32);
typedef GdipPrivateAddMemoryFontDart = int Function(Pointer<Void>, Pointer<Void>, int);
final GdipPrivateAddMemoryFont = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipPrivateAddMemoryFontNative, GdipPrivateAddMemoryFontDart>('GdipPrivateAddMemoryFont');
// fontCollection : GpFontCollection* in/out -> Pointer<Void>
// memory : void* -> Pointer<Void>
// length : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipPrivateAddMemoryFont(
fontCollection: Pointer; // GpFontCollection* in/out
memory: Pointer; // void*
length: Integer // INT
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipPrivateAddMemoryFont';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipPrivateAddMemoryFont"
c_GdipPrivateAddMemoryFont :: Ptr () -> Ptr () -> Int32 -> IO Int32
-- fontCollection : GpFontCollection* in/out -> Ptr ()
-- memory : void* -> Ptr ()
-- length : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipprivateaddmemoryfont =
foreign "GdipPrivateAddMemoryFont"
((ptr void) @-> (ptr void) @-> int32_t @-> returning int32_t)
(* fontCollection : GpFontCollection* in/out -> (ptr void) *)
(* memory : void* -> (ptr void) *)
(* length : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipPrivateAddMemoryFont" gdip-private-add-memory-font :convention :stdcall) :int32
(font-collection :pointer) ; GpFontCollection* in/out
(memory :pointer) ; void*
(length :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipPrivateAddMemoryFont = Win32::API::More->new('gdiplus',
'int GdipPrivateAddMemoryFont(LPVOID fontCollection, LPVOID memory, int length)');
# my $ret = $GdipPrivateAddMemoryFont->Call($fontCollection, $memory, $length);
# fontCollection : GpFontCollection* in/out -> LPVOID
# memory : void* -> LPVOID
# length : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。