Comments (7)
@endroid Thank you very much, according to the link you provided, I have found can display Chinese fonts.
from qr-code.
是因为调用的字体不支持中文, endroid\qrcode\src\QrCode.php 文件
$this->setLabelFontPath(DIR.'/../assets/font/opensans.ttf');
改为中文字体路径即可。
from qr-code.
$qrCode =new \Endroid\QrCode\QrCode();
$qrCode
->setText('http://www.test.com/')
->setSize(300)
->setPadding(10)
->setErrorCorrection('high')
->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))
->setLabel('测试中文')
->setLabelFontPath(DIR.'/../assets/font/opensans.ttf')
->setLabelFontSize(16)
->setImageType(\Endroid\QrCode\QrCode::IMAGE_TYPE_PNG)
;
//$list = $Model->where($map)->paginate(5,false,['query' => $this->request->param(),]);
// now we can directly output the qrcode
header('Content-Type: '.$qrCode->getContentType());
$qrCode->render();
我之前试过,但只显示二维码,中文处什么都没有
from qr-code.
Hi @shenmadouyaowen, I don't exacly know how the imagettftext function which is used here handles fonts, but it indeed looks like you need another font, as @scfff already mentioned. For example, when I use the font "Noto Sans CJK SC" from the URL https://www.google.com/get/noto/, the label is generated correctly.
from qr-code.
@endroid Thank you for the link, I found I needed fonts, but it still does not display or garbled
from qr-code.
Too bad. If you attach the font file you are using I can try to see if it works on my side. You can also create a simple script that only calls the imagettftext function with your font to see if this issue has any relation with my library.
from qr-code.
'Noto Sans CJK SC ' resolved my question , Chinese fonts can display, thanks.
from qr-code.
Related Issues (20)
- Specifying QR code models HOT 2
- [Feature Request] PdfWriter sub-millimeter block size
- vcards HOT 1
- Problems using library HOT 1
- imagettfbbox(): Could not find/open font HOT 6
- Expected type 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelInterface'. Found 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh'. HOT 1
- PArameter documentation HOT 2
- Background color and margin for logo HOT 1
- How can I add an image with input type file? HOT 1
- Message: Interface "Endroid\QrCode\QrCodeInterface" not found HOT 1
- Modifying cells of the matrix HOT 3
- how to set the version of a qrcode HOT 1
- Question : how is it possible not displaying the label (for accessibility reasons) ? HOT 2
- Call to undefined method Endroid\QrCode\QrCode::create() HOT 3
- Image embedded in email contains full path to image HOT 2
- Could it be that the readme is outdated? HOT 2
- [Feature Request] SvgWriter with choice of code generation policy - Option to Use Previous SVG Generation Method with <defs> HOT 4
- Version 2+ really slow (xdebug) HOT 3
- Composer install problem HOT 1
- Showing ParseError error when libary added.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qr-code.