zoukankan      html  css  js  c++  java
  • Java——CaptchaUtil生成二维码乱码

    前言

    这个问题就是因为Linux上没有字体,你可以有两种方法,一个在生成的时候设置字体,一个就是安装字体。
    默认的字体为Courier

    乱码情况

    步骤

    安装字体工具

    yum install -y fontconfig mkfontscale
    

    查看服务器字体

    # fc-list
    /usr/share/fonts/dejavu/DejaVuSansCondensed-Oblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
    /usr/share/fonts/dejavu/DejaVuSansCondensed-Bold.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold
    /usr/share/fonts/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
    /usr/share/fonts/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
    /usr/share/fonts/dejavu/DejaVuSansCondensed.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
    /usr/share/fonts/dejavu/DejaVuSans-ExtraLight.ttf: DejaVu Sans,DejaVu Sans Light:style=ExtraLight
    /usr/share/fonts/dejavu/DejaVuSansCondensed-BoldOblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold Oblique,Bold Oblique
    /usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique
    /usr/share/fonts/dejavu/DejaVuSans-BoldOblique.ttf: DejaVu Sans:style=Bold Oblique
    

    寻找对应的字体并上传到服务器字体文件目录下

    缓存下字体

    #fc-cache /usr/share/fonts/lyx
    

    拷贝到jdk并缓存

    拷贝字体文件到  jdk安装目录/jre/lib/fonts 目录下
    运行命令  fc-cache jdk安装目录/jre/lib/fonts
    

    重启项目

    重启java项目即可
    
  • 相关阅读:
    PHP生成pdf文档
    PHP将数据库数据批量生成word文档
    三个常用的PHP图表类库
    Javascript——(1)
    python学习HTML之CSS(2)
    python学习HTML之CSS
    python学习之HTML
    python学习之rabbitmq
    第10周15/16/17
    多进程
  • 原文地址:https://www.cnblogs.com/wangyang0210/p/11428634.html
Copyright © 2011-2022 走看看