From 3c08a69aedd719c9f351321fff6b8d2042ea7887 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Thu, 16 Feb 2023 15:32:28 +0100 Subject: [PATCH] initial commit with apothecary lib script --- .gitignore | 50 +++++++++ addon_config.mk | 64 +++++++++++ scripts/formulas/msdf-atlas-gen.sh | 175 +++++++++++++++++++++++++++++ 3 files changed, 289 insertions(+) create mode 100644 .gitignore create mode 100644 addon_config.mk create mode 100644 scripts/formulas/msdf-atlas-gen.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2f92a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# don't push project files +*.cbp +*.sln +*.vcx* +*.workspace* +config.make +Makefile +*.xcodeproj +*.plist +*.xcconfig +*.suo + +*.depend +*.layout +*.mode*v3 +*.pbxuser +*.app* +*.DS_* +*.xcworkspacedata +xcuserdata/ +project.xcworkspace + +*.opensdf +*.sdf +*.suo +*.ipch + +.svn/ +obj/ +bin/ +build/ +!data/ + +.cache +.ccls-cache + +# don't push backup files/directories +*.bk + +# vim +*.swp +*.swo + +# qtcreator +*.qbs +*.qbs.user +build-* + +scripts/linux/ci/opencv_docker/shared +libs/opencv4 diff --git a/addon_config.mk b/addon_config.mk new file mode 100644 index 0000000..26352fc --- /dev/null +++ b/addon_config.mk @@ -0,0 +1,64 @@ +# All variables and this file are optional, if they are not present the PG and the +# makefiles will try to parse the correct values from the file system. +# +# Variables that specify exclusions can use % as a wildcard to specify that anything in +# that position will match. A partial path can also be specified to, for example, exclude +# a whole folder from the parsed paths from the file system +# +# Variables can be specified using = or += +# = will clear the contents of that variable both specified from the file or the ones parsed +# from the file system +# += will add the values to the previous ones in the file or the ones parsed from the file +# system +# +# The PG can be used to detect errors in this file, just create a new project with this addon +# and the PG will write to the console the kind of error and in which line it is + +meta: + ADDON_NAME = ofxMsdfgen + ADDON_DESCRIPTION = Multi-Channel Signed Distance Field Font Drawing + ADDON_AUTHOR = Jakob Schloetter + ADDON_TAGS = "typography" + ADDON_URL = https://gitlab.com/pointerstudio/utils/ofxMsdfgen + +common: + # dependencies with other addons, a list of them separated by spaces + # or use += in several lines + # ADDON_DEPENDENCIES = + + # include search paths, this will be usually parsed from the file system + # but if the addon or addon libraries need special search paths they can be + # specified here separated by spaces or one per line using += + # ADDON_INCLUDES = + + # any special flag that should be passed to the compiler when using this + # addon + # ADDON_CFLAGS = + + # any special flag that should be passed to the linker when using this + # addon, also used for system libraries with -lname + # ADDON_LDFLAGS = + + # linux only, any library that should be included in the project using + # pkg-config + # ADDON_PKG_CONFIG_LIBRARIES = + + # osx/iOS only, any framework that should be included in the project + # ADDON_FRAMEWORKS = + + # source files, these will be usually parsed from the file system looking + # in the src folders in libs and the root of the addon. if your addon needs + # to include files in different places or a different set of files per platform + # they can be specified here + # ADDON_SOURCES = + + # some addons need resources to be copied to the bin/data folder of the project + # specify here any files that need to be copied, you can use wildcards like * and ? + # ADDON_DATA = + + # when parsing the file system looking for libraries exclude this for all or + # a specific platform + # ADDON_LIBS_EXCLUDE = + +linux64: + ADDON_CFLAGS = -Ilibs/serial/include diff --git a/scripts/formulas/msdf-atlas-gen.sh b/scripts/formulas/msdf-atlas-gen.sh new file mode 100644 index 0000000..36e37a2 --- /dev/null +++ b/scripts/formulas/msdf-atlas-gen.sh @@ -0,0 +1,175 @@ +#! /bin/bash +# +# Multi-channel signed distance field atlas generator +# This is a utility for generating compact font atlases using MSDFgen. +# +# The atlas generator loads a subset of glyphs from a TTF or OTF font file, +# generates a distance field for each of them, and tightly packs them into +# an atlas bitmap (example below). The finished atlas and/or its layout +# metadata can be exported as an Artery Font file, a plain image file, +# a CSV sheet or a structured JSON file. +# https://github.com/Chlumsky/msdf-atlas-gen +# +# it uses cmake build system, and depends on msdfgen (also downloaded) +# +# linux notes: +# should you not have libtinyxml2-dev installed with cmake files +# check with for example (Debian, Ubuntu): dpkg -L libtinyxml2-dev +# if cmake files are present +# +# if not then install libtinyxml2 from https://github.com/leethomason/tinyxml2.git +# +# for example: +# $ cd your/favorite/persistent/build/directory +# $ git clone https://github.com/leethomason/tinyxml2.git +# $ cd tinyxml2 +# $ mkdir build && cd build +# $ cmake .. +# $ make +# $ sudo make install +# +# emscripten notes: +# additionally to the depencies below +# you may have to build freetype from source +# and with that also bzip2 +# $ +# $ # tinyxml2: +# $ cd your/favorite/persistent/build/directory +# $ git clone https://github.com/leethomason/tinyxml2.git +# $ cd tinyxml2 +# $ mkdir build && cd build +# $ emcmake cmake .. +# $ emmake make +# $ emmake make install +# $ +# $ # zlib: +# $ cd your/favorite/persistent/build/directory +# $ wget https://www.zlib.net/zlib-1.2.13.tar.gz +# $ tar -xf zlib-1.2.13.tar.gz +# $ cd zlib-1.2.13.tar.gz +# $ mkdir build && cd build +# $ emcmake cmake .. +# $ emmake make +# $ emmake make install +# $ +# $ # libpng: +# $ cd your/favorite/persistent/build/directory +# $ wget https://sourceforge.net/projects/libpng/files/libpng16/1.6.39/libpng-1.6.39.tar.xz/download -O libpng-1.6.39.tar.xz +# $ tar -xf libpng-1.6.39.tar.xz +# $ cd libpng-1.6.39 +# $ mkdir build && cd build +# $ emcmake cmake .. +# $ emmake make +# $ emmake make install + + +# array of build types supported by this formula +# you can delete this to implicitly support *all* types +FORMULA_TYPES=( "osx" "linux" "linux64" "vs" "msys2" "ios" "android" "emscripten" ) + +# define the version +VER=1.2.2 + +# tools for git use +GIT_URL=https://github.com/Chlumsky/msdf-atlas-gen.git +GIT_TAG="v${VER}" + +# download the source code and unpack it into LIB_NAME +function download() { + echo "download msdf-atlas-gen" + wget --quiet https://pointer.click/files/msdf-atlas-gen.tar.gz -O msdf-atlas-gen.tar.gz + mkdir -p msdf-atlas-gen + tar -xzf msdf-atlas-gen.tar.gz -C msdf-atlas-gen --strip-components=1 + rm msdf-atlas-gen.tar.gz +} + +# prepare the build environment, executed inside the lib src dir +function prepare() { + mkdir -p lib/$TYPE +} + +# executed inside the lib src dir +function build() { + if [ "$TYPE" == "linux64" ] ; then + cd lib/$TYPE + cmake \ + -DMSDF_ATLAS_BUILD_STANDALONE=OFF \ + -DMSDF_ATLAS_USE_VCPKG=OFF \ + -DMSDF_ATLAS_USE_SKIA=OFF \ + -DMSDF_ATLAS_NO_ARTERY_FONT=OFF \ + -DMSDF_ATLAS_MSDFGEN_EXTERNAL=OFF \ + -DMSDF_ATLAS_INSTALL=OFF \ + -DMSDF_ATLAS_DYNAMIC_RUNTIME=OFF \ + -DBUILD_SHARED_LIBS=OFF \ + -DMSDFGEN_CORE_ONLY=OFF \ + -DMSDFGEN_BUILD_STANDALONE=OFF \ + -DMSDFGEN_USE_VCPKG=OFF \ + -DMSDFGEN_USE_OPENMP=OFF \ + -DMSDFGEN_USE_CPP11=ON \ + -DMSDFGEN_USE_SKIA=OFF \ + -DMSDFGEN_INSTALL=OFF \ + -DMSDFGEN_DYNAMIC_RUNTIME=OFF \ + ../.. + make + elif [ "$TYPE" == "emscripten" ] ; then + cd lib/$TYPE + emcmake cmake \ + -DMSDF_ATLAS_BUILD_STANDALONE=OFF \ + -DMSDF_ATLAS_USE_VCPKG=OFF \ + -DMSDF_ATLAS_USE_SKIA=OFF \ + -DMSDF_ATLAS_NO_ARTERY_FONT=OFF \ + -DMSDF_ATLAS_MSDFGEN_EXTERNAL=OFF \ + -DMSDF_ATLAS_INSTALL=OFF \ + -DMSDF_ATLAS_DYNAMIC_RUNTIME=OFF \ + -DBUILD_SHARED_LIBS=OFF \ + -DMSDFGEN_CORE_ONLY=OFF \ + -DMSDFGEN_BUILD_STANDALONE=OFF \ + -DMSDFGEN_USE_VCPKG=OFF \ + -DMSDFGEN_USE_OPENMP=OFF \ + -DMSDFGEN_USE_CPP11=ON \ + -DMSDFGEN_USE_SKIA=OFF \ + -DMSDFGEN_INSTALL=OFF \ + -DMSDFGEN_DYNAMIC_RUNTIME=OFF \ + ../.. + emmake make + else + echoWarning "TODO: $TYPE build" + fi +} + +# executed inside the lib src dir, first arg $1 is the dest libs dir root +function copy() { + if [ "$TYPE" == "linux64" ] || [ "$TYPE" == "emscripten" ] ; then + # lib + cd lib/$TYPE + dest_lib=$1/lib/$TYPE + mkdir -p $dest_lib + find . -iname "*.a" -exec cp {} $dest_lib/ \; + + # include + cd ../.. + dest_include=$1/include + mkdir -p $dest_include + cp LICENSE.txt $dest_include/ + cp ./*.h $dest_include/ + cp -r artery-font-format $dest_include/ + cp -r msdfgen $dest_include/ + rm -rf $dest_include/msdfgen/cmake + cp -r msdf-atlas-gen $dest_include/ + else + echoWarning "TODO: $TYPE copy" + fi +} + +# executed inside the lib src dir +function clean() { + if [ "$TYPE" == "linux64" ] ; then + cd lib/$TYPE + make clean + elif [ "$TYPE" == "emscripten" ] ; then + cd lib/$TYPE + emmake make clean + else + echoWarning "TODO: $TYPE clean" + fi +}