字体

一、字体编号

要向pdf写入一个字符时,会调用output_one_char。如果这字符使用的字体对象(编号)是新的,即没有写入过pdf,那把该字体对象写入pdf。

memory_word *volatile varmem = NULL;

参数p指向字符节点的指针,类型int,是字符节点在varmem这个数组的索引。

scaled_whd output_one_char(PDF pdf, halfword p)
{
    internal_font_number f = font(p);
    int c = character(p);
    // f是字体编号,要写入是字体对象中的一个字段。
    // c是字符编码,像数字1,c的值便是1的ascii码:49
    int ex_glyph = ex_glyph(p)/1000;
    /*tex The real width, height and depth of the character: */
    scaled_whd ci = get_charinfo_whd(f, c);
    ......
}

int pdf_create_obj(PDF pdf, int t, int i)

pdf_create_obj是把对象写入pdf的统一函数,当写入的是字体对象时,参数t是obj_type_font(0),i是字体编号,即output_on_char中的f。这里说下f 怎么来的。此实例运行到oupt_one_char的三个实时值。

  • p(字符节点在varmem数组的索引): 26789。
  • f(字体编号): 53
  • c(字体编码): 49
#  define rh v.RH
font宏
#  define font(a)               vlink((a)+2)
#  define vlink(a)      varmem[(a)].hh.v.RH

font(26789),等于读取varmen[26791].hh.v.RH。

 

1.1 new_font的返回值15赋值给eqtb[535038].hh.v.RH

  • u: 535038, cnom: [lmroman10-regular]:+tlig;
  • s: 655360
  • natural_dir: -1
int read_font_info(pointer u, char *cnom, scaled s, int natural_dir)
{
    f = new_font();
    if ((f = do_define_font(f, cnom, s, natural_dir))) {
        // 进这入口
        return f;
    } else {
       ...
    } 
}

new_font行为是从字体表font_tables得到一个空位,返回是f是在个空位在font_tables的索引。由于0到14都被占用了,f是15。

new_font后,在15位置只是申请了,没有给填充值。do_define_font要填充这些字段,以下是几个填令后的字段值。

_font_name: [lmroman10-regular]:+tlig;
_font_filename: c:/users/ancientcc/我的文档/roseapp/launcher/miktex/sandbox/fonts/opentype/public/lm/lmroman10-regular.otf
_font_fullname: LMRoman10-Regular

tex_def_font调用完read_font_info后,执行“equiv(u) = f”,至此eqtb[535038].hh.v.RH值是15。

 

1.2 eqtb[535038].hh.v.RH赋值给cur_chr

static boolean get_next_tokenlist(void)
{
  ...
  cur_chr = equiv(cur_cs);
  ...
}

cur_cs值是535038。

 

1.3 eq_define以cur_chr为参数,把eqtb[333278].hh.v.RH设置为15

  • p: 333278
  • t: 156
  • e: 15
void eq_define(halfword p, quarterword t, halfword e) 
{
    ...
    set_equiv(p, e)
    ...
}

eq_define会调用set_equiv,把eqtb[333278].hh.v.RH设置为15。参数e来自全局变量cur_chr。

 

1.4 经过多次eq_define和其它变换,eqtb[333278].hh.v.RH值变成53

从15变成53,除eq_define,还会是其它函数内。

15->.....->37->19->38->19->33->35->53

 

1.5 new_char把varmen[26791].hh.v.RH置为53

halfword new_char(int f, int c)
{
    halfword p;
    p = new_glyph_node();
    set_to_character(p);
    font(p) = f;
    character(p) = c;
    // 此处p是26789,于是varmen[26791].hh.v.RH置为53,字符编码则是49。
    ......
}

c是新来的字符字符1的ascii编码49,可看到26791来自new_glyph_node。

此至varmem[26791]的f是53,c是49,然后进入一开提到的output_one_char。

总的来说,字体编号起源于font_tables当时空位索引15,但最后写入pdf的字体编号是经过一系列变化的,目前还不清楚中间过程。

全部评论: 0

    写评论: