Skip to content

生成字体字库图片 - BuildFontLibrary

函数简介

根据指定字符集与字体生成字库 PNG,并可选择导入数据库。

接口名称

BuildFontLibrary

DLL调用

c
int BuildFontLibrary(long ola, string charset, int charsetType, string outputDir,
                     string fontPath, string fontName, int fontSize,
                     int fixedCellWidth, int fixedCellHeight, int antialiasing,
                     long dbHandle, string dictName, int cover);

参数说明

参数名类型说明
ola长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
charset字符串字符集:UTF-8 文本、区间表达式或文件路径(由 charsetType 决定)。charsetType=1 时多个区间或字符用逗号分割,如 0-9,A-Z,确定
charsetType整数型0 文本;1 区间表达式(逗号分割,支持连字符区间如 0-9);2 文件路径。
outputDir字符串PNG 输出目录。可为空;仅入库时允许为空。若创建目录失败则仅跳过 PNG 导出,不影响入库。
fontPath字符串字体文件路径;为空时使用 fontName
fontName字符串系统字体名;在 fontPath 为空时生效。
fontSize整数型字号(像素)。
fixedCellWidth整数型固定格宽;0 表示按真实尺寸。
fixedCellHeight整数型固定格高;0 表示按真实尺寸。
antialiasing整数型抗锯齿:0 关闭,1 开启。
dbHandle长整数型数据库句柄;0 表示使用全局默认库 ConfigModel::DbPtr(需已通过 [OpenDatabase](/olaplug/数据库/打开数据库 - OpenDatabase.html) 打开)。
dictName字符串字库名称;非空则导入数据库(显式 dbHandle 或默认 DbPtr 至少其一有效)。
cover整数型是否覆盖已有数据:0 否,1 是。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0);
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0)
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.BuildFontLibrary(“charsetType”, 0, “value”, “C:\\test.txt”, “fontPath”, 0, 800, 600, 0, 0, “dbHandle”, 0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.BuildFontLibrary("charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0);

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
BuildFontLibrary(instance, "charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0);
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int BuildFontLibrary(long ola, string charset, int charsetType, string outputDir, string fontPath, string fontName, int fontSize, int fixedCellWidth, int fixedCellHeight, int antialiasing, long dbHandle, string dictName, int cover);

long instance = CreateCOLAPlugInterFace();
BuildFontLibrary(instance, "charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.BuildFontLibrary(instance, "charsetType", 0, "value", "C:\\test.txt", "fontPath", 0, 800, 600, 0, 0, "dbHandle", 0)

返回值

返回值说明
(返回值)- >= 0:成功导出的字形数量。 - < 0:失败。