Re: Meson build, continued
> All right, here's the same set of patches with Black applied. The > differences are minor, except for the use of double-quotes instead > of single ones (I don't care personally). Thanks! Will check your stuff within the next few days. Werner
Re: Meson build, continued
> I'll tell Werner that black is better, speaking in my capacity of a > professional python font developer! I believe you :-) Werner
Re: Meson build, continued
>> Let's not clog the src folder please >> >> src/base/amiga (not src/amiga) >> src/base/unix (not src/unix) > > What about using a _.c suffix, as in: If at all I prefer a `-.c` suffix. Underlines are an abomination :-) > src/base/ftsystem_amiga.c > src/base/ftsystem_win32.c > etc.. > > We are no longer limited to 8.3 filenames, and I find this approach > makes it easy to spot source files which have platform-specific > variants. Mhmm. Honestly, I like `src/base//` more. Werner
Re: Meson build, continued
Le ven. 18 sept. 2020 à 16:22, Alexei Podtelezhnikov a écrit : > Let's not clog the src folder please > > src/base/amiga (not src/amiga) > src/base/unix (not src/unix) > > What about using a _.c suffix, as in: src/base/ftsystem_amiga.c src/base/ftsystem_win32.c etc.. We are no longer limited to 8.3 filenames, and I find this approach makes it easy to spot source files which have platform-specific variants. > > don't you think that all those (source) files should be in src/ ? I >> > would find these more logical. Maybe in subdirectories of src (like >> > src/unix src/mac src/windows etc...) > >
Re: compressed streams
On 9/18/20 5:30 AM, David Turner wrote: Is this also true for pcf.Z and pcf.bz2? I would like to warn about this in the docs. Yes, absolutely! Historically, these font files are legacy from X11 and no-one sane should be using these (there are TrueType equivalents for all of these as far as understand). X.Org has been slowly developing a tool to convert bdf fonts to ttf files instead of pcf files, but I don't know if any distros are really using it yet: https://gitlab.freedesktop.org/xorg/app/fonttosfnt And while I contributed the .bz2 support code from Solaris to X.Org years ago, we've also stopped shipping most .pcf files as compressed in Solaris as it wasn't saving enough space to be worthwhile, especially once we moved to compressing the install media & on-disk filesystems as a whole. -- -Alan Coopersmith- alan.coopersm...@oracle.com Oracle Solaris Engineering - https://blogs.oracle.com/alanc
Re: Meson build, continued
Let's not clog the src folder please src/base/amiga (not src/amiga) src/base/unix (not src/unix) > don't you think that all those (source) files should be in src/ ? I > > would find these more logical. Maybe in subdirectories of src (like > > src/unix src/mac src/windows etc...)
Re: Meson build, continued
> a quick find -name *.c gives files in src/ and also : > > ./builds/amiga/src/base/ftdebug.c > ./builds/amiga/src/base/ftsystem.c > ./builds/mac/ftmac.c > ./builds/unix/ftsystem.c > ./builds/vms/ftsystem.c > ./builds/wince/ftdebug.c > ./builds/windows/ftdebug.c > ./builds/windows/ftsystem.c > > don't you think that all those (source) files should be in src/ ? I > would find these more logical. Maybe in subdirectories of src (like > src/unix src/mac src/windows etc...) The latter is a nice idea. However, this is nothing urgent IMHO. On the other hand, if someone is going to provide a patch, I won't object :-) Werner
Re: Meson build, continued
Hello a quick find -name *.c gives files in src/ and also : ./builds/amiga/src/base/ftdebug.c ./builds/amiga/src/base/ftsystem.c ./builds/mac/ftmac.c ./builds/unix/ftsystem.c ./builds/vms/ftsystem.c ./builds/wince/ftdebug.c ./builds/windows/ftdebug.c ./builds/windows/ftsystem.c don't you think that all those (source) files should be in src/ ? I would find these more logical. Maybe in subdirectories of src (like src/unix src/mac src/windows etc...) thank you Vincent Torri On Fri, Sep 18, 2020 at 3:03 PM David Turner wrote: > > All right, here's the same set of patches with Black applied. The differences > are minor, except for the use of double-quotes instead of single ones (I > don't care personally). > I'll let Werner choose which set is better :-) > > > > Le ven. 18 sept. 2020 à 14:54, Nikolaus Waxweiler a > écrit : >>> >>> PS: This introduces several python scripts, I have been using the "yapf" >>> tool to format them. If you know of a better python reformatter, let me >>> know. >> >> >> Black It's the best
Re: Meson build, continued
I'll tell Werner that black is better, speaking in my capacity of a professional python font developer! @Werner: see above Ps: thanks for doing meson work! Can't wait to see all other build systems be dropped!
Re: Meson build, continued
All right, here's the same set of patches with Black applied. The differences are minor, except for the use of double-quotes instead of single ones (I don't care personally). I'll let Werner choose which set is better :-) Le ven. 18 sept. 2020 à 14:54, Nikolaus Waxweiler a écrit : > PS: This introduces several python scripts, I have been using the "yapf" >> tool to format them. If you know of a better python reformatter, let me >> know. >> > > Black It's the best > >> From 8dcb5c0789a8065947eb66d08ceae730b6afae87 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 25 Aug 2020 20:52:32 +0200 Subject: [build] Add scripts/make_distribution_archives.py This standalone Python script should be equivalent to running "make dist" with the Make-based build system, with the following minor differences: - Since 'make distclean' doesn't always cleanup objs/ properly, the 'make dist' archives may contain some stale binaries like objs/.libs/libfreetype.so.6 or others. - The config.guess and config.sub files are not update, unless one uses the --gnu-config-dir=DIR option to specify were they are located. - Some bits of the auto-generated reference documentation may appear in slightly different order, probably due to issues related to mkdocs and docwriter. Usage example: scripts/make_distribution_archives.py /tmp/freetype2-dist Will create files the following files under /tmp/freetype2-dist: freetype-.tar.gz freetype-.tar.xz ft.zip --- scripts/make_distribution_archives.py | 188 ++ 1 file changed, 188 insertions(+) create mode 100755 scripts/make_distribution_archives.py diff --git a/scripts/make_distribution_archives.py b/scripts/make_distribution_archives.py new file mode 100755 index 0..cf2bb544f --- /dev/null +++ b/scripts/make_distribution_archives.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python3 +"""Generate distribution archives for a given FreeType 2 release.""" + +from __future__ import print_function + +import argparse +import atexit +import os +import shutil +import subprocess +import sys +import tempfile + +_SCRIPT_DIR = os.path.dirname(__file__) +_TOP_DIR = os.path.abspath(os.path.join(_SCRIPT_DIR, "..")) + + +def get_cmd_output(cmd, cwd=None): +"""Run a command and return its output as a string.""" +if cwd is not None: +out = subprocess.check_output(cmd, cwd=cwd) +else: +out = subprocess.check_output(cmd) +return out.decode("utf-8").rstrip() + + +def is_git_dir_clean(git_dir): +"""Return True iff |git_dir| is a git directory in clean state.""" +out = get_cmd_output(["git", "status", "--porcelain"], cwd=git_dir) +return len(out) == 0 + + +def main(): +parser = argparse.ArgumentParser(description=__doc__) + +parser.add_argument("--source_dir", default=_TOP_DIR, help="Source directory path.") + +parser.add_argument( +"--version", +help="Specify alternate FreeType version (it is otherwise extracted from " +"current sources by default).", +) + +parser.add_argument( +"--gnu-config-dir", +help=( +"Path of input directory containing recent `config.guess` and " +"`config.sub` files from GNU config." +), +) + +parser.add_argument( +"--build-dir", +help="Specify build directory. Only used for debugging this script.", +) + +parser.add_argument( +"--ignore-clean-check", +action="store_true", +help="Do not check for a clean source git repository. Only used for " +"debugging this script.", +) + +parser.add_argument("output_dir", help="Output directory for generated archives.") + +args = parser.parse_args() + +git_dir = args.source_dir if args.source_dir else _TOP_DIR +if not args.ignore_clean_check and not is_git_dir_clean(git_dir): +sys.stderr.write( +"ERROR: Your git repository is not in a clean state: %s\n" % git_dir +) +return 1 + +if args.version: +version = args.version +else: +# Extract FreeType version from sources. +version = get_cmd_output( +[ +sys.executable, +os.path.join(_SCRIPT_DIR, "extract_freetype_version.py"), +os.path.join(_TOP_DIR, "include", "freetype", "freetype.h"), +] +) + +# Determine the build directory. This will be a temporary file that is +# cleaned up on script exit by default, unless --build-dir=DIR is used, +# in which case we only create and empty the directory, but never remove +# its content on exit. +if args.build_dir: +build_dir = args.build_dir +if not os.path.exists(build_dir): +os.makedirs(build_dir) +else: +# Remove anything from the build directory, if any. +for item in os.listdir(build_dir): +file_path = os.path.join(build_dir, item) +
Re: Meson build, continued
> > PS: This introduces several python scripts, I have been using the "yapf" > tool to format them. If you know of a better python reformatter, let me > know. > Black It's the best >
Re: compressed streams
Le ven. 18 sept. 2020 à 14:18, Alexei Podtelezhnikov a écrit : > > > On Fri, Sep 18, 2020 at 7:18 AM David Turner wrote: > >> Le jeu. 17 sept. 2020 à 14:01, Werner LEMBERG a écrit : >> >>> > These are some horrible numbers that essentially test FT_Load_Glyph >>> > from compressed unifont.pcf.gz in reverse order: [...] >>> >>> We do, there is no "rewinding the compressed stream", we have to restart >> from the first byte of the file everytime we need to go back in the file. >> > [...] >> So in theory, something like that could be added. It's just seems a lot >> of complexity for little practical benefits imho. >> > > Is this also true for pcf.Z and pcf.bz2? I would like to warn about this > in the docs. > > Yes, absolutely! Historically, these font files are legacy from X11 and no-one sane should be using these (there are TrueType equivalents for all of these as far as understand).
Meson build, continued
Hello Here's my latest version of the Meson build support files for FreeType 2. It works! Compared to the previous versions, there are several improvements: - The generated binaries are now the same size as the ones from the GNU Make and CMake builds. - The installed shared libraries have the proper libtool-compatible suffix, and the generated pkg-config file is now using the correct FreeType version, paths and other settings. - The "docs" target will generate the documentation properly, except that this will go into $BUILD_DIR/docs/ instead of $SRC_DIR/docs/, since Meson doesn't support modifying the source tree (a good thing in my opinion). I'd like to see this submitted to the tree, and I'll keep updating it as needed. See the commit message for instructions on how to build and install with Meson. There is also a second patch that adds a new scripts/make_distribution_archives.py script. it essentially does the same thing as "make dist", but doesn't rely on GNU Make / CMake / Meson in any way. I think it's a better way to generate our distribution archives and a good way to transition to a different build system overall. Let me know what you think about these. - Digit PS: This introduces several python scripts, I have been using the "yapf" tool to format them. If you know of a better python reformatter, let me know. From 45017badeade312778b7e0107873e9649ff52e34 Mon Sep 17 00:00:00 2001 From: David Turner Date: Sun, 17 May 2020 18:45:41 +0200 Subject: [build] Add Meson build project files. This adds a few files to build the FreeType 2 library with the Meson build system: - meson.build: top-level Meson build file for the library. - meson_options.txt: user-selectable options for the build. These can be printed with 'meson configure', and selected as 'meson setup' or 'meson --reconfigure' time with -D=. - scripts/parse_modules_cfg.py: A script invoked by meson.build to parse modules.cfg and extract important information out of it (i.e. the list of modules). - scripts/process_ftoption_h.py: A script invoked by meson.build to process the original ftoption.h and enable or disabled configuration macro variables based on the available dependencies. This is similar to what other build systems are using (i.e. Meson configure_file() is not used here). - scripts/extract_freetype_version.py: A script invoked by meson.build to extract the FreeType version number from - scripts/extract_libtool_version.py: A script invoked by meson.build to extract the libtool revision_info from builds/unix/configure.raw and generate the corresponding shared library suffix. - scripts/generate_reference_docs.py: A script invoked by meson.build to generate the FreeType 2 reference documentation (using the docwriter / mkdocs packages which must be installed previously). Example usage: # Configure Meson build to generate release binaries comparable to # to the ones from the autotools/make build system. meson setup build-meson --prefix=/ --buildtype=debugoptimized --strip -Db_ndebug=true # Build and install to /tmp/aa/, this includes a pkg-config file. DESTDIR=/tmp/aa ninja -C build-meson install # Generate documentation under build-meson/docs ninja -C build-meson docs Library size comparison for stripped libfreetype.so generated by all three build systems: - Default build (autotools + libtool): 712 KiB - CMake build (RelWithDebInfo):712 KiB - Meson build: 712 KiB --- builds/unix/ftsystem.c | 2 +- meson.build | 346 meson_options.txt | 6 + scripts/extract_freetype_version.py | 101 scripts/extract_libtool_version.py | 96 scripts/generate_reference_docs.py | 63 + scripts/parse_modules_cfg.py| 141 scripts/process_ftoption_h.py | 97 8 files changed, 851 insertions(+), 1 deletion(-) create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 scripts/extract_freetype_version.py create mode 100644 scripts/extract_libtool_version.py create mode 100644 scripts/generate_reference_docs.py create mode 100644 scripts/parse_modules_cfg.py create mode 100644 scripts/process_ftoption_h.py diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c index 8437a6689..b4d71d40e 100644 --- a/builds/unix/ftsystem.c +++ b/builds/unix/ftsystem.c @@ -18,7 +18,7 @@ #include /* we use our special ftconfig.h file, not the standard one */ -#include +#include FT_CONFIG_CONFIG_H #include #include #include diff --git a/meson.build b/meson.build new file mode 100644 index 0..1d8f2672c --- /dev/null +++ b/meson.build @@ -0,0 +1,346 @@ +# Meson project file for FreeType 2 + +project('freetype2', 'c', default_options: ['default_library=both']) + +# +# Rules to compile the FreeType 2 library itself +# + +# Apparently meson doesn't provide a read_file()
Re: compressed streams
On Fri, Sep 18, 2020 at 7:18 AM David Turner wrote: > Le jeu. 17 sept. 2020 à 14:01, Werner LEMBERG a écrit : > >> > These are some horrible numbers that essentially test FT_Load_Glyph >> > from compressed unifont.pcf.gz in reverse order: [...] >> >> We do, there is no "rewinding the compressed stream", we have to restart > from the first byte of the file everytime we need to go back in the file. > [...] > So in theory, something like that could be added. It's just seems a lot of > complexity for little practical benefits imho. > Is this also true for pcf.Z and pcf.bz2? I would like to warn about this in the docs.
Re: cmake patch
Le jeu. 17 sept. 2020 à 15:42, Alexei Podtelezhnikov a écrit : > > Patch attached for avoid adding lib prefix when compiling with mingw and > also letting to use FT_CONFIG_OPTION_ERROR_STRINGS from cmake command line. > > The lib prefix is your personal aversion. It depends. There is value for the CMake build to generate the same-named library as the regular GNU Make-based one for example. And the former does generate something called "freetype.dll" or "freetype.lib" This is not limited to Mingw but to all Win32 builds, so I would be in favor to change the default for this platform. However, I don't know if this is going to disrupt developers (we never officially supported the CMake build as far as I know, so it may not matter though). Thoughts? > Would this work for the second wish? > cmake -D PUBLIC=FT_CONFIG_OPTION_ERROR_STRINGS or something > > I'd rather see this feature added as an option than a special case in the CMakeLists.txt file. E.g. FT_WITH_ERROR_STRINGS for example (similar to FT_WITH_XXX options currently supported). After all, there is nothing specific to Mingw here. - David
Re: compressed streams
Le jeu. 17 sept. 2020 à 14:01, Werner LEMBERG a écrit : > > > These are some horrible numbers that essentially test FT_Load_Glyph > > from compressed unifont.pcf.gz in reverse order: [...] > > > > real0m6.062s > > > > The same string forward is much faster: [...] > > > > real0m0.486s > > Ouch. > > > Is it well known that rewinding the compressed stream is so > > prohibitively expensive? Or, is this a bug? > > I don't know, sorry. The basic question is, I guess, whether we are > correctly using the gzip interface ... > > We do, there is no "rewinding the compressed stream", we have to restart from the first byte of the file everytime we need to go back in the file. We just didn't implement some sort of caching or state checkpointing in the gzip decoder because this kind of font is legacy and has better alternatives now (see https://packages.debian.org/fr/sid/xfonts-unifont vs https://packages.debian.org/fr/sid/fonts-unifont for Debian).. But in case one would really want to support this, it is possible to improve random access in gzip stream by essentially storing the state of the deflate decoder at various points of the input file. For a practical example, see: https://github.com/madler/zlib/blob/2fa463bacfff79181df1a5270fb67cc679a53e71/examples/zran.c So in theory, something like that could be added. It's just seems a lot of complexity for little practical benefits imho. - David > > Werner > >