⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttflib.c

📁 字体缩放显示
💻 C
📖 第 1 页 / 共 2 页
字号:
                                     language_index,                                     &feature_index);      if (error)        goto check_hani;      else        goto Done;    }    else      goto Done;  check_hani:    error = TT_GSUB_Select_Script(gsub,                                  SCRIPT_hani,                                  &script_index);    if (error)      goto check_hang;    error = TT_GSUB_Select_Feature(gsub,                                   FEATURE_vert,                                   script_index,                                   0xFFFF,                                   &feature_index);    if (error)    {      error = TT_GSUB_Select_Language(gsub,                                      LANGUAGE_CHN,                                      script_index,                                      &language_index,                                      &req_feature_index);      if (error)        goto check_hang;      error = TT_GSUB_Select_Feature(gsub,                                     FEATURE_vert,                                     script_index,                                     language_index,                                     &feature_index);      if (error)        goto check_hang;      else        goto Done;    }    else      goto Done;  check_hang:    error = TT_GSUB_Select_Script(gsub,                                  SCRIPT_hang,                                  &script_index);    if (error)      goto Done;    error = TT_GSUB_Select_Feature(gsub,                                   FEATURE_vert,                                   script_index,                                   0xFFFF,                                   &feature_index);    if (error)    {      error = TT_GSUB_Select_Language(gsub,                                      LANGUAGE_KOR,                                      script_index,                                      &language_index,                                      &req_feature_index);      if (error)        goto Done;      error = TT_GSUB_Select_Feature(gsub,                                     FEATURE_vert,                                     script_index,                                     language_index,                                     &feature_index);    }  Done:    if (error)    {      warning("There is no data for vertical typesetting in GSUB table.");      has_gsub = False;    }    if (req_feature_index != 0xFFFF)      TT_GSUB_Add_Feature(gsub, req_feature_index, ALL_GLYPHS);    TT_GSUB_Add_Feature(gsub, feature_index, ALL_GLYPHS);    in.length = 1;    in.pos = 0;    in.string = in_string;    in.properties = NULL;    out.pos = 0;    out.allocated = 0;    out.string = NULL;    out.properties = NULL;  }}static TT_ErrorLoadTrueTypeChar(Font *fnt,                 int idx,                 Boolean hint,                 Boolean quiet){  TT_Error error;  int flags;  flags = TTLOAD_SCALE_GLYPH;  if (hint)    flags |= TTLOAD_HINT_GLYPH;  error = TT_Load_Glyph(instance, glyph, idx, flags);  if (!error)    error = TT_Get_Glyph_Big_Metrics(glyph, &metrics);  if (!error)    error = TT_Get_Glyph_Outline(glyph, &outline);  if (!error)  {    if (fnt->efactor != 1.0 || fnt->slant != 0.0 )      TT_Transform_Outline(&outline, &matrix1);    if (fnt->rotate)      TT_Transform_Outline(&outline, &matrix2);  }  if (!error)    error = TT_Get_Outline_BBox(&outline, &bbox); /* we need the non-                                                     grid-fitted bbox */  if (fnt->rotate)    TT_Translate_Outline(&outline,                         metrics.vertBearingY - bbox.xMin,                         -fnt->y_offset * ppem * 64);  if (!error)    error = TT_Get_Outline_BBox(&outline, &bbox);  if (!error)    SetRasterArea(quiet);  return error;}BooleanTTFprocess(Font *fnt,           long Code,           byte **bitmap,           int *width, int *height,           int *hoff, int *voff,           Boolean hinting,           Boolean quiet){  int Num;  TT_Error error;  if (!bitmap || !width || !height || !hoff || !voff)    oops("Invalid parameter in call to TTFprocess()");  if (Code >= 0x1000000)    Num = Code & 0xFFFFFF;  else  {    Num = TT_Char_Index(char_map, Code);    if (has_gsub)    {      in_string[0] = Num;      error = TT_GSUB_Apply_String(gsub, &in, &out);      if (error && error != TTO_Err_Not_Covered)        warning("Cannot get the vertical glyph form for glyph index %d.",                Num);      else        Num = out.string[0];    }  }  if ((error = LoadTrueTypeChar(fnt, Num, hinting, quiet)) == TT_Err_Ok)  {    memset(Bit.bitmap, 0, Bit.size);    TT_Get_Glyph_Bitmap(glyph, &Bit, x_offset * 64, y_offset * 64);    FlipBit();          *bitmap = Bit2.bitmap;    *width = Bit2.width;    *height = Bit2.rows;    *hoff = x_offset;    *voff = y_offset;    /* *voff = Bit2.rows - y_offset;    */    /* printf("%D %d\n", *hoff, *voff); */    /* Output(Bit2);                    */    return True;  }  else    return False;}/* *   We collect first all glyphs addressed via the cmap.  Then we fill the *   array up with glyphs not in the cmap. * *   If PSnames is set to `Only', we get the first 256 glyphs which have *   names different from `.notdef', `.null', and `nonmarkingreturn'. * *   For nicer output, we return the glyph names in an encoding array. */encoding *TTFget_first_glyphs(Font *fnt, long *array){  unsigned int i, j, Num;  unsigned int index_array[257];     /* we ignore glyph index 0 */  char *n;  encoding *e = (encoding *)mymalloc(sizeof (encoding));  if (!array)    oops("Invalid parameter in call to TTFget_first_glyphs()");  for (i = 0; i < 257; i++)    index_array[i] = 0;  j = 0;  if (fnt->PSnames != Only)  {    for (i = 0; i <= 0x16FFFF; i++)    {      Num = TT_Char_Index(char_map, i);      if (Num < 0)        oops("cmap mapping failure.");      if (Num == 0)        continue;      if (Num <= 256)        index_array[Num] = 1;      if (fnt->PSnames)        (void)TT_Get_PS_Name(face, Num, &n);      else        n = code_to_adobename(i);      if (strcmp(n, ".notdef") == 0)        continue;      if (strcmp(n, ".null") == 0)        continue;      if (strcmp(n, "nonmarkingreturn") == 0)        continue;      if (j < 256)      {        array[j] = i;        e->vec[j] = n;      }      else        return e;      j++;    }    if (!fnt->PSnames)    {      for (i = 1; i < properties.num_Glyphs; i++)      {        if (index_array[i] == 0)        {          if (j < 256)          {            array[j] = i | 0x1000000;            e->vec[j] = code_to_adobename(i | 0x1000000);          }          else            return e;          j++;        }      }    }  }  else  {    for (i = 0; i < properties.num_Glyphs; i++)    {      char *n;      (void)TT_Get_PS_Name(face, i, &n);      if (strcmp(n, ".notdef") == 0)        continue;      if (strcmp(n, ".null") == 0)        continue;      if (strcmp(n, "nonmarkingreturn") == 0)        continue;      if (j < 256)      {        array[j] = i | 0x1000000;        e->vec[j] = n;      }      else        return e;      j++;    }  }  return NULL;              /* never reached */}/* *   This routine fills `array' with the subfont character codes; *   additionally, it tests for valid glyph indices. */voidTTFget_subfont(Font *fnt, long *array){  int i, j, Num;  if (!fnt || !array)    oops("Invalid parameter in call to TTFget_subfont()");  for (i = 0; i <= 0xFF; i++)  {    j = fnt->sf_code[i];    if (j < 0)      array[i] = j;    else    {      Num = TT_Char_Index(char_map, j);      if (Num < 0)        oops("cmap mapping failure.");      else        array[i] = j;    }  }}longTTFsearch_PS_name(char *name){  unsigned int i;  char *n;  for (i = 0; i < properties.num_Glyphs; i++)  {    TT_Get_PS_Name(face, i, &n);    if (strcmp(name, n) == 0)      break;  }  if (i == properties.num_Glyphs)    return -1L;  else    return (long)i;}/* end */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -