免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2871 | 回复: 10
打印 上一主题 下一主题

还是png图片问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-10-31 11:50 |只看该作者 |倒序浏览
<?php
  header("Content-type: image/jpeg");
  $im = imagecreate(400,30);
  $white = imagecolorallocate($im, 255,255,255);
  $black = imagecolorallocate($im, 0,0,0);

  // Replace path by your own font path
  imagettftext($im, 20, 0, 10, 20, $black, "/path/arial.ttf",
  "Testing... Omega: Ω");
  imagejpeg($im);
  imagedestroy($im);
?>

这个文件运行错误,
"/path/arial.ttf"
是啥意思,请教

论坛徽章:
0
2 [报告]
发表于 2005-10-31 12:43 |只看该作者
字符集 的文件路径
看手册就用说明
请你看完手册再提问
还有 请你看本版的 置顶贴

论坛徽章:
0
3 [报告]
发表于 2005-10-31 13:24 |只看该作者

我不知字符集 的文件路径在那里呀?

我不知字符集 的文件路径在那里呀?我找不到呀?请指点一下

论坛徽章:
0
4 [报告]
发表于 2005-10-31 14:37 |只看该作者

怎样支持中文字体呀?

header("Content-type: image/png");
  $im = imagecreate(500,100);
  $black = imagecolorallocate($im, 0,0,0);
  $white = imagecolorallocate($im, 255,255,255);
  

  // Replace path by your own font path
  //imagettftext($im, 20, 0, 10, 20, $black, "/path/arial.ttf","Testing");
  imagettftext($im, 50, 0, 50, 60, $white, "/WINNT/Fonts/黑体.ttf","你好");
  imagejpeg($im);
  imagedestroy($im);
这样不行呀imagettftext($im, 50, 0, 50, 60, $white, "/WINNT/Fonts/黑体.ttf","你好");
报错
imagettftext($im, 20, 0, 10, 20, $black, "/WINNT/Fonts/arial.ttf","Testing");
这样就不报错,怎样让他实现中文字体呀?

[ 本帖最后由 jimli 于 2005-10-31 14:39 编辑 ]

论坛徽章:
0
5 [报告]
发表于 2005-10-31 15:54 |只看该作者
在fonts下没有"黑体.ttf"这个文件

  1. imagettftext($im, 50, 0, 50, 60, $white, "/WINNT/Fonts/simhei.ttf","你好");
复制代码

论坛徽章:
0
6 [报告]
发表于 2005-11-01 09:14 |只看该作者

不显示呀

imagettftext($im, 50, 0, 50, 60, $white, "/WINNT/Fonts/simhei.ttf","你好");
按您说的这样不报错了,但不显示就"你好"两个字呀?
换成imagettftext($im, 50, 0, 50, 60, $white, "/WINNT/Fonts/simhei.ttf","test");
就显示"test",字体库里也有simhei字体,是不是不支持中文呀,怎样让他支持呀?谢谢

[ 本帖最后由 jimli 于 2005-11-1 09:15 编辑 ]

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
7 [报告]
发表于 2005-11-01 09:40 |只看该作者

论坛徽章:
0
8 [报告]
发表于 2005-11-01 17:37 |只看该作者
需要字体文件。

看看我的小站:

http://www.makepic.com

论坛徽章:
0
9 [报告]
发表于 2005-11-01 21:20 |只看该作者

乱码没编译过来呀?怎么编译呀?

<?
Class GB2UTF8
{
        var $gb;          // 待转换的GB2312字符串
        var $utf8;        // 转换后的UTF8字符串
    var $CodeTable;   // 转换过程中使用的GB2312代码文件数组
    var $ErrorMsg;    // 转换过程之中的错误讯息

        function GB2UTF8&#40;$InStr=""&#41;
        {
                $this->;gb=$InStr;
                $this->;SetGb2312&#40;&#41;;
                &#40;$this->;gb==""&#41;?0&#58;$this->;Convert&#40;&#41;;
        }

        function SetGb2312&#40;$InStr="gb2312.txt"&#41;
        {                  // 设置gb2312代码文件,默认为gb2312.txt
                $this->;ErrorMsg="";
                $tmp=@file&#40;$InStr&#41;;
        if &#40;!$tmp&#41; {
            $this->;ErrorMsg="No GB2312";
            return false;
            }
                $this->;CodeTable=array&#40;&#41;;
                while&#40;list&#40;$key,$value&#41;=each&#40;$tmp&#41;&#41; {
                        $this->;CodeTable&#91;hexdec&#40;substr&#40;$value,0,6&#41;&#41;&#93;=substr&#40;$value,7,6&#41;;
                }
        }

        function Convert&#40;&#41;
        {                   // 转换GB2312字符串到UTF8字符串,需预先设置$gb
                $this->;utf8="";
                if&#40;!trim&#40;$this->;gb&#41; || $this->;ErrorMsg!=""&#41; {
                        return &#40;$this->;utf8=$this->;ErrorMsg&#41;;
                }
        $str=$this->;gb;

                while&#40;$str&#41; {
                        if &#40;ord&#40;substr&#40;$str,0,1&#41;&#41;>;127&#41;
                                {
                                        $tmp=substr&#40;$str,0,2&#41;;
                                        $str=substr&#40;$str,2,strlen&#40;$str&#41;&#41;;
                                        $tmp=$this->;U2UTF8&#40;hexdec&#40;$this->;CodeTable&#91;hexdec&#40;bin2hex&#40;$tmp&#41;&#41;-0x8080&#93;&#41;&#41;;
                                        for&#40;$i=0;$i<strlen &#40;$tmp&#41;;$i+=3&#41;
                                        $this->;utf8.=chr&#40;substr&#40;$tmp,$i,3&#41;&#41;;
                                }
                        else
                                {
                                        $tmp=substr&#40;$str,0,1&#41;;
                                        $str=substr&#40;$str,1,strlen&#40;$str&#41;&#41;;
                                        $this->;utf8.=$tmp;
                                }
                        }
                return $this->;utf8;
        }


        function U2UTF8&#40;$InStr&#41;
        {
                for&#40;$i=0;$i<count&#40;$InStr&#41;;$i++&#41;
                $str="";
                if &#40;$InStr < 0x80&#41; {
                        $str.=ord&#40;$InStr&#41;;
                }
                else if &#40;$InStr < 0x800&#41; {
                        $str.=&#40;0xC0 | $InStr>;>;6&#41;;
                        $str.=&#40;0x80 | $InStr & 0x3F&#41;;
                }
                else if &#40;$InStr < 0x10000&#41; {
                        $str.=&#40;0xE0 | $InStr>;>;12&#41;;
                        $str.=&#40;0x80 | $InStr>;>;6 & 0x3F&#41;;
                        $str.=&#40;0x80 | $InStr & 0x3F&#41;;
                }
                else if &#40;$InStr < 0x200000&#41; {
                        $str.=&#40;0xF0 | $InStr>;>;18&#41;;
                        $str.=&#40;0x80 | $InStr>;>;12 & 0x3F&#41;;
                        $str.=&#40;0x80 | $InStr>;>;6 & 0x3F&#41;;
                        $str.=&#40;0x80 | $InStr & 0x3F&#41;;
                }
                return $str;
        }
}
?>;
}等等这些乱码怎么编译过来呀?这样不能用呀?谢谢了老大

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
10 [报告]
发表于 2005-11-02 16:46 |只看该作者
你可以替换一下子,有的是(有的是),转换过程出了问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP