目录

1、使用环境

2、关于freetype库

3、编译freetype-2.10.4

4、下载LVGL官方封装的接口lv_lib_freetype

5、在mian.c中添加测试代码


1、使用环境

硬件环境:宸芯科技的SS202X系列芯片(笔者这里使用的是SS202D)

软件环境:Linux(移植的嵌入式系统)  LVGL7.11

编译器:arm-linux-gnueabihf-gcc

2、关于freetype库

笔者这里使用的是freetype-2.10.4,下载地址:https://download.savannah.gnu.org/releases/freetype/

3、编译freetype-2.10.4

(1)解压freetype-2.10.4

tar -zxvf freetype-2.10.4.tar.gz

解压完成后可以用tree命令看到如下文件目录树

tree freetype-2.10.4freetype-2.10.4
├── autogen.sh
├── builds
│   ├── amiga
│   │   ├── include
│   │   │   └── config
│   │   │       ├── ftconfig.h
│   │   │       └── ftmodule.h
│   │   ├── makefile
│   │   ├── makefile.os4
│   │   ├── README
│   │   ├── smakefile
│   │   └── src
│   │       └── base
│   │           ├── ftdebug.c
│   │           └── ftsystem.c
│   ├── ansi
│   │   ├── ansi-def.mk
│   │   └── ansi.mk
│   ├── atari
│   │   ├── ATARI.H
│   │   ├── deflinejoiner.awk
│   │   ├── FNames.SIC
│   │   ├── FREETYPE.PRJ
│   │   ├── gen-purec-patch.sh
│   │   └── README.TXT
│   ├── beos
│   │   ├── beos-def.mk
│   │   ├── beos.mk
│   │   └── detect.mk
│   ├── cmake
│   │   ├── FindBrotliDec.cmake
│   │   ├── FindHarfBuzz.cmake
│   │   ├── iOS.cmake
│   │   └── testbuild.sh
│   ├── compiler
│   │   ├── ansi-cc.mk
│   │   ├── bcc-dev.mk
│   │   ├── bcc.mk
│   │   ├── emx.mk
│   │   ├── gcc-dev.mk
│   │   ├── gcc.mk
│   │   ├── intelc.mk
│   │   ├── unix-lcc.mk
│   │   ├── visualage.mk
│   │   ├── visualc.mk
│   │   ├── watcom.mk
│   │   └── win-lcc.mk
│   ├── detect.mk
│   ├── dos
│   │   ├── detect.mk
│   │   ├── dos-def.mk
│   │   ├── dos-emx.mk
│   │   ├── dos-gcc.mk
│   │   └── dos-wat.mk
│   ├── exports.mk
│   ├── freetype.mk
│   ├── link_dos.mk
│   ├── link_std.mk
│   ├── mac
│   │   ├── ascii2mpw.py
│   │   ├── freetype-Info.plist
│   │   ├── FreeType.m68k_cfm.make.txt
│   │   ├── FreeType.m68k_far.make.txt
│   │   ├── FreeType.ppc_carbon.make.txt
│   │   ├── FreeType.ppc_classic.make.txt
│   │   ├── ftlib.prj.xml
│   │   ├── ftmac.c
│   │   └── README
│   ├── meson
│   │   ├── extract_freetype_version.py
│   │   ├── extract_libtool_version.py
│   │   ├── generate_reference_docs.py
│   │   ├── parse_modules_cfg.py
│   │   └── process_ftoption_h.py
│   ├── modules.mk
│   ├── os2
│   │   ├── detect.mk
│   │   ├── os2-def.mk
│   │   ├── os2-dev.mk
│   │   └── os2-gcc.mk
│   ├── symbian
│   │   ├── bld.inf
│   │   └── freetype.mmp
│   ├── toplevel.mk
│   ├── unix
│   │   ├── aclocal.m4
│   │   ├── ax_compare_version.m4
│   │   ├── ax_prog_python_version.m4
│   │   ├── config.guess
│   │   ├── config.sub
│   │   ├── configure
│   │   ├── configure.ac
│   │   ├── configure.raw
│   │   ├── detect.mk
│   │   ├── freetype2.in
│   │   ├── freetype2.m4
│   │   ├── freetype-config.in
│   │   ├── ftconfig.h.in
│   │   ├── ft-munmap.m4
│   │   ├── ftsystem.c
│   │   ├── install.mk
│   │   ├── install-sh
│   │   ├── ltmain.sh
│   │   ├── pkg.m4
│   │   ├── unix-cc.in
│   │   ├── unixddef.mk
│   │   ├── unix-def.in
│   │   ├── unix-dev.mk
│   │   ├── unix-lcc.mk
│   │   └── unix.mk
│   ├── vms
│   │   ├── ftconfig.h
│   │   ├── ftsystem.c
│   │   ├── LIBS.OPT_IA64
│   │   ├── _LINK.OPT_IA64
│   │   └── vmslib.dat
│   ├── wince
│   │   ├── ftdebug.c
│   │   ├── vc2005-ce
│   │   │   ├── freetype.sln
│   │   │   ├── freetype.vcproj
│   │   │   └── index.html
│   │   └── vc2008-ce
│   │       ├── freetype.sln
│   │       ├── freetype.vcproj
│   │       └── index.html
│   └── windows
│       ├── detect.mk
│       ├── ftdebug.c
│       ├── vc2010
│       │   ├── freetype.sln
│       │   ├── freetype.user.props
│       │   ├── freetype.vcxproj
│       │   ├── freetype.vcxproj.filters
│       │   └── index.html
│       ├── visualc
│       │   ├── freetype.dsp
│       │   ├── freetype.dsw
│       │   ├── freetype.sln
│       │   ├── freetype.vcproj
│       │   └── index.html
│       ├── visualce
│       │   ├── freetype.dsp
│       │   ├── freetype.dsw
│       │   ├── freetype.vcproj
│       │   └── index.html
│       ├── w32-bccd.mk
│       ├── w32-bcc.mk
│       ├── w32-dev.mk
│       ├── w32-gcc.mk
│       ├── w32-icc.mk
│       ├── w32-intl.mk
│       ├── w32-lcc.mk
│       ├── w32-mingw32.mk
│       ├── w32-vcc.mk
│       ├── w32-wat.mk
│       └── win32-def.mk
├── ChangeLog
├── ChangeLog.20
├── ChangeLog.21
├── ChangeLog.22
├── ChangeLog.23
├── ChangeLog.24
├── ChangeLog.25
├── ChangeLog.26
├── ChangeLog.27
├── ChangeLog.28
├── ChangeLog.29
├── CMakeLists.txt
├── configure
├── devel
│   ├── ft2build.h
│   └── ftoption.h
├── docs
│   ├── CHANGES
│   ├── CMAKE
│   ├── CUSTOMIZE
│   ├── DEBUG
│   ├── DOCGUIDE
│   ├── formats.txt
│   ├── freetype-config.1
│   ├── FTL.TXT
│   ├── GPLv2.TXT
│   ├── INSTALL
│   ├── INSTALL.ANY
│   ├── INSTALL.CROSS
│   ├── INSTALL.GNU
│   ├── INSTALL.MAC
│   ├── INSTALL.UNIX
│   ├── INSTALL.VMS
│   ├── LICENSE.TXT
│   ├── MAKEPP
│   ├── PROBLEMS
│   ├── raster.txt
│   ├── README
│   ├── reference
│   │   ├── 404.html
│   │   ├── assets
│   │   │   ├── fonts
│   │   │   │   ├── font-awesome.css
│   │   │   │   ├── material-icons.css
│   │   │   │   └── specimen
│   │   │   │       ├── FontAwesome.ttf
│   │   │   │       ├── FontAwesome.woff
│   │   │   │       ├── FontAwesome.woff2
│   │   │   │       ├── MaterialIcons-Regular.ttf
│   │   │   │       ├── MaterialIcons-Regular.woff
│   │   │   │       └── MaterialIcons-Regular.woff2
│   │   │   ├── images
│   │   │   │   ├── favicon.png
│   │   │   │   └── icons
│   │   │   │       ├── bitbucket.1b09e088.svg
│   │   │   │       ├── github.f0b8504a.svg
│   │   │   │       └── gitlab.6dd19c00.svg
│   │   │   ├── javascripts
│   │   │   │   ├── application.c33a9706.js
│   │   │   │   ├── lunr
│   │   │   │   │   ├── lunr.ar.js
│   │   │   │   │   ├── lunr.da.js
│   │   │   │   │   ├── lunr.de.js
│   │   │   │   │   ├── lunr.du.js
│   │   │   │   │   ├── lunr.es.js
│   │   │   │   │   ├── lunr.fi.js
│   │   │   │   │   ├── lunr.fr.js
│   │   │   │   │   ├── lunr.hu.js
│   │   │   │   │   ├── lunr.it.js
│   │   │   │   │   ├── lunr.ja.js
│   │   │   │   │   ├── lunr.jp.js
│   │   │   │   │   ├── lunr.multi.js
│   │   │   │   │   ├── lunr.nl.js
│   │   │   │   │   ├── lunr.no.js
│   │   │   │   │   ├── lunr.pt.js
│   │   │   │   │   ├── lunr.ro.js
│   │   │   │   │   ├── lunr.ru.js
│   │   │   │   │   ├── lunr.stemmer.support.js
│   │   │   │   │   ├── lunr.sv.js
│   │   │   │   │   ├── lunr.th.js
│   │   │   │   │   ├── lunr.tr.js
│   │   │   │   │   ├── lunr.vi.js
│   │   │   │   │   ├── tinyseg.js
│   │   │   │   │   └── wordcut.js
│   │   │   │   └── modernizr.86422ebf.js
│   │   │   └── stylesheets
│   │   │       ├── application.adb8469c.css
│   │   │       └── application-palette.a8b3c06d.css
│   │   ├── ft2-auto_hinter.html
│   │   ├── ft2-base_interface.html
│   │   ├── ft2-basic_types.html
│   │   ├── ft2-bdf_fonts.html
│   │   ├── ft2-bitmap_handling.html
│   │   ├── ft2-bzip2.html
│   │   ├── ft2-cache_subsystem.html
│   │   ├── ft2-cff_driver.html
│   │   ├── ft2-cid_fonts.html
│   │   ├── ft2-color_management.html
│   │   ├── ft2-computations.html
│   │   ├── ft2-error_code_values.html
│   │   ├── ft2-error_enumerations.html
│   │   ├── ft2-font_formats.html
│   │   ├── ft2-gasp_table.html
│   │   ├── ft2-glyph_management.html
│   │   ├── ft2-glyph_stroker.html
│   │   ├── ft2-glyph_variants.html
│   │   ├── ft2-gx_validation.html
│   │   ├── ft2-gzip.html
│   │   ├── ft2-header_file_macros.html
│   │   ├── ft2-header_inclusion.html
│   │   ├── ft2-incremental.html
│   │   ├── ft2-index.html
│   │   ├── ft2-layer_management.html
│   │   ├── ft2-lcd_rendering.html
│   │   ├── ft2-list_processing.html
│   │   ├── ft2-lzw.html
│   │   ├── ft2-mac_specific.html
│   │   ├── ft2-module_management.html
│   │   ├── ft2-multiple_masters.html
│   │   ├── ft2-ot_validation.html
│   │   ├── ft2-outline_processing.html
│   │   ├── ft2-parameter_tags.html
│   │   ├── ft2-pcf_driver.html
│   │   ├── ft2-pfr_fonts.html
│   │   ├── ft2-properties.html
│   │   ├── ft2-quick_advance.html
│   │   ├── ft2-raster.html
│   │   ├── ft2-sfnt_names.html
│   │   ├── ft2-sizes_management.html
│   │   ├── ft2-system_interface.html
│   │   ├── ft2-t1_cid_driver.html
│   │   ├── ft2-truetype_engine.html
│   │   ├── ft2-truetype_tables.html
│   │   ├── ft2-tt_driver.html
│   │   ├── ft2-type1_tables.html
│   │   ├── ft2-user_allocation.html
│   │   ├── ft2-version.html
│   │   ├── ft2-winfnt_fonts.html
│   │   ├── images
│   │   │   └── favico.ico
│   │   ├── index.html
│   │   ├── javascripts
│   │   │   └── extra.js
│   │   ├── search
│   │   │   └── search_index.json
│   │   ├── sitemap.xml
│   │   ├── sitemap.xml.gz
│   │   └── stylesheets
│   │       └── extra.css
│   ├── release
│   ├── TODO
│   └── VERSIONS.TXT
├── include
│   ├── freetype
│   │   ├── config
│   │   │   ├── ftconfig.h
│   │   │   ├── ftheader.h
│   │   │   ├── ftmodule.h
│   │   │   ├── ftoption.h
│   │   │   ├── ftstdlib.h
│   │   │   ├── integer-types.h
│   │   │   ├── mac-support.h
│   │   │   └── public-macros.h
│   │   ├── freetype.h
│   │   ├── ftadvanc.h
│   │   ├── ftbbox.h
│   │   ├── ftbdf.h
│   │   ├── ftbitmap.h
│   │   ├── ftbzip2.h
│   │   ├── ftcache.h
│   │   ├── ftchapters.h
│   │   ├── ftcid.h
│   │   ├── ftcolor.h
│   │   ├── ftdriver.h
│   │   ├── fterrdef.h
│   │   ├── fterrors.h
│   │   ├── ftfntfmt.h
│   │   ├── ftgasp.h
│   │   ├── ftglyph.h
│   │   ├── ftgxval.h
│   │   ├── ftgzip.h
│   │   ├── ftimage.h
│   │   ├── ftincrem.h
│   │   ├── ftlcdfil.h
│   │   ├── ftlist.h
│   │   ├── ftlzw.h
│   │   ├── ftmac.h
│   │   ├── ftmm.h
│   │   ├── ftmodapi.h
│   │   ├── ftmoderr.h
│   │   ├── ftotval.h
│   │   ├── ftoutln.h
│   │   ├── ftparams.h
│   │   ├── ftpfr.h
│   │   ├── ftrender.h
│   │   ├── ftsizes.h
│   │   ├── ftsnames.h
│   │   ├── ftstroke.h
│   │   ├── ftsynth.h
│   │   ├── ftsystem.h
│   │   ├── fttrigon.h
│   │   ├── fttypes.h
│   │   ├── ftwinfnt.h
│   │   ├── internal
│   │   │   ├── autohint.h
│   │   │   ├── cffotypes.h
│   │   │   ├── cfftypes.h
│   │   │   ├── compiler-macros.h
│   │   │   ├── ftcalc.h
│   │   │   ├── ftdebug.h
│   │   │   ├── ftdrv.h
│   │   │   ├── ftgloadr.h
│   │   │   ├── fthash.h
│   │   │   ├── ftmemory.h
│   │   │   ├── ftobjs.h
│   │   │   ├── ftpsprop.h
│   │   │   ├── ftrfork.h
│   │   │   ├── ftserv.h
│   │   │   ├── ftstream.h
│   │   │   ├── fttrace.h
│   │   │   ├── ftvalid.h
│   │   │   ├── psaux.h
│   │   │   ├── pshints.h
│   │   │   ├── services
│   │   │   │   ├── svbdf.h
│   │   │   │   ├── svcfftl.h
│   │   │   │   ├── svcid.h
│   │   │   │   ├── svfntfmt.h
│   │   │   │   ├── svgldict.h
│   │   │   │   ├── svgxval.h
│   │   │   │   ├── svkern.h
│   │   │   │   ├── svmetric.h
│   │   │   │   ├── svmm.h
│   │   │   │   ├── svotval.h
│   │   │   │   ├── svpfr.h
│   │   │   │   ├── svpostnm.h
│   │   │   │   ├── svprop.h
│   │   │   │   ├── svpscmap.h
│   │   │   │   ├── svpsinfo.h
│   │   │   │   ├── svsfnt.h
│   │   │   │   ├── svttcmap.h
│   │   │   │   ├── svtteng.h
│   │   │   │   ├── svttglyf.h
│   │   │   │   └── svwinfnt.h
│   │   │   ├── sfnt.h
│   │   │   ├── t1types.h
│   │   │   ├── tttypes.h
│   │   │   └── wofftypes.h
│   │   ├── t1tables.h
│   │   ├── ttnameid.h
│   │   ├── tttables.h
│   │   └── tttags.h
│   └── ft2build.h
├── Makefile
├── meson.build
├── meson_options.txt
├── modules.cfg
├── objs
│   └── README
├── README
├── README.git
├── src
│   ├── autofit
│   │   ├── afangles.c
│   │   ├── afangles.h
│   │   ├── afblue.c
│   │   ├── afblue.cin
│   │   ├── afblue.dat
│   │   ├── afblue.h
│   │   ├── afblue.hin
│   │   ├── afcjk.c
│   │   ├── afcjk.h
│   │   ├── afcover.h
│   │   ├── afdummy.c
│   │   ├── afdummy.h
│   │   ├── aferrors.h
│   │   ├── afglobal.c
│   │   ├── afglobal.h
│   │   ├── afhints.c
│   │   ├── afhints.h
│   │   ├── afindic.c
│   │   ├── afindic.h
│   │   ├── aflatin2.c
│   │   ├── aflatin2.h
│   │   ├── aflatin.c
│   │   ├── aflatin.h
│   │   ├── afloader.c
│   │   ├── afloader.h
│   │   ├── afmodule.c
│   │   ├── afmodule.h
│   │   ├── afranges.c
│   │   ├── afranges.h
│   │   ├── afscript.h
│   │   ├── afshaper.c
│   │   ├── afshaper.h
│   │   ├── afstyles.h
│   │   ├── aftypes.h
│   │   ├── afwarp.c
│   │   ├── afwarp.h
│   │   ├── afwrtsys.h
│   │   ├── autofit.c
│   │   ├── module.mk
│   │   └── rules.mk
│   ├── base
│   │   ├── ftadvanc.c
│   │   ├── ftbase.c
│   │   ├── ftbase.h
│   │   ├── ftbbox.c
│   │   ├── ftbdf.c
│   │   ├── ftbitmap.c
│   │   ├── ftcalc.c
│   │   ├── ftcid.c
│   │   ├── ftcolor.c
│   │   ├── ftdbgmem.c
│   │   ├── ftdebug.c
│   │   ├── fterrors.c
│   │   ├── ftfntfmt.c
│   │   ├── ftfstype.c
│   │   ├── ftgasp.c
│   │   ├── ftgloadr.c
│   │   ├── ftglyph.c
│   │   ├── ftgxval.c
│   │   ├── fthash.c
│   │   ├── ftinit.c
│   │   ├── ftlcdfil.c
│   │   ├── ftmac.c
│   │   ├── ftmm.c
│   │   ├── ftobjs.c
│   │   ├── ftotval.c
│   │   ├── ftoutln.c
│   │   ├── ftpatent.c
│   │   ├── ftpfr.c
│   │   ├── ftpsprop.c
│   │   ├── ftrfork.c
│   │   ├── ftsnames.c
│   │   ├── ftstream.c
│   │   ├── ftstroke.c
│   │   ├── ftsynth.c
│   │   ├── ftsystem.c
│   │   ├── fttrigon.c
│   │   ├── fttype1.c
│   │   ├── ftutil.c
│   │   ├── ftver.rc
│   │   ├── ftwinfnt.c
│   │   ├── md5.c
│   │   ├── md5.h
│   │   └── rules.mk
│   ├── bdf
│   │   ├── bdf.c
│   │   ├── bdfdrivr.c
│   │   ├── bdfdrivr.h
│   │   ├── bdferror.h
│   │   ├── bdf.h
│   │   ├── bdflib.c
│   │   ├── module.mk
│   │   ├── README
│   │   └── rules.mk
│   ├── bzip2
│   │   ├── ftbzip2.c
│   │   └── rules.mk
│   ├── cache
│   │   ├── ftcache.c
│   │   ├── ftcbasic.c
│   │   ├── ftccache.c
│   │   ├── ftccache.h
│   │   ├── ftccback.h
│   │   ├── ftccmap.c
│   │   ├── ftcerror.h
│   │   ├── ftcglyph.c
│   │   ├── ftcglyph.h
│   │   ├── ftcimage.c
│   │   ├── ftcimage.h
│   │   ├── ftcmanag.c
│   │   ├── ftcmanag.h
│   │   ├── ftcmru.c
│   │   ├── ftcmru.h
│   │   ├── ftcsbits.c
│   │   ├── ftcsbits.h
│   │   └── rules.mk
│   ├── cff
│   │   ├── cff.c
│   │   ├── cffcmap.c
│   │   ├── cffcmap.h
│   │   ├── cffdrivr.c
│   │   ├── cffdrivr.h
│   │   ├── cfferrs.h
│   │   ├── cffgload.c
│   │   ├── cffgload.h
│   │   ├── cffload.c
│   │   ├── cffload.h
│   │   ├── cffobjs.c
│   │   ├── cffobjs.h
│   │   ├── cffparse.c
│   │   ├── cffparse.h
│   │   ├── cfftoken.h
│   │   ├── module.mk
│   │   └── rules.mk
│   ├── cid
│   │   ├── ciderrs.h
│   │   ├── cidgload.c
│   │   ├── cidgload.h
│   │   ├── cidload.c
│   │   ├── cidload.h
│   │   ├── cidobjs.c
│   │   ├── cidobjs.h
│   │   ├── cidparse.c
│   │   ├── cidparse.h
│   │   ├── cidriver.c
│   │   ├── cidriver.h
│   │   ├── cidtoken.h
│   │   ├── module.mk
│   │   ├── rules.mk
│   │   └── type1cid.c
│   ├── gxvalid
│   │   ├── gxvalid.c
│   │   ├── gxvalid.h
│   │   ├── gxvbsln.c
│   │   ├── gxvcommn.c
│   │   ├── gxvcommn.h
│   │   ├── gxverror.h
│   │   ├── gxvfeat.c
│   │   ├── gxvfeat.h
│   │   ├── gxvfgen.c
│   │   ├── gxvjust.c
│   │   ├── gxvkern.c
│   │   ├── gxvlcar.c
│   │   ├── gxvmod.c
│   │   ├── gxvmod.h
│   │   ├── gxvmort0.c
│   │   ├── gxvmort1.c
│   │   ├── gxvmort2.c
│   │   ├── gxvmort4.c
│   │   ├── gxvmort5.c
│   │   ├── gxvmort.c
│   │   ├── gxvmort.h
│   │   ├── gxvmorx0.c
│   │   ├── gxvmorx1.c
│   │   ├── gxvmorx2.c
│   │   ├── gxvmorx4.c
│   │   ├── gxvmorx5.c
│   │   ├── gxvmorx.c
│   │   ├── gxvmorx.h
│   │   ├── gxvopbd.c
│   │   ├── gxvprop.c
│   │   ├── gxvtrak.c
│   │   ├── module.mk
│   │   ├── README
│   │   └── rules.mk
│   ├── gzip
│   │   ├── adler32.c
│   │   ├── ftgzip.c
│   │   ├── ftzconf.h
│   │   ├── infblock.c
│   │   ├── infblock.h
│   │   ├── infcodes.c
│   │   ├── infcodes.h
│   │   ├── inffixed.h
│   │   ├── inflate.c
│   │   ├── inftrees.c
│   │   ├── inftrees.h
│   │   ├── infutil.c
│   │   ├── infutil.h
│   │   ├── rules.mk
│   │   ├── zlib.h
│   │   ├── zutil.c
│   │   └── zutil.h
│   ├── lzw
│   │   ├── ftlzw.c
│   │   ├── ftzopen.c
│   │   ├── ftzopen.h
│   │   └── rules.mk
│   ├── otvalid
│   │   ├── module.mk
│   │   ├── otvalid.c
│   │   ├── otvalid.h
│   │   ├── otvbase.c
│   │   ├── otvcommn.c
│   │   ├── otvcommn.h
│   │   ├── otverror.h
│   │   ├── otvgdef.c
│   │   ├── otvgpos.c
│   │   ├── otvgpos.h
│   │   ├── otvgsub.c
│   │   ├── otvjstf.c
│   │   ├── otvmath.c
│   │   ├── otvmod.c
│   │   ├── otvmod.h
│   │   └── rules.mk
│   ├── pcf
│   │   ├── module.mk
│   │   ├── pcf.c
│   │   ├── pcfdrivr.c
│   │   ├── pcfdrivr.h
│   │   ├── pcferror.h
│   │   ├── pcf.h
│   │   ├── pcfread.c
│   │   ├── pcfread.h
│   │   ├── pcfutil.c
│   │   ├── pcfutil.h
│   │   ├── README
│   │   └── rules.mk
│   ├── pfr
│   │   ├── module.mk
│   │   ├── pfr.c
│   │   ├── pfrcmap.c
│   │   ├── pfrcmap.h
│   │   ├── pfrdrivr.c
│   │   ├── pfrdrivr.h
│   │   ├── pfrerror.h
│   │   ├── pfrgload.c
│   │   ├── pfrgload.h
│   │   ├── pfrload.c
│   │   ├── pfrload.h
│   │   ├── pfrobjs.c
│   │   ├── pfrobjs.h
│   │   ├── pfrsbit.c
│   │   ├── pfrsbit.h
│   │   ├── pfrtypes.h
│   │   └── rules.mk
│   ├── psaux
│   │   ├── afmparse.c
│   │   ├── afmparse.h
│   │   ├── cffdecode.c
│   │   ├── cffdecode.h
│   │   ├── module.mk
│   │   ├── psarrst.c
│   │   ├── psarrst.h
│   │   ├── psaux.c
│   │   ├── psauxerr.h
│   │   ├── psauxmod.c
│   │   ├── psauxmod.h
│   │   ├── psblues.c
│   │   ├── psblues.h
│   │   ├── psconv.c
│   │   ├── psconv.h
│   │   ├── pserror.c
│   │   ├── pserror.h
│   │   ├── psfixed.h
│   │   ├── psfont.c
│   │   ├── psfont.h
│   │   ├── psft.c
│   │   ├── psft.h
│   │   ├── psglue.h
│   │   ├── pshints.c
│   │   ├── pshints.h
│   │   ├── psintrp.c
│   │   ├── psintrp.h
│   │   ├── psobjs.c
│   │   ├── psobjs.h
│   │   ├── psread.c
│   │   ├── psread.h
│   │   ├── psstack.c
│   │   ├── psstack.h
│   │   ├── pstypes.h
│   │   ├── rules.mk
│   │   ├── t1cmap.c
│   │   ├── t1cmap.h
│   │   ├── t1decode.c
│   │   └── t1decode.h
│   ├── pshinter
│   │   ├── module.mk
│   │   ├── pshalgo.c
│   │   ├── pshalgo.h
│   │   ├── pshglob.c
│   │   ├── pshglob.h
│   │   ├── pshinter.c
│   │   ├── pshmod.c
│   │   ├── pshmod.h
│   │   ├── pshnterr.h
│   │   ├── pshrec.c
│   │   ├── pshrec.h
│   │   └── rules.mk
│   ├── psnames
│   │   ├── module.mk
│   │   ├── psmodule.c
│   │   ├── psmodule.h
│   │   ├── psnamerr.h
│   │   ├── psnames.c
│   │   ├── pstables.h
│   │   └── rules.mk
│   ├── raster
│   │   ├── ftmisc.h
│   │   ├── ftraster.c
│   │   ├── ftraster.h
│   │   ├── ftrend1.c
│   │   ├── ftrend1.h
│   │   ├── module.mk
│   │   ├── raster.c
│   │   ├── rasterrs.h
│   │   └── rules.mk
│   ├── sfnt
│   │   ├── module.mk
│   │   ├── pngshim.c
│   │   ├── pngshim.h
│   │   ├── rules.mk
│   │   ├── sfdriver.c
│   │   ├── sfdriver.h
│   │   ├── sferrors.h
│   │   ├── sfnt.c
│   │   ├── sfobjs.c
│   │   ├── sfobjs.h
│   │   ├── sfwoff2.c
│   │   ├── sfwoff2.h
│   │   ├── sfwoff.c
│   │   ├── sfwoff.h
│   │   ├── ttbdf.c
│   │   ├── ttbdf.h
│   │   ├── ttcmap.c
│   │   ├── ttcmapc.h
│   │   ├── ttcmap.h
│   │   ├── ttcolr.c
│   │   ├── ttcolr.h
│   │   ├── ttcpal.c
│   │   ├── ttcpal.h
│   │   ├── ttkern.c
│   │   ├── ttkern.h
│   │   ├── ttload.c
│   │   ├── ttload.h
│   │   ├── ttmtx.c
│   │   ├── ttmtx.h
│   │   ├── ttpost.c
│   │   ├── ttpost.h
│   │   ├── ttsbit.c
│   │   ├── ttsbit.h
│   │   ├── woff2tags.c
│   │   └── woff2tags.h
│   ├── smooth
│   │   ├── ftgrays.c
│   │   ├── ftgrays.h
│   │   ├── ftsmerrs.h
│   │   ├── ftsmooth.c
│   │   ├── ftsmooth.h
│   │   ├── module.mk
│   │   ├── rules.mk
│   │   └── smooth.c
│   ├── tools
│   │   ├── afblue.pl
│   │   ├── apinames.c
│   │   ├── chktrcmp.py
│   │   ├── cordic.py
│   │   ├── ftrandom
│   │   │   ├── ftrandom.c
│   │   │   ├── Makefile
│   │   │   └── README
│   │   ├── glnames.py
│   │   ├── make_distribution_archives.py
│   │   ├── no-copyright
│   │   ├── test_afm.c
│   │   ├── test_bbox.c
│   │   ├── test_trig.c
│   │   ├── update-copyright
│   │   └── update-copyright-year
│   ├── truetype
│   │   ├── module.mk
│   │   ├── rules.mk
│   │   ├── truetype.c
│   │   ├── ttdriver.c
│   │   ├── ttdriver.h
│   │   ├── tterrors.h
│   │   ├── ttgload.c
│   │   ├── ttgload.h
│   │   ├── ttgxvar.c
│   │   ├── ttgxvar.h
│   │   ├── ttinterp.c
│   │   ├── ttinterp.h
│   │   ├── ttobjs.c
│   │   ├── ttobjs.h
│   │   ├── ttpload.c
│   │   ├── ttpload.h
│   │   ├── ttsubpix.c
│   │   └── ttsubpix.h
│   ├── type1
│   │   ├── module.mk
│   │   ├── rules.mk
│   │   ├── t1afm.c
│   │   ├── t1afm.h
│   │   ├── t1driver.c
│   │   ├── t1driver.h
│   │   ├── t1errors.h
│   │   ├── t1gload.c
│   │   ├── t1gload.h
│   │   ├── t1load.c
│   │   ├── t1load.h
│   │   ├── t1objs.c
│   │   ├── t1objs.h
│   │   ├── t1parse.c
│   │   ├── t1parse.h
│   │   ├── t1tokens.h
│   │   └── type1.c
│   ├── type42
│   │   ├── module.mk
│   │   ├── rules.mk
│   │   ├── t42drivr.c
│   │   ├── t42drivr.h
│   │   ├── t42error.h
│   │   ├── t42objs.c
│   │   ├── t42objs.h
│   │   ├── t42parse.c
│   │   ├── t42parse.h
│   │   ├── t42types.h
│   │   └── type42.c
│   └── winfonts
│       ├── fnterrs.h
│       ├── module.mk
│       ├── rules.mk
│       ├── winfnt.c
│       └── winfnt.h
├── version.sed
└── vms_make.com72 directories, 794 files

(2)编译配置

进入目录

cd freetype-2.10.4

配置编译参数

这里指定了编译器为arm-linux-gnueablihf-gcc 安装目录为当前目录下的library,不需要依赖zlib和png库

./configure CC=arm-linux-gnueabihf-gcc --host=arm-linux --prefix=$PWD/library --with-zlib=no --with-png=no
make
make install

编译完成之后再用tree命令查看安装目录,结构如下:

library/
├── include
│   └── freetype2
│       ├── freetype
│       │   ├── config
│       │   │   ├── ftconfig.h
│       │   │   ├── ftheader.h
│       │   │   ├── ftmodule.h
│       │   │   ├── ftoption.h
│       │   │   ├── ftstdlib.h
│       │   │   ├── integer-types.h
│       │   │   ├── mac-support.h
│       │   │   └── public-macros.h
│       │   ├── freetype.h
│       │   ├── ftadvanc.h
│       │   ├── ftbbox.h
│       │   ├── ftbdf.h
│       │   ├── ftbitmap.h
│       │   ├── ftbzip2.h
│       │   ├── ftcache.h
│       │   ├── ftchapters.h
│       │   ├── ftcid.h
│       │   ├── ftcolor.h
│       │   ├── ftdriver.h
│       │   ├── fterrdef.h
│       │   ├── fterrors.h
│       │   ├── ftfntfmt.h
│       │   ├── ftgasp.h
│       │   ├── ftglyph.h
│       │   ├── ftgxval.h
│       │   ├── ftgzip.h
│       │   ├── ftimage.h
│       │   ├── ftincrem.h
│       │   ├── ftlcdfil.h
│       │   ├── ftlist.h
│       │   ├── ftlzw.h
│       │   ├── ftmac.h
│       │   ├── ftmm.h
│       │   ├── ftmodapi.h
│       │   ├── ftmoderr.h
│       │   ├── ftotval.h
│       │   ├── ftoutln.h
│       │   ├── ftparams.h
│       │   ├── ftpfr.h
│       │   ├── ftrender.h
│       │   ├── ftsizes.h
│       │   ├── ftsnames.h
│       │   ├── ftstroke.h
│       │   ├── ftsynth.h
│       │   ├── ftsystem.h
│       │   ├── fttrigon.h
│       │   ├── fttypes.h
│       │   ├── ftwinfnt.h
│       │   ├── t1tables.h
│       │   ├── ttnameid.h
│       │   ├── tttables.h
│       │   └── tttags.h
│       └── ft2build.h
├── lib
│   ├── libfreetype.a
│   ├── libfreetype.la
│   ├── libfreetype.so -> libfreetype.so.6.17.4
│   ├── libfreetype.so.6 -> libfreetype.so.6.17.4
│   ├── libfreetype.so.6.17.4
│   └── pkgconfig
│       └── freetype2.pc
└── share└── aclocal└── freetype2.m48 directories, 60 files

4、下载LVGL官方封装的接口lv_lib_freetype

下载地址:https://github.com/lvgl/lv_lib_freetype

由于文件较少,下面直接贴上源代码:

/*** @file lv_freetype.h**/
#ifndef _LV_FONT_TTF_H
#define _LV_FONT_TTF_H#ifdef __cplusplus
extern "C" {
#endif/**********************      INCLUDES*********************/
#include "lvgl/lvgl.h"
#include "ft2build.h"
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_CACHE_H
#include FT_SIZES_H/**********************      DEFINES*********************/
#define LV_USE_FT_CACHE_MANAGER  1/***********************      TYPEDEFS**********************/
typedef struct {uint16_t cnt;char*   name;
} lv_face_info_t;typedef struct {uint16_t num;uint16_t cnt;lv_ll_t  face_ll;
} lv_faces_control_t;typedef enum {FT_FONT_STYLE_NORMAL = 0,FT_FONT_STYLE_ITALIC = 1 << 0,FT_FONT_STYLE_BOLD   = 1 << 1
} LV_FT_FONT_STYLE;typedef struct {const char* name;   /* The name of the font file */lv_font_t* font;    /* point to lvgl font */uint16_t weight;    /* font size */uint16_t style;     /* font style */
} lv_ft_info_t;typedef struct {FT_Face     face;FT_Size     size;lv_font_t*  font;uint16_t    style;uint16_t weight;
} lv_font_fmt_freetype_dsc_t;typedef lv_font_fmt_freetype_dsc_t lv_font_fmt_ft_dsc_t;/*********************** GLOBAL PROTOTYPES**********************//*** init freetype library* @param max_faces Maximum number of opened FT_Face objects managed by this cache instance. Use 0 for defaults.* @param max_sizes Maximum number of opened FT_Size objects managed by this cache instance. Use 0 for defaults.* @param max_bytes Maximum number of bytes to use for cached data nodes. Use 0 for defaults.*                  Note that this value does not account for managed FT_Face and FT_Size objects.* @return true on success, otherwise false.*/
bool lv_freetype_init(FT_UInt max_faces, FT_UInt max_sizes, FT_ULong max_bytes);/*** Destroy freetype library*/
void lv_freetype_destroy(void);/*** Creates a font with info parameter specified.* @param info See lv_ft_info_t for details.*             when success, lv_ft_info_t->font point to the font you created.* @return true on success, otherwise false.*/
bool lv_ft_font_init(lv_ft_info_t *info);/*** Destroy a font that has been created.* @param font pointer to font.*/
void lv_ft_font_destroy(lv_font_t* font);/***********************      MACROS**********************/#ifdef __cplusplus
} /* extern "C" */
#endif#endif
/*** @file lv_freetype.c**//**********************      INCLUDES*********************/#include "lv_freetype.h"/**********************      DEFINES*********************//***********************      TYPEDEFS**********************//***********************  STATIC PROTOTYPES**********************/
static FT_Face face_find_in_list(lv_ft_info_t *info);
static void face_add_to_list(FT_Face face);
static void face_remove_from_list(FT_Face face);static void face_generic_finalizer(void* object);
static bool get_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out,uint32_t unicode_letter, uint32_t unicode_letter_next);
static const uint8_t * get_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter);#if LV_USE_FT_CACHE_MANAGER
static FT_Error font_face_requester(FTC_FaceID face_id,FT_Library library_is,FT_Pointer req_data,FT_Face* aface);
#endif/***********************  STATIC VARIABLES**********************/
static FT_Library library;#if LV_USE_FT_CACHE_MANAGER
static FTC_Manager cache_manager;
static FTC_CMapCache cmap_cache;
static FTC_SBitCache sbit_cache;
static FTC_SBit sbit;
#endifstatic lv_faces_control_t face_control;/***********************      MACROS**********************//***********************   GLOBAL FUNCTIONS**********************/
bool lv_freetype_init(FT_UInt max_faces, FT_UInt max_sizes, FT_ULong max_bytes)
{face_control.cnt = 0;face_control.num = max_faces;_lv_ll_init(&face_control.face_ll, sizeof(FT_Face *));FT_Error error = FT_Init_FreeType(&library);if (error) {LV_LOG_ERROR("init freeType error(%d)", error);return false;}#if LV_USE_FT_CACHE_MANAGERerror = FTC_Manager_New(library, max_faces, max_sizes,max_bytes, font_face_requester, NULL, &cache_manager);if (error) {FT_Done_FreeType(library);LV_LOG_ERROR("Failed to open cache manager");return false;}error = FTC_CMapCache_New(cache_manager, &cmap_cache);if(error) {LV_LOG_ERROR("Failed to open Cmap Cache");goto Fail;}error = FTC_SBitCache_New(cache_manager, &sbit_cache);if(error){LV_LOG_ERROR("Failed to open sbit cache");goto Fail;}return true;
Fail:FTC_Manager_Done(cache_manager);FT_Done_FreeType(library);return false;
#elseLV_UNUSED(max_sizes);LV_UNUSED(max_bytes);return true;
#endif/* LV_USE_FT_CACHE_MANAGER */
}void lv_freetype_destroy(void)
{
#if LV_USE_FT_CACHE_MANAGERFTC_Manager_Done(cache_manager);
#endifFT_Done_FreeType(library);
}bool lv_ft_font_init(lv_ft_info_t *info)
{lv_font_fmt_ft_dsc_t * dsc = lv_mem_alloc(sizeof(lv_font_fmt_ft_dsc_t));if(dsc == NULL) return false;dsc->font = lv_mem_alloc(sizeof(lv_font_t));if(dsc->font == NULL) {lv_mem_free(dsc);return false;}lv_face_info_t *face_info = NULL;FT_Face face = face_find_in_list(info);if (face == NULL) {if (face_control.cnt == face_control.num - 1) {LV_LOG_WARN("face full");goto Fail;}face_info = lv_mem_alloc(sizeof(lv_face_info_t) + strlen(info->name) + 1);if(face_info == NULL) {goto Fail;}FT_Error error = FT_New_Face(library, info->name, 0, &face);if(error){lv_mem_free(face_info);LV_LOG_WARN("create face error(%d)", error);goto Fail;}face_info->name = ((char *)face_info) + sizeof(lv_face_info_t);strcpy(face_info->name, info->name);face_info->cnt = 1;face->generic.data = face_info;face->generic.finalizer = face_generic_finalizer;face_add_to_list(face);}else {
#if LV_USE_FT_CACHE_MANAGER == 0FT_Size size;FT_Error error = FT_New_Size(face, &size);if (error) {goto Fail;}FT_Activate_Size(size);FT_Reference_Face(face);
#elseface_info = (lv_face_info_t *)face->generic.data;face_info->cnt++;
#endif}FT_Set_Pixel_Sizes(face, 0, info->weight);dsc->face = face;dsc->size = face->size;dsc->weight = info->weight;dsc->style = info->style;lv_font_t *font = dsc->font;font->user_data = dsc;font->get_glyph_dsc = get_glyph_dsc_cb;font->get_glyph_bitmap = get_glyph_bitmap_cb;font->line_height = (dsc->face->size->metrics.height >> 6);font->base_line = -(dsc->face->size->metrics.descender >> 6);font->subpx = LV_FONT_SUBPX_NONE;font->underline_position = dsc->face->underline_position;font->underline_thickness = dsc->face->underline_thickness;font->dsc = NULL;info->font = font;return true;Fail:lv_mem_free(dsc->font);lv_mem_free(dsc);return false;
}void lv_ft_font_destroy(lv_font_t* font)
{if (font == NULL) {return;}lv_font_fmt_ft_dsc_t * dsc = (lv_font_fmt_ft_dsc_t *)(font->user_data);if (dsc) {
#if LV_USE_FT_CACHE_MANAGER == 0FT_Done_Size(dsc->size);FT_Done_Face(dsc->face);
#elselv_face_info_t *face_info = (lv_face_info_t *)dsc->face->generic.data;face_info->cnt--;if(face_info->cnt == 0){FTC_Manager_RemoveFaceID(cache_manager, (FTC_FaceID)dsc->face);}
#endiflv_mem_free(dsc->font);lv_mem_free(dsc);}
}/***********************   STATIC FUNCTIONS**********************/
static void face_generic_finalizer(void* object)
{FT_Face face = (FT_Face)object;face_remove_from_list(face);if(face->generic.data){lv_face_info_t *face_info = (lv_face_info_t *)face->generic.data;lv_mem_free(face_info);}LV_LOG_INFO("face finalizer(%p)\n", face);
}static FT_Face face_find_in_list(lv_ft_info_t *info)
{lv_face_info_t *face_info;FT_Face *pface = _lv_ll_get_head(&face_control.face_ll);while(pface) {face_info = (lv_face_info_t *)(*pface)->generic.data;if (strcmp(face_info->name, info->name) == 0) {return *pface;}pface = _lv_ll_get_next(&face_control.face_ll, pface);}return NULL;
}static void face_add_to_list(FT_Face face)
{FT_Face *pface;pface = (FT_Face *)_lv_ll_ins_tail(&face_control.face_ll);*pface = face;face_control.cnt++;
}static void face_remove_from_list(FT_Face face)
{FT_Face *pface = _lv_ll_get_head(&face_control.face_ll);while(pface) {if (*pface == face) {_lv_ll_remove(&face_control.face_ll, pface);lv_mem_free(pface);face_control.cnt--;break;}pface = _lv_ll_get_next(&face_control.face_ll, pface);}
}#if LV_USE_FT_CACHE_MANAGERstatic FT_Error font_face_requester(FTC_FaceID face_id,FT_Library library_is,FT_Pointer req_data,FT_Face* aface)
{LV_UNUSED(library_is);LV_UNUSED(req_data);*aface = face_id;return FT_Err_Ok;
}static bool get_glyph_dsc_cb_cache(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next)
{LV_UNUSED(unicode_letter_next);if(unicode_letter < 0x20) {dsc_out->adv_w = 0;dsc_out->box_h = 0;dsc_out->box_w = 0;dsc_out->ofs_x = 0;dsc_out->ofs_y = 0;dsc_out->bpp = 0;return true;}lv_font_fmt_ft_dsc_t * dsc = (lv_font_fmt_ft_dsc_t *)(font->user_data);FT_Face face = dsc->face;static FTC_ImageTypeRec desc_sbit_type;desc_sbit_type.face_id = (FTC_FaceID)face;desc_sbit_type.flags = FT_LOAD_RENDER | FT_LOAD_TARGET_NORMAL;desc_sbit_type.height = dsc->weight;desc_sbit_type.width = dsc->weight;FT_UInt charmap_index = FT_Get_Charmap_Index(face->charmap);FT_UInt glyph_index = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)face, charmap_index, unicode_letter);FT_Error error = FTC_SBitCache_Lookup(sbit_cache, &desc_sbit_type, glyph_index, &sbit, NULL);dsc_out->adv_w = sbit->xadvance;dsc_out->box_h = sbit->height;  /*Height of the bitmap in [px]*/dsc_out->box_w = sbit->width;   /*Width of the bitmap in [px]*/dsc_out->ofs_x = sbit->left;    /*X offset of the bitmap in [pf]*/dsc_out->ofs_y = sbit->top - sbit->height; /*Y offset of the bitmap measured from the as line*/dsc_out->bpp = 8;               /*Bit per pixel: 1/2/4/8*/return true;
}static const uint8_t * get_glyph_bitmap_cb_cache(const lv_font_t * font, uint32_t unicode_letter)
{LV_UNUSED(font);LV_UNUSED(unicode_letter);return (const uint8_t *)sbit->buffer;
}#else/* LV_USE_FT_CACHE_MANAGER */static bool get_glyph_dsc_cb_nocache(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next)
{LV_UNUSED(unicode_letter_next);if(unicode_letter < 0x20) {dsc_out->adv_w = 0;dsc_out->box_h = 0;dsc_out->box_w = 0;dsc_out->ofs_x = 0;dsc_out->ofs_y = 0;dsc_out->bpp = 0;return true;}FT_Error error;FT_Face face;lv_font_fmt_ft_dsc_t * dsc = (lv_font_fmt_ft_dsc_t *)(font->user_data);face = dsc->face;FT_UInt glyph_index = FT_Get_Char_Index( face, unicode_letter );if (face->size != dsc->size) {FT_Activate_Size(dsc->size);}error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT );if (error){return false;}error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL);if (error){return false;}dsc_out->adv_w = (face->glyph->metrics.horiAdvance >> 6);dsc_out->box_h = face->glyph->bitmap.rows;         /*Height of the bitmap in [px]*/dsc_out->box_w = face->glyph->bitmap.width;         /*Width of the bitmap in [px]*/dsc_out->ofs_x = face->glyph->bitmap_left;         /*X offset of the bitmap in [pf]*/dsc_out->ofs_y = face->glyph->bitmap_top - face->glyph->bitmap.rows;         /*Y offset of the bitmap measured from the as line*/dsc_out->bpp = 8;         /*Bit per pixel: 1/2/4/8*/return true;
}static const uint8_t * get_glyph_bitmap_cb_nocache(const lv_font_t * font, uint32_t unicode_letter)
{LV_UNUSED(unicode_letter);lv_font_fmt_ft_dsc_t * dsc = (lv_font_fmt_ft_dsc_t *)(font->user_data);FT_Face face = dsc->face;return (const uint8_t *)(face->glyph->bitmap.buffer);
}#endif/* LV_USE_FT_CACHE_MANAGER */static bool get_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next)
{
#if LV_USE_FT_CACHE_MANAGERreturn get_glyph_dsc_cb_cache(font, dsc_out, unicode_letter, unicode_letter_next);
#elsereturn get_glyph_dsc_cb_nocache(font, dsc_out, unicode_letter, unicode_letter_next);
#endif
}static const uint8_t * get_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter)
{
#if LV_USE_FT_CACHE_MANAGERreturn get_glyph_bitmap_cb_cache(font, unicode_letter);
#elsereturn get_glyph_bitmap_cb_nocache(font, unicode_letter);
#endif
}

将整个文件夹lv_lib_freetype拷贝到LVGL的工程目录下,由于笔者这里单独建立了一个目录lv_lib,这里将lv_lib_freetype放到了lv_lib目录下

test@test:/home/work/lvgl_v711/Sigmastar202D$ls
build.sh  lonbon_app  lv_drivers     lv_examples   lv_fs_if  lv_lib  Makefile      module     test.png
library   lv_conf.h   lv_drv_conf.h  lv_ex_conf.h  lvgl      main.c  MicroHei.ttf  README.md
test@test:/home/work/lvgl_v711/Sigmastar202D$ ls lv_lib/
lv_lib_bmp  lv_lib_freetype  lv_lib_png  lv_lib_qrcode  lv_lib_split_jpg

然后将library目录中的头文件合并到lv_lib_freetype目录下,并在lv_lib_freetype下添加lv_lib_freetype.mk

test@test:/home/work/lvgl_v711/Sigmastar202D$ cd lv_lib/lv_lib_freetype/
test@test:/home/work/lvgl_v711/Sigmastar202D/lv_lib/lv_lib_freetype$ ls
freetype  ft2build.h  lv_freetype.c  lv_freetype.h  lv_lib_freetype.mk
test@test:/home/work/lvgl_v711/Sigmastar202D/lv_lib/lv_lib_freetype$ ls freetype/
config      ftbdf.h     ftchapters.h  fterrdef.h  ftglyph.h  ftincrem.h  ftmac.h     ftotval.h   ftrender.h  ftsynth.h   ftwinfnt.h  tttags.h
freetype.h  ftbitmap.h  ftcid.h       fterrors.h  ftgxval.h  ftlcdfil.h  ftmm.h      ftoutln.h   ftsizes.h   ftsystem.h  t1tables.h
ftadvanc.h  ftbzip2.h   ftcolor.h     ftfntfmt.h  ftgzip.h   ftlist.h    ftmodapi.h  ftparams.h  ftsnames.h  fttrigon.h  ttnameid.h
ftbbox.h    ftcache.h   ftdriver.h    ftgasp.h    ftimage.h  ftlzw.h     ftmoderr.h  ftpfr.h     ftstroke.h  fttypes.h   tttables.h
test@test:/home/work/lvgl_v711/Sigmastar202D/lv_lib/lv_lib_freetype$
#
# lv_lib_freetype.mk
#LV_LIB_FREETYPE_DIR_NAME ?= lv_lib_freetypeCSRCS += lv_freetype.c#添加依赖文件路径
DEPPATH += --dep-path $(LVGL_DIR)/lv_lib/$(LV_LIB_FREETYPE_DIR_NAME)#添加搜索路径
VPATH += :$(LVGL_DIR)/lv_lib/$(LV_LIB_FREETYPE_DIR_NAME)#添加头文件包含路径
CFLAGS += "-I$(LVGL_DIR)/lv_lib/$(LV_LIB_FREETYPE_DIR_NAME)"
CFLAGS += "-I$(LVGL_DIR)/lv_lib/$(LV_LIB_FREETYPE_DIR_NAME)/freetype"

然后回到LVGL工程目录,在Makefile文件中添加链接路径和链接库

include $(LVGL_DIR)/lv_lib/lv_lib_freetype/lv_lib_freetype.mkCFLAGS += -L./library
CFLAGS += -lfreetype

5、在mian.c中添加测试代码

void freetype_font_test()
{/* init freetype library */lv_freetype_init(64, 1, 0);/*Create a font*/lv_ft_info_t ft_info;ft_info.name = "./MicroHei.ttf";ft_info.weight = 90;ft_info.style = FT_FONT_STYLE_NORMAL;lv_ft_font_init(&ft_info);lv_ft_info_t ft_info1;ft_info1.name = "./MicroHei.ttf";ft_info1.weight = 40;ft_info1.style = FT_FONT_STYLE_NORMAL;lv_ft_font_init(&ft_info1);/*Create style with the new font*/static lv_style_t style;lv_style_init(&style);lv_style_set_text_font(&style, LV_STATE_DEFAULT, ft_info.font);static lv_style_t style1;lv_style_init(&style1);lv_style_set_text_font(&style1, LV_STATE_DEFAULT, ft_info1.font);/*Create a label with the new style*/lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);lv_obj_add_style(label, LV_LABEL_PART_MAIN, &style);lv_label_set_text(label, "Hello world 123456\n你好世界!");lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);lv_obj_add_style(label1, LV_LABEL_PART_MAIN, &style1);lv_label_set_text(label1, "世界你好");lv_obj_align(label1, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 200);
}

修改lv_conf.h将LV_USE_USER_DATA改成1

#define LV_USE_USER_DATA        1 //0

同时将library中的库文件拷到运行目录下的library目录中,运行效果如下:

参考文献:LVGL学习之路——基于lv_lib_freetype库的TTF字体文件动态加载中文字体

LVGL7.11中使用freetype库加载显示字体相关推荐

  1. Android Studio中RecycerView依赖库加载问题

    依赖包导入思考: 参考资料:recycleview导包问题 打开修改本项目中的build.gradle; 切勿着急添加包,应当提前查看其中的版本号(因为加载的v7包要和其版本保持一致性): 例如: 因 ...

  2. Winform DataGridView中利用WebClient异步加载显示网络地址的图片

    转载于:https://www.cnblogs.com/sjcatsoft/archive/2008/11/21/1338448.html

  3. Launcher3 安装App加载显示过程分析,androidstudio开发app实例

    "Initializing LauncherAppState in the absence of LauncherProvider"); } Log.v(Launcher.TAG, ...

  4. wps2019数据分析加载项_《07版office办公软件中的excle中,为什么在加载项里选择了分析工具库,数据分析还是显示不出来?》 wps数据分析加载项...

    如何利用excle做数据分析 excel完全可以解决! 可以通过数据透视表,筛选出你的各种需求,但是要求操作要熟练,没办法在这里描述清楚的 07版office办公软件中的excle中,为什么在加载项里 ...

  5. postgresql源码学习(57)—— pg中的四种动态库加载方法

    一. 基础知识 1. 什么是库 库其实就是一些通用代码,可以在程序中重复使用,比如一些数学函数,可以不需要自己编写,直接调用相关函数即可实现,避免重复造轮子. 在linux中,支持两种类型的库: 1. ...

  6. html字体库otf文件使用,在webpack中加载.otf字体文件的正确方法是什么?

    使用webpack时加载.otf字体文件的适当方式是什么?我曾多次尝试包括在我的webpack.config.js的规则,没有任何成功的基础上,很多例子我大致如下的线路看出:对于在webpack中加载 ...

  7. excel2007无法加载mysql_Excel2007中进行无法安装加载项的解决方法

    最近在学数学模型,用规划求解来计算.以前用Excel XP,知道在工具中加载相关的宏,然后很顺利地就能求解.但是用Excel 2007就找不到北了,今天,学习啦小编就教大家在Excel2007中进行无 ...

  8. 【Android 逆向】Android 进程注入工具开发 ( 远程进程注入动态库文件操作 | 注入动态库 加载 业务动态库 | 业务动态库启动 | pthread_create 线程开发 )

    文章目录 前言 一.加载 libnattive.so 动态库 二. libnattive.so 动态库启动 三. pthread_create 线程开发 四. 线程执行函数 前言 libbridge. ...

  9. 【Android NDK 开发】Android.mk 配置动态库 ( Android Studio 配置动态库 | 动态库加载版本限制 | 本章仅做参考推荐使用 CMake 配置动态库 )

    文章目录 I . Android Studio 中使用 Android.mk 配置动态库 总结 II . 第三方动态库来源 III . 配置 Android.mk 构建脚本路径 IV . 预编译 第三 ...

最新文章

  1. Python之并发编程
  2. Java类的基本运行顺序
  3. 【小米面试题】-给定一个具体时间,计算时针与分针之间的角度
  4. 图像分析demo android_10个JavaScript图像处理库,收藏好留备用
  5. leetcode python3 简单题217. Contains Duplicate
  6. 数据库学习--DCL(数据库控制语言)
  7. 重提URL Rewrite(4):不同级别URL Rewrite的一些细节与特点
  8. 南宁看桃花的季节是2月
  9. 安装使用TortoiseSVN + google code
  10. 遗传算法--适应度尺度变换
  11. 字符编码ASCII、ANSI、Unicode、UTF-8、GB2312
  12. 我的信念 -居里夫人
  13. 获取基金数据python库_PYTHON爬取基金数据及基金筛选
  14. Enzo Life Sciences/艾美捷丨线粒体/胞浆分离试剂盒
  15. 排列组合数学的相邻问题(插空法-捆绑法-隔板法)
  16. BP(back propagation)误差逆传播神经网络
  17. 交换机与路由器与猫的区别与联系
  18. 任正非文章:一江春水向东流
  19. html 整个页面只能看,如何截图整个完整的网页页面(包含滚动条下面看不到的网页)...
  20. 上位机UI界面设计项目

热门文章

  1. Gatsby中怎么使用emotion?
  2. iOS SDK制作脚本(a或framework)
  3. BZOJ 1128 [POI2008]Lam 高精度
  4. ACM - 贪心 - 基础(区间问题 + Huffman树 + 排序不等式 + 绝对值不等式 + 推公式)
  5. java三角形梯形和圆形类_java 三角形、梯形和圆形的类封装
  6. 什么是GHO和ISO
  7. iptables mangle使用
  8. Minecraft 服务器安装Forge 并添加Mod
  9. Linux sysfs文件系统
  10. 虚拟机VMware Workstation 7.1.4官方原版下载+激活密钥+汉化补丁