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

📄 fofitruetype.cc

📁 swf文件查看工具,能够看flash文件的格式
💻 CC
📖 第 1 页 / 共 5 页
字号:
  i = seekTable("CFF ");  if (!checkRegion(tables[i].offset, tables[i].len)) {    return NULL;  }  if (!(ff = FoFiType1C::make((char *)file + tables[i].offset,			      tables[i].len))) {    return NULL;  }  map = ff->getCIDToGIDMap(nCIDs);  delete ff;  return map;}int FoFiTrueType::getEmbeddingRights() {  int i, fsType;  GBool ok;  if ((i = seekTable("OS/2")) < 0) {    return 4;  }  ok = gTrue;  fsType = getU16BE(tables[i].offset + 8, &ok);  if (!ok) {    return 4;  }  if (fsType & 0x0008) {    return 2;  }  if (fsType & 0x0004) {    return 1;  }  if (fsType & 0x0002) {    return 0;  }  return 3;}void FoFiTrueType::convertToType42(char *psName, char **encoding,				   Gushort *codeToGID,				   FoFiOutputFunc outputFunc,				   void *outputStream) {  GString *buf;  GBool ok;  if (openTypeCFF) {    return;  }  // write the header  ok = gTrue;  buf = GString::format("%!PS-TrueTypeFont-{0:2g}\n",			(double)getS32BE(0, &ok) / 65536.0);  (*outputFunc)(outputStream, buf->getCString(), buf->getLength());  delete buf;  // begin the font dictionary  (*outputFunc)(outputStream, "10 dict begin\n", 14);  (*outputFunc)(outputStream, "/FontName /", 11);  (*outputFunc)(outputStream, psName, strlen(psName));  (*outputFunc)(outputStream, " def\n", 5);  (*outputFunc)(outputStream, "/FontType 42 def\n", 17);  (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30);  buf = GString::format("/FontBBox [{0:d} {1:d} {2:d} {3:d}] def\n",			bbox[0], bbox[1], bbox[2], bbox[3]);  (*outputFunc)(outputStream, buf->getCString(), buf->getLength());  delete buf;  (*outputFunc)(outputStream, "/PaintType 0 def\n", 17);  // write the guts of the dictionary  cvtEncoding(encoding, outputFunc, outputStream);  cvtCharStrings(encoding, codeToGID, outputFunc, outputStream);  cvtSfnts(outputFunc, outputStream, NULL, gFalse);  // end the dictionary and define the font  (*outputFunc)(outputStream, "FontName currentdict end definefont pop\n", 40);}void FoFiTrueType::convertToType1(char *psName, char **newEncoding,				  GBool ascii, FoFiOutputFunc outputFunc,				  void *outputStream) {  FoFiType1C *ff;  int i;  if (!openTypeCFF) {    return;  }  i = seekTable("CFF ");  if (!checkRegion(tables[i].offset, tables[i].len)) {    return;  }  if (!(ff = FoFiType1C::make((char *)file + tables[i].offset,			      tables[i].len))) {    return;  }  ff->convertToType1(psName, newEncoding, ascii, outputFunc, outputStream);  delete ff;}void FoFiTrueType::convertToCIDType2(char *psName,				     Gushort *cidMap, int nCIDs,				     GBool needVerticalMetrics,				     FoFiOutputFunc outputFunc,				     void *outputStream) {  GString *buf;  Gushort cid;  GBool ok;  int i, j, k;  if (openTypeCFF) {    return;  }  // write the header  ok = gTrue;  buf = GString::format("%!PS-TrueTypeFont-{0:2g}\n",			(double)getS32BE(0, &ok) / 65536.0);  (*outputFunc)(outputStream, buf->getCString(), buf->getLength());  delete buf;  // begin the font dictionary  (*outputFunc)(outputStream, "20 dict begin\n", 14);  (*outputFunc)(outputStream, "/CIDFontName /", 14);  (*outputFunc)(outputStream, psName, strlen(psName));  (*outputFunc)(outputStream, " def\n", 5);  (*outputFunc)(outputStream, "/CIDFontType 2 def\n", 19);  (*outputFunc)(outputStream, "/FontType 42 def\n", 17);  (*outputFunc)(outputStream, "/CIDSystemInfo 3 dict dup begin\n", 32);  (*outputFunc)(outputStream, "  /Registry (Adobe) def\n", 24);  (*outputFunc)(outputStream, "  /Ordering (Identity) def\n", 27);  (*outputFunc)(outputStream, "  /Supplement 0 def\n", 20);  (*outputFunc)(outputStream, "  end def\n", 10);  (*outputFunc)(outputStream, "/GDBytes 2 def\n", 15);  if (cidMap) {    buf = GString::format("/CIDCount {0:d} def\n", nCIDs);    (*outputFunc)(outputStream, buf->getCString(), buf->getLength());    delete buf;    if (nCIDs > 32767) {      (*outputFunc)(outputStream, "/CIDMap [", 9);      for (i = 0; i < nCIDs; i += 32768 - 16) {	(*outputFunc)(outputStream, "<\n", 2);	for (j = 0; j < 32768 - 16 && i+j < nCIDs; j += 16) {	  (*outputFunc)(outputStream, "  ", 2);	  for (k = 0; k < 16 && i+j+k < nCIDs; ++k) {	    cid = cidMap[i+j+k];	    buf = GString::format("{0:02x}{1:02x}",				  (cid >> 8) & 0xff, cid & 0xff);	    (*outputFunc)(outputStream, buf->getCString(), buf->getLength());	    delete buf;	  }	  (*outputFunc)(outputStream, "\n", 1);	}	(*outputFunc)(outputStream, "  >", 3);      }      (*outputFunc)(outputStream, "\n", 1);      (*outputFunc)(outputStream, "] def\n", 6);    } else {      (*outputFunc)(outputStream, "/CIDMap <\n", 10);      for (i = 0; i < nCIDs; i += 16) {	(*outputFunc)(outputStream, "  ", 2);	for (j = 0; j < 16 && i+j < nCIDs; ++j) {	  cid = cidMap[i+j];	  buf = GString::format("{0:02x}{1:02x}",				(cid >> 8) & 0xff, cid & 0xff);	  (*outputFunc)(outputStream, buf->getCString(), buf->getLength());	  delete buf;	}	(*outputFunc)(outputStream, "\n", 1);      }      (*outputFunc)(outputStream, "> def\n", 6);    }  } else {    // direct mapping - just fill the string(s) with s[i]=i    buf = GString::format("/CIDCount {0:d} def\n", nGlyphs);    (*outputFunc)(outputStream, buf->getCString(), buf->getLength());    delete buf;    if (nGlyphs > 32767) {      (*outputFunc)(outputStream, "/CIDMap [\n", 10);      for (i = 0; i < nGlyphs; i += 32767) {	j = nGlyphs - i < 32767 ? nGlyphs - i : 32767;	buf = GString::format("  {0:d} string 0 1 {1:d} {{\n", 2 * j, j - 1);	(*outputFunc)(outputStream, buf->getCString(), buf->getLength());	delete buf;	buf = GString::format("    2 copy dup 2 mul exch {0:d} add -8 bitshift put\n",			      i);	(*outputFunc)(outputStream, buf->getCString(), buf->getLength());	delete buf;	buf = GString::format("    1 index exch dup 2 mul 1 add exch {0:d} add"			      " 255 and put\n", i);	(*outputFunc)(outputStream, buf->getCString(), buf->getLength());	delete buf;	(*outputFunc)(outputStream, "  } for\n", 8);      }      (*outputFunc)(outputStream, "] def\n", 6);    } else {      buf = GString::format("/CIDMap {0:d} string\n", 2 * nGlyphs);      (*outputFunc)(outputStream, buf->getCString(), buf->getLength());      delete buf;      buf = GString::format("  0 1 {0:d} {{\n", nGlyphs - 1);      (*outputFunc)(outputStream, buf->getCString(), buf->getLength());      delete buf;      (*outputFunc)(outputStream,		    "    2 copy dup 2 mul exch -8 bitshift put\n", 42);      (*outputFunc)(outputStream,		    "    1 index exch dup 2 mul 1 add exch 255 and put\n", 50);      (*outputFunc)(outputStream, "  } for\n", 8);      (*outputFunc)(outputStream, "def\n", 4);    }  }  (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30);  buf = GString::format("/FontBBox [{0:d} {1:d} {2:d} {3:d}] def\n",			bbox[0], bbox[1], bbox[2], bbox[3]);  (*outputFunc)(outputStream, buf->getCString(), buf->getLength());  delete buf;  (*outputFunc)(outputStream, "/PaintType 0 def\n", 17);  (*outputFunc)(outputStream, "/Encoding [] readonly def\n", 26);  (*outputFunc)(outputStream, "/CharStrings 1 dict dup begin\n", 30);  (*outputFunc)(outputStream, "  /.notdef 0 def\n", 17);  (*outputFunc)(outputStream, "  end readonly def\n", 19);  // write the guts of the dictionary  cvtSfnts(outputFunc, outputStream, NULL, needVerticalMetrics);  // end the dictionary and define the font  (*outputFunc)(outputStream,		"CIDFontName currentdict end /CIDFont defineresource pop\n",		56);}void FoFiTrueType::convertToCIDType0(char *psName,				     FoFiOutputFunc outputFunc,				     void *outputStream) {  FoFiType1C *ff;  int i;  if (!openTypeCFF) {    return;  }  i = seekTable("CFF ");  if (!checkRegion(tables[i].offset, tables[i].len)) {    return;  }  if (!(ff = FoFiType1C::make((char *)file + tables[i].offset,			      tables[i].len))) {    return;  }  ff->convertToCIDType0(psName, outputFunc, outputStream);  delete ff;}void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, int nCIDs,				  GBool needVerticalMetrics,				  FoFiOutputFunc outputFunc,				  void *outputStream) {  GString *buf;  GString *sfntsName;  int n, i, j;  if (openTypeCFF) {    return;  }  // write the Type 42 sfnts array  sfntsName = (new GString(psName))->append("_sfnts");  cvtSfnts(outputFunc, outputStream, sfntsName, needVerticalMetrics);  delete sfntsName;  // write the descendant Type 42 fonts  n = cidMap ? nCIDs : nGlyphs;  for (i = 0; i < n; i += 256) {    (*outputFunc)(outputStream, "10 dict begin\n", 14);    (*outputFunc)(outputStream, "/FontName /", 11);    (*outputFunc)(outputStream, psName, strlen(psName));    buf = GString::format("_{0:02x} def\n", i >> 8);    (*outputFunc)(outputStream, buf->getCString(), buf->getLength());    delete buf;    (*outputFunc)(outputStream, "/FontType 42 def\n", 17);    (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30);    buf = GString::format("/FontBBox [{0:d} {1:d} {2:d} {3:d}] def\n",			  bbox[0], bbox[1], bbox[2], bbox[3]);    (*outputFunc)(outputStream, buf->getCString(), buf->getLength());    delete buf;    (*outputFunc)(outputStream, "/PaintType 0 def\n", 17);    (*outputFunc)(outputStream, "/sfnts ", 7);    (*outputFunc)(outputStream, psName, strlen(psName));    (*outputFunc)(outputStream, "_sfnts def\n", 11);    (*outputFunc)(outputStream, "/Encoding 256 array\n", 20);    for (j = 0; j < 256 && i+j < n; ++j) {      buf = GString::format("dup {0:d} /c{1:02x} put\n", j, j);      (*outputFunc)(outputStream, buf->getCString(), buf->getLength());      delete buf;    }    (*outputFunc)(outputStream, "readonly def\n", 13);    (*outputFunc)(outputStream, "/CharStrings 257 dict dup begin\n", 32);    (*outputFunc)(outputStream, "/.notdef 0 def\n", 15);    for (j = 0; j < 256 && i+j < n; ++j) {      buf = GString::format("/c{0:02x} {1:d} def\n",			    j, cidMap ? cidMap[i+j] : i+j);      (*outputFunc)(outputStream, buf->getCString(), buf->getLength());      delete buf;    }    (*outputFunc)(outputStream, "end readonly def\n", 17);    (*outputFunc)(outputStream,		  "FontName currentdict end definefont pop\n", 40);  }  // write the Type 0 parent font  (*outputFunc)(outputStream, "16 dict begin\n", 14);  (*outputFunc)(outputStream, "/FontName /", 11);  (*outputFunc)(outputStream, psName, strlen(psName));  (*outputFunc)(outputStream, " def\n", 5);  (*outputFunc)(outputStream, "/FontType 0 def\n", 16);  (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30);  (*outputFunc)(outputStream, "/FMapType 2 def\n", 16);  (*outputFunc)(outputStream, "/Encoding [\n", 12);  for (i = 0; i < n; i += 256) {    buf = GString::format("{0:d}\n", i >> 8);    (*outputFunc)(outputStream, buf->getCString(), buf->getLength());    delete buf;  }  (*outputFunc)(outputStream, "] def\n", 6);  (*outputFunc)(outputStream, "/FDepVector [\n", 14);  for (i = 0; i < n; i += 256) {    (*outputFunc)(outputStream, "/", 1);    (*outputFunc)(outputStream, psName, strlen(psName));    buf = GString::format("_{0:02x} findfont\n", i >> 8);    (*outputFunc)(outputStream, buf->getCString(), buf->getLength());    delete buf;  }  (*outputFunc)(outputStream, "] def\n", 6);  (*outputFunc)(outputStream, "FontName currentdict end definefont pop\n", 40);}void FoFiTrueType::convertToType0(char *psName,				  FoFiOutputFunc outputFunc,				  void *outputStream) {  FoFiType1C *ff;  int i;  if (!openTypeCFF) {    return;  }  i = seekTable("CFF ");  if (!checkRegion(tables[i].offset, tables[i].len)) {    return;  }  if (!(ff = FoFiType1C::make((char *)file + tables[i].offset,			      tables[i].len))) {    return;  }  ff->convertToType0(psName, outputFunc, outputStream);  delete ff;}void FoFiTrueType::writeTTF(FoFiOutputFunc outputFunc,			    void *outputStream, char *name,			    Gushort *codeToGID) {  // this substitute cmap table maps char codes 0000-ffff directly to  // glyphs 0000-ffff  static char cmapTab[36] = {    0, 0,			// table version number    0, 1,			// number of encoding tables    0, 1,			// platform ID    0, 0,			// encoding ID    0, 0, 0, 12,		// offset of subtable    0, 4,			// subtable format    0, 24,			// subtable length    0, 0,			// subtable version    0, 2,			// segment count * 2    0, 2,			// 2 * 2 ^ floor(log2(segCount))    0, 0,			// floor(log2(segCount))    0, 0,			// 2*segCount - 2*2^floor(log2(segCount))    (char)0xff, (char)0xff,	// endCount[0]    0, 0,			// reserved    0, 0,			// startCount[0]    0, 0,			// idDelta[0]    0, 0			// pad to a mulitple of four bytes  };  static char nameTab[8] = {    0, 0,			// format    0, 0,			// number of name records    0, 6,			// offset to start of string storage    0, 0			// pad to multiple of four bytes  };  static char postTab[32] = {    0, 1, 0, 0,			// format    0, 0, 0, 0,			// italic angle    0, 0,			// underline position    0, 0,			// underline thickness    0, 0, 0, 0,			// fixed pitch    0, 0, 0, 0,			// min Type 42 memory    0, 0, 0, 0,			// max Type 42 memory    0, 0, 0, 0,			// min Type 1 memory    0, 0, 0, 0			// max Type 1 memory  };  static char os2Tab[86] = {    0, 1,			// version    0, 1,			// xAvgCharWidth    0, 0,			// usWeightClass    0, 0,			// usWidthClass    0, 0,			// fsType    0, 0,			// ySubscriptXSize    0, 0,			// ySubscriptYSize    0, 0,			// ySubscriptXOffset    0, 0,			// ySubscriptYOffset    0, 0,			// ySuperscriptXSize    0, 0,			// ySuperscriptYSize

⌨️ 快捷键说明

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