• PostScript语言教程(五、文本打印)


    5.1、POSTSCRIPT字体

    字体是具有统一规格的字符集。其中包含数百个字符集,包含熟悉的TIMES和HELVETICA

    使用POSTSCRIPT字体
    在你打印文本之前,你需要指定所需的字体,这个过程需要三个步骤
    1、查找字体的信息。保存在当前环境中,他用来提供特定字体的形状,信息。
    2、将字体缩放。
    3、将缩放的额字体设置为当前字体,然后打印出来

    %!PS-Adobe-3.0
    
    /Times-Roman findfont 15 scalefont setfont
    
    72 200 moveto (typography) show
    
    showpage

    /Times-Roman findfont
    查找名称为Times-Roman的字体,并把它保存到当前程序中

    15 scalefont
    设置字体大小为15号的Times-Roman字体

    setfont
    根据已经保存好的规格,对字体进行设置

    5.2、动态设置字体大小

    %!PS-Adobe-3.0
    
    /scaleTimes % stack:scale
    {
    /Times-Roman findfont
    each scalefont setfont
    }def
    
    6 scaleTimes
    72 200 moveto (typography) show
    showpage

    /Times-Roman findfont 入栈
    each scalefont setfont 入栈

    6 scaleTimes意义为
    6 /Times-Roman findfont each scalefont setfont
    each 将 6 和 /Times-Roman 交换位置得
    /Times-Roman findfont 6 scalefont setfont

    默认支持的字体字体:
    Times-Roman
    Times-Bold
    Times-Italic
    Times-Boldltalic
    Helvetica
    Helvetica-Bold
    Helvetica-Oblique
    Helvetica-Boldltalic
    Courier
    Courier-Bold
    Courier-Oblique
    Courier-BoldOblique

    %!PS-Adobe-3.0
    
    /MainFont
        /STSong-Light--GB-EUC-H findfont 15 scalefont def 
    /SloganFont
        /Helvetica-Oblique findfont 7 scalefont def 
    /OwnerFont
        /Helvetica  findfont 10 scalefont def 
    
    /rightshow 
    {
        dup stringwidth pop 
        150 exch sub 
        0 rmoveto
        show
    }def
    
    /CardOutline
    {
        newpath
        90 90 moveto
        0 144 rlineto
        252 0 rlineto
        0 -144 rlineto
        closepath
        .5 setlinewidth
        stroke
    }def
    
    /doBorder
    {
        99 99 moveto
        0 126 rlineto
        234 0 rlineto
        0 -126 rlineto
        closepath
        2 setlinewidth
        stroke
    }def
    
    /Diamond
    {
        newpath
        207 216 moveto
        36 -54 rlineto
        -36 -54 rlineto
        -36 54 rlineto
        closepath
        .8 setgray
        fill
    }def
    
    /doText
    {
        0 setgray
        90 180 moveto
        MainFont setfont
        (AAA丶死刘) rightshow
    
        90 168 moveto
        SloganFont setfont
        ("The Club of Lonely Hearts") rightshow
    
    
        216 126 moveto
        OwnerFont setfont
        (Sam Spade) show
    
        216 111 moveto
        (Owner) show
    }def
    
    
    CardOutline
    doBorder
    Diamond
    doText
    
    showpage

    /STSong-Light--GB-EUC-H 为中文打印(注:中文打印时候要求文件格式为gb2312,否则字库不识别,打印出来是乱码)

    stringwidth 获取当前字符串的宽度,寄存起为字符串宽度 ,字符串内容,宽度在顶端
      dup stringwidth pop
      150 exch sub
      0 rmoveto
      show
    意义为:
      获取字符串宽度,并将(150 - 字符串宽度的值,0)进行偏移,即:打印字符串在150处右端对其

  • 相关阅读:
    一篇关于兼容问题的基础总结
    js数组遍历some,foreach,map,filter,every对比
    webpack笔记1
    前段集成解决方案grunt+yeoman初步认识
    简单的Linq笔记
    .net 使用Json(),maxJsonLength属性设置的值问题
    .net using使用小结
    根据某个字段的长度,且不包含”,“,作为条件查询
    JS Replace() 全部替换字符的用法
    SQL分页查询,纯Top方式和row_number()解析函数的使用及区别
  • 原文地址:https://www.cnblogs.com/Ansing/p/7444300.html
Copyright © 2020-2023  润新知