How to automatically wrap text and images in imagettfbbox and imagettftext in PHP

不言
Release: 2023-04-02 14:10:01
Original
9264 people have browsed it

This article mainly introduces the method of automatic line wrapping of text and pictures in imagettfbbox and imagettftext in PHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

mb_internal_encoding("UTF-8"); // 设置编码 // 这几个变量分别是 字体大小, 角度, 字体名称, 字符串, 预设宽度 $content = ""; // 将字符串拆分成一个个单字 保存到数组 letter 中 for ($i=0;$i $width) && ($content !== "")) { $content .= "\n"; } $content .= $l; } // $fontBox = imagettfbbox($fontSize, 0, $font, $text3); imagettftext ( $target, $fontSize, 0, ceil(($width - $fontBox[2]) / 2), 400, $fontColor_black, $font, $content );
Copy after login

The above is this article The entire content, I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

PHPstorm configures PHPunit to unit test the PHP code introduced by composer

The above is the detailed content of How to automatically wrap text and images in imagettfbbox and imagettftext in PHP. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!