让GraphicsMagick支持Windows TrueType字体

让GM支持Windows TrueType字体(GM版本版本是1.3.17)

Linux系统自带Ghostscript字体,都是英文字体。
在Linux上安装GM时,如果不指定Ghostscript字体的目录 ,GM会默认使用Linux系统的字体 ,目录是/usr/share/fonts/default/Type1/  。
若GM安装在默认路径,可以/usr/local/lib/GraphicsMagick-1.3.17/config目录看字体配置文件。

如果想让GM支持中文字体。
在Linux上安装GM时使用 --with-windows-font-dir=字体目录   参数,指明Windows字体文件的目录。
若GM安装在默认路径,GM会/usr/local/lib/GraphicsMagick-1.3.17/config目录放一份type-windows.mgk字体配置文件。配置文件内容很多都是字体的路径和字体名。
然后人工复制全部Windows字体文件到这个目录,并保持原名。
这样就和ype-windows.mgk对应起来了。

GM 默认安装完,GM文件都在哪些目录里
----------------------------------
Linux服务器:
1、gm命令在 /usr/local/bin
2、模块配置文件  /usr/local/share/GraphicsMagick-1.3.17/config 
3、字体配置文件  /usr/local/lib/GraphicsMagick-1.3.17/config   
4、头文件 /usr/local/include/GraphicsMagick/magick
5、文档文件 /usr/local/share/doc/GraphicsMagick

Windows服务器:
C:\Program Files\GraphicsMagick-1.3.17-Q8


精准安装Windows TrueType中文字体
支持中文字体种类
----------------------------------
计划支持不少于以下种类Windows TrueType字体:(如果字体种类不够,可以通过配置文件添加)
simkai.ttf                  楷书
SURSONG.TTF             宋体(宋体-方正超大字符集)
simhei.ttf                 黑体
msyh.ttf                 微软雅黑
SIMLI.TTF             隶书
方正硬笔行书简体.ttf     行书(方正硬笔行书简体)
SIMYOU.TTF             幼圆
以上字体文件可到C:\Windows\Fonts目录copy来。方正硬笔行书简体可以网上搜索下载。

字体文件存放在目录
----------------------------------
把字体文件copy到约定目录:
windows系统: E:\imguppic\ms_font\
linux系统:/usr/share/fonts/ms_font

如果Windows服务器,修改字体配置文件
----------------------------------
默认安装GraphicsMagick后,字体配置文件目录在: C:\Program Files\GraphicsMagick-1.3.17-Q8\  目录,
新建一个type-windows.mgk文件,使用GB2312编码。

修改它的内容:
<?xml version="1.0"?>
<typemap>
    <type name="楷书" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="E:\imguppic\ms_font\simkai.ttf"/>
    <type name="宋体" fullname="宋体-方正超大字符集" family="Arial" weight="400" style="normal" stretch="normal" glyphs="E:\imguppic\ms_font\SURSONG.TTF"/>
     <type name="黑体" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="E:\imguppic\ms_font\simhei.ttf"/>
    <type name="微软雅黑" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="E:\imguppic\ms_font\msyh.ttf"/>
    <type name="隶书" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="E:\imguppic\ms_font\SIMLI.TTF"/>
    <type name="行书" fullname="方正硬笔行书简体" family="Arial" weight="400" style="normal" stretch="normal" glyphs="E:\imguppic\ms_font\方正硬笔行书简体.ttf"/>
    <type name="幼圆" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="E:\imguppic\ms_font\SIMYOU.TTF"/>
</typemap>

修改type.mgk内容为:(使用GB2312编码)
<?xml version="1.0"?>
<typemap>
  <include file="type-ghostscript.mgk" />
  <include file="type-windows.mgk" />
</typemap>


如果Linux服务器,修改字体配置文件
-------------------------------------
默认安装GraphicsMagick后,字体配置文件目录在:/usr/local/lib/GraphicsMagick-1.3.17/config。
linux系统字体配置文件是 /usr/local/lib/GraphicsMagick-1.3.17/config/type-windows.mgk,它指明了字体文件的路径。这个文件是安装GM时生成的,是GB2312编码,所以还保存为原编码。

修改它的内容为:
<?xml version="1.0"?>
<typemap>
    <type name="楷书" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="/usr/share/fonts/ms_font/simkai.ttf"/>
    <type name="宋体" fullname="宋体-方正超大字符集" family="Arial" weight="400" style="normal" stretch="normal" glyphs="/usr/share/fonts/ms_font/SURSONG.TTF"/>
     <type name="黑体" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="/usr/share/fonts/ms_font/simhei.ttf"/>
    <type name="微软雅黑" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="/usr/share/fonts/ms_font/msyh.ttf"/>
    <type name="隶书" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="/usr/share/fonts/ms_font/SIMLI.TTF"/>
    <type name="行书" fullname="方正硬笔行书简体" family="Arial" weight="400" style="normal" stretch="normal" glyphs="/usr/share/fonts/ms_font/方正硬笔行书简体.ttf"/>
    <type name="幼圆" fullname="Arial" family="Arial" weight="400" style="normal" stretch="normal" glyphs="/usr/share/fonts/ms_font/SIMYOU.TTF"/>
</typemap>

注,还可以检查type.mgk文件,其中应该有<include file="type-windows.mgk" />

猜你喜欢

转载自elf8848.iteye.com/blog/1782783