没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|其它|编辑:郝浩|2005-08-31 11:38:00.000|阅读 1790 次
概述:
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
除了PDFlib自带字体外,用户还可以使用安装在系统上的字体及其他用户字体。
PDFlib称安装在Windows和Mac操作系统中的(存在于或被拷入相应系统字体目录的)TrueType,
OpenType 和PostScript字体为宿主字体(Host Font)。PDFlib可直接引用字体名进行调用,但必须与文件名完全相同(严格区分大小写)。例如,调用安装在Windows系统中的字体:C:\WINDOWS\Fonts\SimHei.ttf
int Font_CS = 0;
Font_CS= PDF_load_font(p, "SimHei", 0, "unicode", "");
除此之外,PDFlib还可以调用其他用户字体。但在调用之时,需要给出路径名。如我想用C:\Program
Files\Adobe\Acrobat 7.0\Resource\CIDFont\AdobeSongStd-Light.otf 这个字体:
Font_CS= PDF_load_font(p, "C:\\Program Files\\Adobe\\Acrobat 7.0\\Resource\\CIDFont\\
AdobeSongStd-Light", 0, "unicode", "");
但这里有个例外,那就是.ttc(TrueType
Collection)字体。.ttc是集合字体文件,每个文件中含有多种字体。所以用户不能用文件名调用字体,而是要用真正的字体名。比方说,我们知道C:\WINDOWS\Fonts\MSGOTHIC.TTC
包含三种字体依次名为MS Gothic,MS PGothic,和MS UI Gothic。我们可以用以它们相应的字体名调用:
int Font_E = 0;
Font_E= PDF_load_font(p, "MS Gothic", 0, "winansi", ""); /*
Use MS Gothic */
PDF_setfont(p,
Font_E, 20);
PDF_show_xy(p,
"MS Gothic font:" , 50, 800);
Font_E= PDF_load_font(p, "MS PGothic", 0, "winansi", ""); /*
Use MS PGothic */
…….
Font_E= PDF_load_font(p, "MS UI Gothic", 0, "winansi", "");
/* Use MS UI Gothic */
……
可是我们经常并不清楚.ttc里包含哪些字体。在这种情况PDFlib提供了另一种调用方式—索引(Index)。用此方式,首先须给字体文件名一个别名,然后在别名后加冒号再加数字(0表示文件中第一种字体,1
表示第二种,依次类推。)
int Font_E = 0;
/* Give “C:\WINDOWS\Fonts\MSGOTHIC.TTC
an alias “gothic” */
PDF_set_parameter(p, "FontOutline",
"gothic=C:\\WINDOWS\\Fonts\\MSGOTHIC.TTC");
Font_E= PDF_load_font(p, "gothic:0", 0, "winansi", ""); /*
Use MS Gothic */
Font_E= PDF_load_font(p, "gothic:1", 0, "winansi", ""); /*
Use MS PGothic */
Font_E= PDF_load_font(p, "gothic:2", 0, "winansi", ""); /*
Use MS UI Gothic */
下面是一个相关的例子--C 源程序(附上生成的pdf文件 –PDFlib_cs2.pdf)。
/*******************************************************************/
/* This example demostrates the usage of host font and other fonts
/* based on Chinese Simplifed Windows.
/*******************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pdflib.h"
int main(void)
{
PDF *p = NULL;
int i = 0, j = 0, Left = 50, Top = 800;
int Font_E = 0, Font_CS = 0;
char fontfile[1024];
char buf[1024];
char TextUnicode[] = "\x80\x7B\x53\x4F\x2D\x4E\x87\x65";
/* create a new PDFlib object */
if ((p = PDF_new()) == (PDF *) 0)
{
printf("Couldn't create PDFlib object (out of
memory)!\n");
return(2);
}
PDF_TRY(p) {
if (PDF_begin_document(p, "pdflib_cs2.pdf", 0, "") == -1)
{
printf("Error: %s\n", PDF_get_errmsg(p));
return(2);
}
PDF_set_info(p, "Creator", "pdflib_cs2.c");
PDF_set_info(p,
"Author", "bowriver2001@yahoo.ca");
PDF_set_info(p, "Title", "Output Chinese Simplify with host font
and others");
/* Start a new page. */
PDF_begin_page_ext(p, a4_width, a4_height, "");
Font_E = PDF_load_font(p, "Helvetica-Bold", 0, "winansi", "");
/* Using host font -- C:\WINDOWS\Fonts\SimHei.ttf. */
Font_CS= PDF_load_font(p, "SimHei", 0, "unicode", "");
PDF_setfont(p, Font_E, 20);
PDF_show_xy(p, "SimHei font:" , Left,
Top);
PDF_setfont(p, Font_CS, 24);
Top-=30;
PDF_show_xy(p, TextUnicode , Left,
Top);
/* Using other disk-based font file --
C:\Program Files\Adobe\Acrobat 7.0\Resource\CIDFont\AdobeSongStd-Light.otf*/
Top-=50;
Font_CS= PDF_load_font(p,
"C:\\Program Files\\Adobe\\Acrobat 7.0\\Resource\\CIDFont\\AdobeSongStd-Light",
0, "unicode", "");
PDF_setfont(p, Font_E, 20);
PDF_show_xy(p, "AdobeSongStd-Light font:" , Left, Top);
PDF_setfont(p, Font_CS, 24);
Top-=30;
PDF_show_xy(p, TextUnicode , Left, Top);
/* Using TrueType collection font with index --
C:\WINDOWS\Fonts\simsun.ttc*/
Top-=50;
strcpy(fontfile, "C:\\WINDOWS\\Fonts\\simsun.ttc");
sprintf(buf, "simsun=%s", fontfile);
/* Defines AdobeSongStd as alias for ..\AdobeSongStd-Light.otf
This only need to claim once will be sufficient to configure all
fonts in simsun.ttc*/
PDF_set_parameter(p, "FontOutline", buf);
/* TTC files contain multiple separate fonts.
Address 1st font by appending a colon
character and 0 after alias simsun */
Font_CS=
PDF_load_font(p, "simsun:0", 0, "unicode", "");
PDF_setfont(p, Font_E, 20);
PDF_show_xy(p, "simsun:0 font:", Left, Top);
PDF_setfont(p, Font_CS, 24);
Top-=30;
PDF_show_xy2(p, TextUnicode, 8, Left, Top);
/*Address 2nd font by appending a colon character and 1 after alias
simsun */
Top-=50;
Font_CS= PDF_load_font(p, "simsun:1", 0, "unicode", "");
PDF_setfont(p, Font_E, 20);
PDF_show_xy(p, "simsun:1 font:", Left, Top);
PDF_setfont(p, Font_CS, 24);
Top-=30;
PDF_show_xy2(p, TextUnicode, 8, Left, Top);
/* End of page. */
PDF_end_page_ext(p, "");
PDF_end_document(p, "");
}
PDF_CATCH(p) {
printf("PDFlib exception occurred in pdflib_cs2
sample:\n");
printf("[%d] %s: %s\n",
PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p));
PDF_delete(p);
return(2);
}
PDF_delete(p);
return 0;
}
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
面对“数字中国”建设和中国制造2025战略实施的机遇期,中车信息公司紧跟时代的步伐,以“集约化、专业化、标准化、精益化、一体化、平台化”为工作目标,大力推进信息服务、工业软件等核心产品及业务的发展。在慧都3D解决方案的实施下,清软英泰建成了多模型来源的综合轻量化显示平台、实现文件不失真的百倍压缩比、针对模型中的大模型文件,在展示平台上进行流畅展示,提升工作效率,优化了使用体验。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号