喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 帮助

RSS 订阅当前论坛  

喜悦证交所已经关闭

上一主题 下一主题
     
标题: 知道黑体字的是谁做的吗?  
 
xltxlm (xltxlm)
金牌会员
Rank: 6Rank: 6
版主



UID 19902
精华 3
积分 1090
帖子 3571
金钱 1060 喜悦币
威望 30
人脉 0
阅读权限 70
注册 2003-4-26
状态 离线
知道黑体字的是谁做的吗?

想不到这样也可以~! 拽

<?
// array ttfName(string $font)
//
// where $font is a string pointing to the font file
//
// Purpose:
//
// Reads a font and stores all information related to the font name and
// copyright in an associative array
//
// Returns:
//
// $array["copy"] = copyright information
// $array["font family"] = font family information
// $array["font subfamily"] = font subfamily name
// $array["id"] = unique font identification
// $array["name"] = full font name
// $array["version"] = font version
// $array["postscript name"] = postscript name for the font
// $array["tm"] = trademark information
// $array["manufacturer"] = font manufacturer name
// $array["designer"] = font designer name
// $array["description"] = font description
// $array["vendor url"] = vendor url
// $array["designer url"] = designer url
// $array["license"] = the terms under which the font may be used
// $array["license url"] = the url pointing to information about the font license
// $array["sample text"] = sample text included with the font for preview displays
// $array["platform"] = platform the font was designed under
//
// or
//
// returns boolean false if name tag can't be found, if the file
// doesn't exist, or if the magic number is not valid.
///////////////////////////

$font="D:/WINDOWS/Fonts/simhei.ttf";
#$font指向具体的字体


$array=ttfName($font);
echo   "<pre>";
print_r($array);
echo   "</pre>";

function ttfName($font) {
  $found=false;
  if (!$fp = @fopen ("$font","r")) {
    return false;
  }
  $magic=false;
  $pos=0;
  
  // here we check to see if a magic number is there, which
  // should be common to all truetype fonts
  // The header should appear somewhere in the first 1k,
  // if not, this is not a truetype font file.  in this event,
  // return false
  while (($magic==false) && (ftell($fp)<=1024)) {
    $data=fread($fp,4);
   
    // if we find the head tag, try to get the
    // location of the head table
    if ($data=="head") {
      $data=fread($fp, 12);
      $headData=unpack("N3",$data);

      // jump to the offset of the header table
      fseek($fp,$headData[2], SEEK_SET);
      $data=fread($fp,16);
      $headTableData=unpack("N4",$data);

      // is this our magic number ?
      if ($headTableData[4]==0x5F0F3CF5) {
        $magic=true;
      } else {
        return false;
      }
    }
  }
  
  // if we never found the head to begin with,
  // no magic at all
  if ($magic==false) {
    return false;
  }
  
  // return to the start of the file to begin processing
  // the font name information
  fseek($fp,0,SEEK_SET);
  while (!feof($fp)) {
    $data=fread($fp,4);

    // continue to loop until the 'name' tag is located
    if ($data=="name") {

      // read data present after tag, 2 unsigned Long, big endian
      $tableDir=fread($fp, 8);
      $tableDirData=unpack("N2",$tableDir);
      $found=true;
      break;
    }
  }
  if ($found) {
    // jump to offset of table, from beginning of file
    fseek($fp,$tableDirData[2], SEEK_SET);
  
    // read three unsigned short, big endian.  get next table offset,
    // and number of records present, as well as the platform ID
    $data=fread($fp, 8);
    $info=unpack("n4", $data);
   
    // figure out the platform ID, and add it to our final array
    switch($info[4]) {
      case 0:
        $name["platform"]="Unicode";
        break;
      case 1:
        $name["platform"]="Apple Macintosh";
        break;
      case 2:
        $name["platform"]="ISO";
        break;
      case 3:
        $name["platform"]="Microsoft Windows";
        break;
      case 4:
        $name["platform"]="Custom";
        break;
      default:
        $name["platform"]="unknown";
    }
   
    //jump back 2 bytes, so we're in the right place
    fseek($fp, ftell($fp)-2, SEEK_SET);
   
    // read six unsigned integers, big endian - loop through all records
    // the number of records is defined in the pervious table
    $i=0;
    for ($x=0; $x<=$info[2]; $x++) {
      $a=fread($fp, 12);
      $data=unpack("n6",$a);


      // in these IF statements we find the first occurances of each specific
      // piece of data, and store the appropriate information
      if (($data[4]==0) && (!isset($indexData["copy"]))) {
        $indexData["copy"]=$data;
      } else
      if (($data[4]==1) && (!isset($indexData["font family"]))) {
        $indexData["font family"]=$data;
      } else
      if (($data[4]==2) && (!isset($indexData["font subfamily"]))) {
        $indexData["font subfamily"]=$data;
      } else
      if (($data[4]==3) && (!isset($indexData["id"]))) {
        $indexData["id"]=$data;
      } else
      if (($data[4]==4) && (!isset($indexData["name"]))) {
        $indexData["name"]=$data;
      } else
      if (($data[4]==5) && (!isset($indexData["version"]))) {
        $indexData["version"]=$data;
      } else
      if (($data[4]==6) && (!isset($indexData["postscript name"]))) {
        $indexData["postscript name"]=$data;
      } else
      if (($data[4]==7) && (!isset($indexData["tm"]))) {
        $indexData["tm"]=$data;
      } else
      if (($data[4]==8) && (!isset($indexData["manufacturer"]))) {
        $indexData["manufacturer"]=$data;
      } else
      if (($data[4]==9) && (!isset($indexData["designer"]))) {
        $indexData["designer"]=$data;
      } else
      if (($data[4]==10) && (!isset($indexData["description"]))) {
        $indexData["description"]=$data;
      } else
      if (($data[4]==11) && (!isset($indexData["vendor url"]))) {
        $indexData["vendor url"]=$data;
      } else
      if (($data[4]==12) && (!isset($indexData["designer url"]))) {
        $indexData["designer url"]=$data;
      } else
      if (($data[4]==13) && (!isset($indexData["license"]))) {
        $indexData["license"]=$data;
      } else
      if (($data[4]==14) && (!isset($indexData["license url"]))) {
        $indexData["license url"]=$data;
      } else
      if (($data[4]==19) && (!isset($indexData["sample text"]))) {
        $indexData["sample text"]=$data;
      }
    }
   
    // set the beginning of the variable area
    $stringStorageStart=ftell($fp)-12;
    foreach ($indexData as $key=>$val) {
      fseek($fp, ($stringStorageStart+$indexData[$key][6]), SEEK_SET);
      $name[$key]=fread($fp, $indexData[$key][5]);
    }
   
    // remove pointless characters users put in to be l33t
    $name=str_replace("\n"," ",$name);
    $name=str_replace("\r","",$name);
    $name=str_replace("\x00","",$name);
    fclose($fp);
    return $name;
  } else {
    fclose($fp);
    return false;
  }
}

?>
2003-8-9 05:37 PM#1
查看资料  发短消息  顶部
 
yourlook (yourlook)
高级会员
Rank: 4
资深会员



UID 13385
精华 0
积分 802
帖子 799
金钱 802 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2002-3-23
来自 哈尔滨
状态 离线
[推荐阅读] 金山毒霸V 正式零售版下载
怪了,哪来的这么多代码~



欢迎访问我的冰城网站,请提点宝贵意见
http://www.yourlook.cn/bbs/
2003-8-9 05:39 PM#2
查看资料  访问主页  Blog  发短消息  QQ . .   ICQ 状态  Yahoo!  顶部
 
yourlook (yourlook)
高级会员
Rank: 4
资深会员



UID 13385
精华 0
积分 802
帖子 799
金钱 802 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2002-3-23
来自 哈尔滨
状态 离线
[推荐阅读] 怎样编网页加密页?
可不可以把Fonts文件夹下的字体用列表显示出来



欢迎访问我的冰城网站,请提点宝贵意见
http://www.yourlook.cn/bbs/
2003-8-9 05:42 PM#3
查看资料  访问主页  Blog  发短消息  QQ . .   ICQ 状态  Yahoo!  顶部
 
xltxlm (xltxlm)
金牌会员
Rank: 6Rank: 6
版主



UID 19902
精华 3
积分 1090
帖子 3571
金钱 1060 喜悦币
威望 30
人脉 0
阅读权限 70
注册 2003-4-26
状态 离线
[推荐阅读] 将PHP变量转化为JS变量的问题
我以前做了一个显示文件程序,搜一下。
嘿嘿,配合它。。。
2003-8-9 05:43 PM#4
查看资料  发短消息  顶部
 
fwolf (fwolf)
金牌会员
Rank: 6Rank: 6
资深会员


UID 19073
精华 0
积分 1227
帖子 1236
金钱 1227 喜悦币
威望 0
人脉 0
阅读权限 70
注册 2003-3-20
来自 河北/石家庄
状态 离线
[推荐阅读] 怎么这样,导不了数据了.
楼上的怎么总能找到好东西?
2003-8-9 07:30 PM#5
查看资料  发短消息  QQ . .   顶部
 
gw2100 (gw2100)
高级会员
Rank: 4
资深会员



UID 18239
精华 0
积分 824
帖子 818
金钱 824 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2003-2-2
来自 北京朝阳农展馆
状态 离线
[推荐阅读] 求在厦门懂PHP的朋友做一个网站。外地联系方便的也可以
支持小妹
2003-8-9 08:16 PM#6
查看资料  发短消息  ICQ 状态  顶部
 
wyw5257 (wyw5257)
金牌会员
Rank: 6Rank: 6
高级会员


UID 19797
精华 0
积分 2069
帖子 2040
金钱 2069 喜悦币
威望 0
人脉 0
阅读权限 70
注册 2003-4-22
状态 离线
[推荐阅读] 这样为什么会有错
有心办事事终成



Freedom
wyw5257[AT]163.com
2003-8-9 08:18 PM#7
查看资料  发短消息  QQ . .   顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.031758 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP