HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
LINK
BACK
 

2018/07/21

Raspberry Piで FontForge フォントアプリをソースリストからビルドする方法 Raspberry Piで FontForge フォントアプリをソースリストからビルドする方法

(ラズパイに FontForge フォントアプリをソースリストからビルドする方法)

Tags: [Raspberry Pi], [電子工作]





● Raspberry Pi 3 Model Bを遂に購入

 Raspberry Pi3 Model B RPI2 RPI3

 大人気の CPUボードの Raspberry Piに WiFiと Bluetoothが搭載されたモデルが新発売となりました。
 以前から Raspberry Pi 2を買おうかどうか迷っていましたが、Raspberry Pi 3 Model Bの発売を機に購入を決意してラズベリアンになる事にしました。

 ※ ラズパイの OS Raspbianはバージョンが上がる毎に過去の版と OSの内部の作りが変わり、過去に書かれた製作記事(例えば Raspbian Wheezyの時代の記事)がそのままではエラーが出たりして動かない事が有ります。
 ※ 当方のホームページのラズパイ記事は全て Raspberry Pi 3 Model Bと Raspbian Jessieの組み合わせで動作確認をしております。
(ただし、将来的に新しい Raspbian OSが出た場合に、当方の Raspbian Jessieを基にした内容がそのままでは動かない可能性が有ります。)
 ※ 2017/08/16から Raspbian OSは Raspbian Jessieから Raspbian Stretchに変わりました。
 ※ 2019/06/20から Raspbian OSは Raspbian Stretchから Raspbian Busterに変わりました。

Download Raspbian for Raspberry Pi

ちなみに、歴代のバージョンと名称は
Debianコードネーム年月備考(参考)Ubuntuでの該当名称
Debian 11Bullseye2021/08/14~2021/11からラズパイにリリースFocal Fossa 20.04 LTS ?
Debian 10Buster2019/06/20~2019/06からラズパイ4対応Bionic 18.04 LTS
Debian 9Stretch2017/08/16~2018/03からラズパイ3B+対応Xenial 16.04 LTS
Debian 8Jessie2015~2016/02からラズパイ3対応Trusty 14.04 LTS
Debian 7Wheezy2013~2016
Debian 6.0Squeeze2011~2014
Debian GNU/Linux 5.0Lenny2009~2012


● Raspberry Piに Fontforge

fontforge/fontforge
 Free (libre) font editor for Windows, Mac OS X and GNU+Linux http://fontforge.github.io/

# Installing FontForge from Git Source Code

# Installing FontForge from Git Source Code
sudo apt-get update

# Clone a copy of the Github source repository:
cd
mkdir -p ~/src/github.com/fontforge
cd ~/src/github.com/fontforge
git clone https://github.com/fontforge/fontforge.git

# To download all dependencies on Debian Jessie, run:
sudo apt-get -y install autotools-dev libjpeg-dev libtiff5-dev libpng-dev libgif-dev libxt-dev libfreetype6-dev autoconf automake libtool libltdl7-dev libxml2-dev libuninameslist-dev libspiro-dev python-dev libpango1.0-dev libcairo2-dev chrpath

# Install the unifont package to get a full display of the reference glyphs.
sudo apt-get -y install unifont

# FontForge uses libspiro to simplify the drawing of curves. Download and install the latest code like this:
git clone https://github.com/fontforge/libspiro.git
cd libspiro
autoreconf -i
automake --foreign -Wall
./configure
make
sudo make install
cd ..

# Build libuninameslist
git clone https://github.com/fontforge/libuninameslist.git
cd libuninameslist
autoreconf -i
automake --foreign
./configure
make
sudo make install
cd ..

# Now run the build and installation scripts, and ensure you can open shared object files:
cd fontforge;
./bootstrap;
./configure;
make;
sudo make install;
sudo ldconfig;
cd ..

You may need to use the following Makefile variables when linking.
Use them in <program>_LDADD when linking a program, or
in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.
  $(GETHOSTNAME_LIB)
  $(INET_NTOP_LIB)
  $(LIBSOCKET)
  $(LTLIBICONV) when linking with libtool, $(LIBICONV) otherwise
  $(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise

Don't forget to
  - add "lib/Makefile" to AC_CONFIG_FILES in ./configure.ac,
  - mention "lib" in SUBDIRS in Makefile.am,
  - mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am,
  - mention "m4/gnulib-cache.m4" in EXTRA_DIST in Makefile.am,
  - invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC_C99,
  - invoke gl_INIT in ./configure.ac.
Copying file compile
Copying file install-sh
Copying file mdate-sh
Copying file texinfo.tex
Copying file depcomp
Copying file config.guess
Copying file config.sub
Copying file INSTALL

pi@raspberrypi:~/src/github.com/fontforge/fontforge $ fontforge -version
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 01:22 UTC 25-Jul-2018-ML-D.
 Based on source from git with hash: e688b8c4dc634dcc128709f84b98f2407294f3fb
fontforge 01:22 UTC 25-Jul-2018
libfontforge 20180725

pi@raspberrypi:~/src/github.com/fontforge/fontforge $ fontforge
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 01:22 UTC 25-Jul-2018-ML-D.
 Based on source from git with hash: e688b8c4dc634dcc128709f84b98f2407294f3fb
Could not open screen.

pi@raspberrypi:~/src/github.com/fontforge/fontforge $ fontforge -help
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 01:22 UTC 25-Jul-2018-ML-D.
 Based on source from git with hash: e688b8c4dc634dcc128709f84b98f2407294f3fb
fontforge [options] [fontfiles]
        -new                     (creates a new font)
        -last                    (loads the last sfd file closed)
        -recover none|auto|inquire|clean (control error recovery)
        -allglyphs               (load all glyphs in the 'glyf' table
                         of a truetype collection)
        -nosplash                (no splash screen)
        -quiet                   (don't print non-essential information to stderr)
        -unique                  (if a fontforge is already running open
                         all arguments in it and have this process exit)
        -display display-name    (sets the X display)
        -depth val               (sets the display depth if possible)
        -vc val                  (sets the visual class if possible)
        -cmap current|copy|private       (sets the type of colormap)
        -dontopenxdevices        (in case that fails)
        -sync                    (syncs the display, debugging)
        -keyboard ibm|mac|sun|ppc  (generates appropriate hotkeys in menus)
        -usecairo=yes|no  Use (or not) the cairo library for drawing
        -help                    (displays this message, and exits)
        -docs                    (displays this message, invokes a browser)
                                 (Using the BROWSER environment variable)
        -version                 (prints the version of fontforge and exits)
        -library-status  (prints information about optional libraries
                                 and exits)
        -lang=py                 use python for scripts (may precede -script)
        -lang=ff                 use fontforge's legacy scripting language
        -script scriptfile       (executes scriptfile)
                must be the first option (or follow -lang).
                All others passed to scriptfile.
        -dry scriptfile          (syntax checks scriptfile)
                must be the first option. All others passed to scriptfile.
                Only for fontforge's own scripting language, not python.
        -c script-string         (executes argument as scripting cmds)
                must be the first option. All others passed to the script.

FontForge will read postscript (pfa, pfb, ps, cid), opentype (otf),
        truetype (ttf,ttc), macintosh resource fonts (dfont,bin,hqx),
        and bdf and pcf fonts. It will also read its own format --
        sfd files.
If no fontfiles are specified (and -new is not either and there's nothing
        to recover) then fontforge will produce an open font dlg.
If a scriptfile is specified then FontForge will not open the X display
        nor will it process any additional arguments. It will execute the
        scriptfile and give it any remaining arguments
If the first argument is an executable filename, and that file's first
        line contains "fontforge" then it will be treated as a scriptfile.

For more information see:
        http://fontforge.sourceforge.net/
Send bug reports to:    fontforge-devel@lists.sourceforge.net


● Raspberry Piに Fontforge --without-xでコマンドライン専用版

cd fontforge;
./bootstrap;
./configure \
  --without-x
make;
sudo make install;
sudo ldconfig;
cd ..

pi@raspberrypi:~/src/github.com/fontforge $ fontforge
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 02:48 UTC 25-Jul-2018-D.
 Based on source from git with hash: e688b8c4dc634dcc128709f84b98f2407294f3fb
>>>
>>> help
Type help() for interactive help, or help(object) for help about object.
>>> help()

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> quit

You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)".  Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
>>> quit()

pi@raspberrypi:~/src/github.com/fontforge $ fontforge
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 02:48 UTC 25-Jul-2018-D.
 Based on source from git with hash: e688b8c4dc634dcc128709f84b98f2407294f3fb
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>>


● Raspberry Piに FontForge CidMap

# cidmapファイル
# https://fontforge.github.io/ja/cidmapformat.html

# CIDのマッピングデータをダウンロードする
cd
wget http://fontforge.sourceforge.net/cidmaps.tgz
tar xvfz cidmaps.tgz

# /usr/share/fontforge/ディレクトリに .cidmapファイルをコピーする
ls -l /usr/share/fontforge/
sudo mv -f Adobe-*.cidmap /usr/share/fontforge/
ls -l /usr/share/fontforge/

# -rw-r--r-- 1 pi   pi   192427 Mar  5  2008 Adobe-CNS1-5.cidmap
# -rw-r--r-- 1 pi   pi   165024 Mar  5  2008 Adobe-GB1-5.cidmap
# -rw-r--r-- 1 pi   pi       23 Sep 10  2005 Adobe-Identity-0.cidmap
# -rw-r--r-- 1 pi   pi   188474 Sep 10  2005 Adobe-Japan1-6.cidmap
# -rw-r--r-- 1 pi   pi    48677 Sep 10  2005 Adobe-Japan2-0.cidmap
# -rw-r--r-- 1 pi   pi   102776 Sep 10  2005 Adobe-Korea1-2.cidmap


● Raspberry Piに sudo apt-get install fontforge

pi@raspberrypi:~ $ sudo apt-get install fontforge
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  fontforge-common fonts-cantarell fonts-inconsolata libfontforge2 libgdraw5
  libspiro0 libuninameslist1
Suggested packages:
  autotrace fontforge-doc fontforge-extras potrace python-fontforge
The following NEW packages will be installed:
  fontforge fontforge-common fonts-cantarell fonts-inconsolata libfontforge2
  libgdraw5 libspiro0 libuninameslist1
0 upgraded, 8 newly installed, 0 to remove and 44 not upgraded.
Need to get 4,605 kB of archives.
After this operation, 17.7 MB of additional disk space will be used.

pi@raspberrypi:~ $ ls -l /usr/bin/fontforge
-rwxr-xr-x 1 root root 5612 Aug 12  2017 /usr/bin/fontforge

pi@raspberrypi:~ $ fontforge
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 20170812-ML-D.
 Based on source from git with hash:
no xdefs_filename!
TESTING: getPixmapDir:/usr/share/fontforge/pixmaps
TESTING: getShareDir:/usr/share/fontforge
TESTING: GResourceProgramDir:/usr/bin
trying default theme:/usr/share/fontforge/pixmaps/resources
Could not open screen.

pi@raspberrypi:~ $ fontforge -version
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 20170812-ML-D.
 Based on source from git with hash:
no xdefs_filename!
TESTING: getPixmapDir:/usr/share/fontforge/pixmaps
TESTING: getShareDir:/usr/share/fontforge
TESTING: GResourceProgramDir:/usr/bin
trying default theme:/usr/share/fontforge/pixmaps/resources
fontforge 20170812
libfontforge 20170812



● Fontforgeのスクリプト言語で OTF形式を TTF形式に変換

FontForge でフォントを変更するためのスクリプトの書き方

FontForge スクリプト関数一覧

$em はフォントが使用する em ユニットの大きさを返します。
$ascent はフォントの高さを返します。
$descent はフォントの深さを返します。


nano hoge.sh
chmod +x hoge.sh

hoge.sh
#!/usr/bin/fontforge

Open($1);
CIDFlatten();
Print("$em " + $em);
Print("$ascent " + $ascent);
Print("$descent " + $descent);
ScaleToEm(1024);
Print("ScaleToEm(1024);");
Print("$em " + $em);
Print("$ascent " + $ascent);
Print("$descent " + $descent);
Generate($1:r + ".ttf");
Quit(0);

pi@raspberrypi:~ $ ls -l sample.*
-rw-r--r-- 1 pi pi  9351276 Feb 21  2018 sample.otf

pi@raspberrypi:~ $ ./hoge.sh sample.otf
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 20170812-ML-D.
 Based on source from git with hash:
The following table(s) in the font have been ignored by FontForge
  Ignoring 'VORG' vertical origin table
Warning: Mac string is a subset of the Windows string in the 'name' table
  for the Family string in the English (US) language.
Warning: Mac string is a subset of the Windows string in the 'name' table
  for the Styles (SubFamily) string in the English (US) language.
Warning: Mac and Windows entries in the 'name' table differ for the
  Fullname string in the language English (US)
  Mac String: SAMPLESAMPLESAMPLESAMPLE XXX R
  Windows String: SAMPLESAMPLESAMPLEXXX-R
Warning: Mac string is a subset of the Windows string in the 'name' table
  for the Designer string in the English (US) language.
Warning: Mac string is a subset of the Windows string in the 'name' table
  for the Family string in the Japanese language.
Warning: Mac string is a subset of the Windows string in the 'name' table
  for the Styles (SubFamily) string in the Japanese language.
$em 1000
$ascent 880
$descent 120
ScaleToEm(1024);
$em 1024
$ascent 901
$descent 123

pi@raspberrypi:~ $ ls -l sample.*
-rw-r--r-- 1 pi pi  9351276 Feb 21  2018 sample.otf
-rw-r--r-- 1 pi pi 10708168 Jul 30 13:31 sample.ttf


● Raspberry Piに FreeType

The FreeType Project
 FreeType is a freely available software library to render fonts.

FreeType Downloads

# NG 2.9.1
# wget http://download.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz
# tar zxvf freetype-2.9.1.tar.gz

# OK 2.6.5
cd
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.6.5.tar.gz
tar xvfz freetype-2.6.5.tar.gz

cd ./freetype-2.6.5
./bootstrap
./configure --enable-freetype-debugger=freetype-2.6.5/
make
sudo make install

Common Problems
If you can not install due to problems with Python, run ./configure line like this (paths may vary):

PYTHON_CFLAGS="-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7"
PYTHON_LIBS="-L/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config"

./configure \
  --disable-programs \
  --disable-native-scripting \
  --without-x \
  --without-cairo \
  --without-giflib \
  --without-libjpeg \
  --without-libtiff \
  --without-libpng \
  --without-libspiro \
  --without-libuninameslist \
  --without-libunicodenames \
  --without-iconv \
  --without-libzmq \
  --without-libreadline \
  --enable-python-scripting \
  --enable-python-extension;



Tags: [Raspberry Pi], [電子工作]



[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c) 2018 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_fontforge_build/