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

📄 font.c

📁 关于rcp2c_v3.rar协议在LINUX下的实现程序
💻 C
📖 第 1 页 / 共 2 页
字号:
  CbEmitStruct(header, "wwwwwwwwwwwww", NULL, fTrue);

  for (x = 0; x < (size_t) header[h_fRectHeight]; x++)
  {
    DumpBytes(bitmap[x], header[h_rowWords] * 2);
    free(bitmap[x]);
  }

  for (x = header[h_firstChar]; x <= (size_t) header[h_lastChar] + 1; x++)
    EmitW(coltable[x]);
  EmitW((unsigned short)col);
  //      EmitW(0);                       /* RMa Remove this bug value */

  DumpBytes(&fntOW[fntNo][header[h_firstChar]],
            (header[h_lastChar] - header[h_firstChar] + 2) * 2);
  EmitW(0xFFFF);                                 /* RMa bug correction last value in file must be 0xFFFF not 0 */

}

static void
SetBuiltinFont(int fntNo,
               unsigned char *rgbWidths,
               int ichStart,
               int cch)
{
  int ich;

  Assert(ichStart + cch <= 256);
  if (fntOW[fntNo] == NULL)
  {
    if (!(fntOW[fntNo] = malloc(256 * sizeof(FontCharInfoType))))
      Error("Out of memory");
    memset(fntOW[fntNo], -1, 256 * sizeof(FontCharInfoType));
  }
  for (ich = ichStart; ich < ichStart + cch; ich++)
  {
    fntOW[fntNo][ich].width = rgbWidths[ich - ichStart];
  }
}

/*
 * Call to set up memory with standard font data 
 */

void
InitFontMem(int fontType)
{

  static unsigned char font0[] = {
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 2, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 11, 5, 8, 8,
    6, 5, 5, 5, 5, 5, 5, 5,
    2, 2, 4, 8, 6, 8, 7, 2,
    4, 4, 6, 6, 3, 4, 2, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 2, 3, 6, 6, 6, 5,
    8, 5, 5, 5, 6, 4, 4, 6,
    6, 2, 4, 6, 5, 8, 6, 7,
    5, 7, 5, 5, 6, 6, 6, 8,
    6, 6, 6, 3, 5, 3, 6, 4,
    3, 5, 5, 4, 5, 5, 4, 5,
    5, 2, 3, 5, 2, 8, 5, 5,
    5, 5, 4, 4, 4, 5, 5, 6,
    6, 6, 4, 4, 2, 4, 7, 5,
    5, 5, 3, 8, 5, 6, 6, 6,
    4, 11, 5, 4, 8, 10, 10, 10,
    10, 3, 3, 5, 5, 4, 4, 7,
    7, 10, 4, 4, 8, 5, 5, 6,
    2, 2, 6, 6, 8, 6, 2, 5,
    4, 8, 5, 6, 6, 4, 8, 6,
    5, 6, 4, 4, 3, 5, 6, 2,
    4, 2, 5, 6, 8, 8, 8, 5,
    5, 5, 5, 5, 5, 5, 7, 5,
    4, 4, 4, 4, 3, 2, 3, 3,
    7, 6, 7, 7, 7, 7, 7, 5,
    8, 6, 6, 6, 6, 6, 6, 6,
    5, 5, 5, 5, 5, 5, 8, 4,
    5, 5, 5, 5, 2, 2, 3, 3,
    5, 5, 5, 5, 5, 5, 5, 6,
    7, 5, 5, 5, 5, 6, 5, 6
  };

  static unsigned char font1[] = {
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 2, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 11, 5, 10, 8,
    6, 6, 5, 5, 5, 5, 5, 5,
    2, 3, 6, 10, 6, 13, 9, 3,
    5, 5, 6, 6, 3, 5, 3, 6,
    6, 6, 6, 6, 6, 6, 6, 6,
    6, 6, 3, 3, 6, 6, 6, 6,
    10, 7, 7, 6, 7, 5, 5, 8,
    8, 3, 5, 7, 6, 10, 7, 8,
    7, 8, 8, 6, 7, 7, 8, 11,
    7, 7, 7, 4, 6, 4, 6, 5,
    4, 6, 6, 5, 6, 6, 5, 6,
    6, 3, 4, 6, 3, 9, 6, 6,
    6, 6, 5, 5, 6, 6, 6, 9,
    6, 6, 5, 5, 3, 5, 7, 5,
    6, 5, 3, 9, 5, 6, 5, 5,
    4, 17, 6, 5, 10, 10, 10, 10,
    10, 3, 3, 5, 5, 4, 4, 6,
    7, 10, 5, 5, 10, 5, 5, 7,
    2, 3, 6, 7, 8, 7, 3, 6,
    4, 8, 6, 8, 6, 5, 8, 6,
    5, 6, 4, 4, 4, 6, 7, 2,
    4, 2, 6, 8, 9, 9, 9, 6,
    7, 7, 7, 7, 7, 7, 9, 6,
    5, 5, 5, 5, 3, 3, 3, 3,
    8, 7, 8, 8, 8, 8, 8, 6,
    8, 7, 7, 7, 7, 7, 7, 8,
    6, 6, 6, 6, 6, 6, 9, 5,
    6, 6, 6, 6, 3, 3, 3, 3,
    6, 6, 6, 6, 6, 6, 6, 7,
    8, 6, 6, 6, 6, 6, 6, 6
  };

  static unsigned char font2[] = {

    5, 5, 5, 5, 5, 5, 5, 5,
    5, 4, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 11, 5, 10, 8,
    10, 7, 5, 5, 5, 5, 5, 5,
    4, 2, 4, 9, 6, 11, 8, 2,
    4, 4, 6, 8, 3, 4, 2, 5,
    7, 7, 7, 7, 7, 7, 7, 7,
    7, 7, 2, 3, 7, 7, 7, 5,
    11, 9, 6, 7, 7, 6, 6, 8,
    7, 3, 4, 7, 5, 10, 7, 8,
    6, 8, 6, 5, 6, 7, 7, 11,
    7, 6, 5, 3, 5, 3, 6, 6,
    3, 6, 7, 6, 7, 7, 4, 7,
    6, 3, 3, 6, 2, 10, 7, 7,
    7, 7, 4, 5, 4, 7, 6, 10,
    6, 7, 6, 4, 2, 4, 7, 5,
    7, 5, 3, 7, 5, 10, 6, 6,
    4, 13, 5, 4, 9, 10, 10, 10,
    10, 3, 3, 5, 5, 5, 6, 12,
    7, 11, 5, 4, 12, 5, 5, 8,
    4, 2, 6, 6, 8, 8, 2, 6,
    4, 10, 5, 7, 7, 4, 10, 4,
    5, 6, 5, 4, 3, 6, 6, 2,
    4, 3, 5, 7, 8, 8, 8, 5,
    9, 9, 9, 9, 9, 9, 9, 7,
    6, 6, 6, 6, 3, 2, 3, 3,
    8, 7, 8, 8, 8, 8, 8, 6,
    8, 7, 7, 7, 7, 6, 6, 6,
    6, 6, 6, 6, 6, 6, 11, 6,
    7, 7, 7, 7, 3, 2, 3, 3,
    6, 7, 7, 7, 7, 7, 7, 6,
    7, 7, 7, 7, 7, 7, 6, 7
  };

  static unsigned char font3[] = {

    5, 5, 5, 11, 10, 10, 10, 11,
    11, 7, 4, 6, 6, 8, 8, 8,
    8, 8, 8, 7, 7, 7, 6, 10,
    10, 10, 10, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5
  };

  static unsigned char font4[] = {

    12, 12, 8, 8, 12, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5
  };

  static unsigned char font5[] = {
    5, 11, 11, 11, 11, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 5, 5, 5, 5
  };

  static unsigned char font6[] = {
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 4, 6, 4, 7,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 9, 9
  };

  static unsigned char font7[] = {
    5, 5, 5, 5, 5, 5, 5, 5,
    5, 2, 5, 5, 5, 5, 5, 5,
    5, 5, 5, 5, 11, 5, 8, 8,
    9, 6, 5, 5, 5, 5, 5, 5,
    2, 3, 6, 8, 7, 11, 9, 3,
    4, 4, 8, 7, 3, 5, 3, 5,
    6, 6, 6, 6, 6, 6, 6, 6,
    6, 6, 3, 4, 7, 6, 7, 6,
    10, 9, 7, 7, 7, 6, 6, 7,
    7, 3, 7, 7, 6, 9, 8, 7,
    7, 8, 7, 7, 7, 7, 8, 10,
    8, 7, 6, 4, 5, 4, 8, 8,
    4, 6, 6, 6, 6, 6, 5, 6,
    6, 3, 4, 6, 3, 9, 6, 6,
    6, 6, 5, 6, 5, 6, 7, 9,
    6, 6, 5, 7, 3, 7, 8, 5,
    6, 5, 3, 7, 6, 9, 6, 6,
    6, 12, 7, 4, 9, 10, 10, 10,
    10, 3, 3, 6, 6, 8, 7, 9,
    7, 8, 6, 4, 9, 5, 5, 7,
    1, 3, 6, 7, 8, 7, 2, 5,
    6, 8, 4, 7, 7, 3, 8, 8,
    5, 7, 4, 4, 4, 7, 8, 3,
    4, 3, 4, 7, 8, 8, 8, 6,
    9, 9, 9, 9, 9, 9, 11, 7,
    6, 6, 6, 6, 4, 4, 5, 4,
    8, 8, 7, 7, 7, 7, 7, 6,
    7, 7, 7, 7, 7, 7, 7, 7,
    6, 6, 6, 6, 6, 6, 9, 6,
    6, 6, 6, 6, 4, 4, 5, 4,
    6, 6, 6, 6, 6, 6, 6, 7,
    6, 6, 6, 6, 6, 6, 6, 6
  };

  /*
   * starts at 0xe0 
   */
  static unsigned char font0Hebrew[] = {
    6, 6, 5, 6, 6, 3, 4, 6,
    6, 3, 6, 5, 6, 6, 6, 3,
    4, 6, 6, 6, 6, 6, 6, 6,
    6, 7, 7, 2, 2, 2, 2, 2
  };

  static unsigned char font1Hebrew[] = {
    7, 7, 6, 7, 7, 3, 5, 7,
    8, 3, 6, 6, 6, 7, 8, 3,
    5, 7, 8, 7, 7, 6, 6, 7,
    6, 9, 8, 2, 2, 2, 2, 2
  };

  static unsigned char font2Hebrew[] = {
    7, 7, 6, 7, 7, 4, 6, 7,
    7, 4, 7, 7, 7, 7, 7, 4,
    4, 7, 7, 7, 7, 7, 7, 7,
    7, 7, 7, 2, 2, 2, 2, 2
  };

  /*
   * BUG! font7Hebrew? 
   */

  memset(fntOW, 0, sizeof(fntOW));
  memset(fntH, 0, sizeof(fntH));

  vfontType = fontType;
  pfnChkCode = IsDBCSNone;

  SetBuiltinFont(0, font0, 0, sizeof(font0));
  SetBuiltinFont(1, font1, 0, sizeof(font1));
  SetBuiltinFont(2, font2, 0, sizeof(font2));
  SetBuiltinFont(3, font3, 0, sizeof(font3));
  SetBuiltinFont(4, font4, 0, sizeof(font4));
  SetBuiltinFont(5, font5, 0, sizeof(font5));
  SetBuiltinFont(6, font6, 0, sizeof(font6));
  SetBuiltinFont(7, font7, 0, sizeof(font7));

  fntH[0] = 11;
  fntH[1] = 11;
  fntH[2] = 14;
  fntH[3] = 10;
  fntH[4] = 11;
  fntH[5] = 8;
  fntH[6] = 19;
  fntH[7] = 15;

  switch (fontType)
  {
    case fontChineseBig5:
      pfnChkCode = IsBIG5;
      break;
    case fontChineseGB:
      Error("GB character widths not yet implemented!");
      break;
    case fontJapanese:
      pfnChkCode = IsJapanese;
      break;
    case fontKoreanHanme:
      pfnChkCode = IsKoreanHanme;
      break;
    case fontKoreanHantip:
      pfnChkCode = IsKoreanHantip;
      break;
    case fontHebrew:
      SetBuiltinFont(0, font0Hebrew, 0xe0, sizeof(font0Hebrew));
      SetBuiltinFont(1, font1Hebrew, 0xe0, sizeof(font1Hebrew));
      SetBuiltinFont(2, font2Hebrew, 0xe0, sizeof(font2Hebrew));
      break;
  }

}

/*
 * Call to free the memory 
 */

void
FreeFontMem()
{
  int i;

  for (i = 0; i < 256; i++)
    if (fntOW[i])
      free(fntOW[i]);

}

/*-----------------------------------------------------------------------------
|	DxCalcRgdx
|	
|		Get extent of pilot string, placing each char width in rgdx
-------------------------------------------------------------WESC------------*/
int
DxCalcRgdx(unsigned char *sz,
           int ifnt,
           int *rgdx)
{
  unsigned char *pch;
  int dx;

  if (sz == NULL)
    return 0;
  dx = 0;

  for (pch = sz; *pch != 0; pch++)
  {
    if (rgdx != NULL)
      rgdx[pch - sz] = DxChar(*pch, ifnt);
    dx += DxChar(*pch, ifnt);
  }
  return dx;
}

/*-----------------------------------------------------------------------------
|	DxCalcExtent
|	
|		Calc extent of string -- BUG! only works for font 0 (and bold)
-------------------------------------------------------------WESC------------*/
int
DxCalcExtent(unsigned char *sz,
             int ifnt)
{
  unsigned char *pch;
  int dx;

  if (sz == NULL)
    return 0;
  dx = 0;

  for (pch = sz; *pch != 0; pch++)
  {
    int dxChar;
    int cch;

    cch = (*pfnChkCode) (pch, &dxChar);
    if (cch > 0)
    {                                            /* Daniel Lin 99/04/07 */
      dx += dxChar;
      pch += cch - 1;                            /* double byte chars */
    }
    else
      dx += DxChar(*pch, ifnt);
  }
  return dx;
}

int
DxChar(int ch,
       int ifnt)
{
  int dx;

  if (ifnt < 0 || ifnt >= 255)
    ErrorLine("Invalid F	ontID");
  if (!fntOW[ifnt])
    ErrorLine("Font not defined");
  dx = fntOW[ifnt][ch].width;
  if (dx == -1)
    dx = 0;
  return dx;
}

int
DyFont(int ifnt)
{
  if (ifnt < 0 || ifnt >= 255)
    ErrorLine("Invalid FontID");
  return fntH[ifnt];
}

int
GetFontType()
{
  return vfontType;
}

⌨️ 快捷键说明

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