Code Monkey home page Code Monkey logo

Comments (7)

shenmadouyaowen avatar shenmadouyaowen commented on August 20, 2024 2

@endroid Thank you very much, according to the link you provided, I have found can display Chinese fonts.

from qr-code.

scfff avatar scfff commented on August 20, 2024

是因为调用的字体不支持中文, endroid\qrcode\src\QrCode.php 文件
$this->setLabelFontPath(DIR.'/../assets/font/opensans.ttf');
改为中文字体路径即可。

from qr-code.

shenmadouyaowen avatar shenmadouyaowen commented on August 20, 2024

$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.

endroid avatar endroid commented on August 20, 2024

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.

shenmadouyaowen avatar shenmadouyaowen commented on August 20, 2024

@endroid Thank you for the link, I found I needed fonts, but it still does not display or garbled

from qr-code.

endroid avatar endroid commented on August 20, 2024

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.

childeYin avatar childeYin commented on August 20, 2024

'Noto Sans CJK SC ' resolved my question , Chinese fonts can display, thanks.

from qr-code.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.