Rewrite ttf2c to use GNU Unifont and merge with pngchar2c.pl.
After this change, SolveSpace does not contain nonfree assets. Additionally, Perl is not required for the build. Note that in the US, case law suggests that copyright does not apply to bitmap fonts: http://www.renpy.org/wiki/renpy/misc/Bitmap_Fonts_and_Copyright Nevertheless, it was prudent to replace the asset with something that is unambiguously free.pull/4/head
|
@ -3,7 +3,7 @@ os:
|
||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
install:
|
install:
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:smspillaz/cmake-master; sudo add-apt-repository -y ppa:ondrej/php5; sudo apt-get update -qq; sudo apt-get install -q -y cmake cmake-data libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev libgtkmm-2.4-dev libpangomm-1.4-dev libgl1-mesa-dev libglu-dev libglew-dev libgd-gd2-perl dpkg-dev; fi
|
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:smspillaz/cmake-master; sudo add-apt-repository -y ppa:ondrej/php5; sudo apt-get update -qq; sudo apt-get install -q -y cmake cmake-data libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev libgtkmm-2.4-dev libpangomm-1.4-dev libgl1-mesa-dev libglu-dev libglew-dev dpkg-dev; fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew upgrade cmake libpng; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew upgrade cmake libpng; fi
|
||||||
script:
|
script:
|
||||||
- mkdir cbuild
|
- mkdir cbuild
|
||||||
|
|
|
@ -21,11 +21,6 @@ project(solvespace)
|
||||||
set(solvespace_VERSION_MAJOR 2)
|
set(solvespace_VERSION_MAJOR 2)
|
||||||
set(solvespace_VERSION_MINOR 1)
|
set(solvespace_VERSION_MINOR 1)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
# ttf2c takes 10 minutes (!) on Appveyor CI
|
|
||||||
set(DISABLE_TTF2C CACHE BOOL "Disable font regeneration with ttf2c, for use on CI")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT WIN32 AND NOT APPLE)
|
if(NOT WIN32 AND NOT APPLE)
|
||||||
set(GUI gtk2 CACHE STRING "GUI toolkit to use (one of: gtk2 gtk3)")
|
set(GUI gtk2 CACHE STRING "GUI toolkit to use (one of: gtk2 gtk3)")
|
||||||
endif()
|
endif()
|
||||||
|
@ -67,12 +62,6 @@ CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
find_package(Perl)
|
|
||||||
find_package(PerlModules COMPONENTS GD)
|
|
||||||
if(NOT (PERL_FOUND AND PERLMODULES_FOUND))
|
|
||||||
message(STATUS "Perl with GD not found; icons will not be regenerated if modified")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
find_package(ZLIB)
|
find_package(ZLIB)
|
||||||
|
|
||||||
|
@ -122,6 +111,7 @@ else() # Linux and compatible systems
|
||||||
|
|
||||||
# Use freedesktop's pkg-config to locate everything.
|
# Use freedesktop's pkg-config to locate everything.
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(ZLIB REQUIRED zlib)
|
||||||
pkg_check_modules(PNG REQUIRED libpng)
|
pkg_check_modules(PNG REQUIRED libpng)
|
||||||
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
|
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
|
||||||
pkg_check_modules(JSONC REQUIRED json-c)
|
pkg_check_modules(JSONC REQUIRED json-c)
|
||||||
|
|
|
@ -3,7 +3,7 @@ before_build:
|
||||||
- git submodule update --init
|
- git submodule update --init
|
||||||
- mkdir cbuild
|
- mkdir cbuild
|
||||||
- cd cbuild
|
- cd cbuild
|
||||||
- cmake -DDISABLE_TTF2C=ON -G"Visual Studio 12" -T v120_xp ..
|
- cmake -G"Visual Studio 12" -T v120_xp ..
|
||||||
build:
|
build:
|
||||||
project: C:\projects\solvespace\cbuild\src\solvespace.vcxproj
|
project: C:\projects\solvespace\cbuild\src\solvespace.vcxproj
|
||||||
verbosity: minimal
|
verbosity: minimal
|
||||||
|
|
|
@ -1,77 +0,0 @@
|
||||||
# - try to find perl modules, passed as COMPONENTS
|
|
||||||
#
|
|
||||||
# Non-cache variable you might use in your CMakeLists.txt:
|
|
||||||
# PERLMODULES_FOUND
|
|
||||||
#
|
|
||||||
# Requires these CMake modules:
|
|
||||||
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
|
||||||
#
|
|
||||||
# Original Author:
|
|
||||||
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
|
||||||
# http://academic.cleardefinition.com
|
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
|
||||||
#
|
|
||||||
# Copyright Iowa State University 2012.
|
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
if(NOT PERL_FOUND)
|
|
||||||
find_package(Perl QUIET)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(_deps_check)
|
|
||||||
if(PERL_FOUND)
|
|
||||||
foreach(module ${PerlModules_FIND_COMPONENTS})
|
|
||||||
string(REPLACE "::" "/" modfilename "${module}.pm")
|
|
||||||
string(REPLACE "::" "_" modvarname "PERLMODULES_${module}_MODULE")
|
|
||||||
string(TOUPPER "${modvarname}" modvarname)
|
|
||||||
list(APPEND _deps_check ${modvarname})
|
|
||||||
if(NOT ${modvarname})
|
|
||||||
if(NOT PerlModules_FIND_QUIETLY)
|
|
||||||
message(STATUS "Checking for perl module ${module}")
|
|
||||||
endif()
|
|
||||||
execute_process(COMMAND
|
|
||||||
"${PERL_EXECUTABLE}"
|
|
||||||
"-e"
|
|
||||||
"use ${module}; print \$INC{\"${modfilename}\"}"
|
|
||||||
RESULT_VARIABLE result_code
|
|
||||||
OUTPUT_VARIABLE filename
|
|
||||||
ERROR_VARIABLE error_info
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
if(result_code EQUAL 0)
|
|
||||||
if(NOT PerlModules_FIND_QUIETLY)
|
|
||||||
message(STATUS
|
|
||||||
"Checking for perl module ${module} - found at ${filename}")
|
|
||||||
endif()
|
|
||||||
set(${modvarname}
|
|
||||||
"${filename}"
|
|
||||||
CACHE
|
|
||||||
FILEPATH
|
|
||||||
"Location found for module ${module}"
|
|
||||||
FORCE)
|
|
||||||
mark_as_advanced(${modvarname})
|
|
||||||
else()
|
|
||||||
if(NOT PerlModules_FIND_QUIETLY)
|
|
||||||
message(STATUS "Checking for perl module ${module} - failed")
|
|
||||||
endif()
|
|
||||||
set(${modvarname}
|
|
||||||
"NOTFOUND"
|
|
||||||
CACHE
|
|
||||||
FILEPATH
|
|
||||||
"No location found for module ${module}"
|
|
||||||
FORCE)
|
|
||||||
file(APPEND
|
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
|
||||||
"Determining if the Perl module ${module} exists failed with the following error output:\n"
|
|
||||||
"${error_info}\n\n")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(PerlModules
|
|
||||||
DEFAULT_MSG
|
|
||||||
PERL_FOUND
|
|
||||||
${_deps_check})
|
|
|
@ -4,8 +4,7 @@ Priority: optional
|
||||||
Maintainer: whitequark <whitequark@whitequark.org>
|
Maintainer: whitequark <whitequark@whitequark.org>
|
||||||
Build-Depends: debhelper (>= 9), cmake, libpng12-dev, zlib1g-dev, libjson-c-dev,
|
Build-Depends: debhelper (>= 9), cmake, libpng12-dev, zlib1g-dev, libjson-c-dev,
|
||||||
libfontconfig1-dev, libgtkmm-2.4-dev, libpangomm-1.4-dev,
|
libfontconfig1-dev, libgtkmm-2.4-dev, libpangomm-1.4-dev,
|
||||||
libgl-dev, libglu-dev, libglew-dev,
|
libgl-dev, libglu-dev, libglew-dev
|
||||||
libgd-gd2-perl
|
|
||||||
Standards-Version: 3.9.5
|
Standards-Version: 3.9.5
|
||||||
Homepage: http://solvespace.com
|
Homepage: http://solvespace.com
|
||||||
Vcs-Git: git://github.com/whitequark/solvespace
|
Vcs-Git: git://github.com/whitequark/solvespace
|
||||||
|
|
|
@ -84,8 +84,9 @@ endif()
|
||||||
# but unlike Windows, Linux does not have the machinery to map
|
# but unlike Windows, Linux does not have the machinery to map
|
||||||
# an invocation of `tool` to an executable `tool.exe` in $PATH.
|
# an invocation of `tool` to an executable `tool.exe` in $PATH.
|
||||||
|
|
||||||
file(GLOB icons "${CMAKE_CURRENT_SOURCE_DIR}/icons/*.png")
|
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||||
|
|
||||||
|
file(GLOB icons "${CMAKE_CURRENT_SOURCE_DIR}/icons/*.png")
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/icons.cpp"
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/icons.cpp"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/generated/icons.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/generated/icons.h"
|
||||||
|
@ -95,33 +96,23 @@ add_custom_command(
|
||||||
${icons}
|
${icons}
|
||||||
DEPENDS png2c ${icons})
|
DEPENDS png2c ${icons})
|
||||||
|
|
||||||
if(PERL_FOUND AND PERLMODULES_FOUND)
|
file(GLOB chars "${CMAKE_CURRENT_SOURCE_DIR}/fonts/private/*.png")
|
||||||
|
list(SORT chars)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/built/bitmapextra.table.h"
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/bitmapfont.table.h"
|
||||||
COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/pngchar2c.pl"
|
COMMAND $<TARGET_FILE:unifont2c>
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/built/bitmapextra.table.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/generated/bitmapfont.table.h"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
"${CMAKE_CURRENT_SOURCE_DIR}/fonts/unifont-8.0.01.hex.gz"
|
||||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/pngchar2c.pl"
|
${chars}
|
||||||
DEPENDS ${icons})
|
DEPENDS unifont2c ${chars})
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32 AND NOT DISABLE_TTF2C)
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/built/bitmapfont.table.h"
|
|
||||||
COMMAND ttf2c "${CMAKE_CURRENT_SOURCE_DIR}/built/bitmapfont.table.h")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(generated_HEADERS
|
set(generated_HEADERS
|
||||||
built/bitmapextra.table.h
|
${CMAKE_CURRENT_BINARY_DIR}/generated/bitmapfont.table.h
|
||||||
built/bitmapfont.table.h
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated/icons.h)
|
${CMAKE_CURRENT_BINARY_DIR}/generated/icons.h)
|
||||||
|
|
||||||
set(generated_SOURCES
|
set(generated_SOURCES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated/icons.cpp)
|
${CMAKE_CURRENT_BINARY_DIR}/generated/icons.cpp)
|
||||||
|
|
||||||
set_source_files_properties(${generated_HEADERS}
|
|
||||||
PROPERTIES GENERATED TRUE)
|
|
||||||
|
|
||||||
# platform dependencies
|
# platform dependencies
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
/**** This is a generated file - do not edit ****/
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
|
||||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0,
|
|
||||||
0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0,
|
|
||||||
0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0,
|
|
||||||
0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0,
|
|
||||||
0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 0,
|
|
||||||
0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0,
|
|
||||||
0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0,
|
|
||||||
0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
|
|
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 218 B |
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 228 B |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
|
@ -11,7 +11,7 @@ namespace SolveSpace {
|
||||||
#include "font.table.h"
|
#include "font.table.h"
|
||||||
|
|
||||||
// A bitmap font.
|
// A bitmap font.
|
||||||
#include "bitmapfont.table.h"
|
#include "generated/bitmapfont.table.h"
|
||||||
|
|
||||||
static bool ColorLocked;
|
static bool ColorLocked;
|
||||||
static bool DepthOffsetLocked;
|
static bool DepthOffsetLocked;
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
#!/usr/bin/env perl
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
use GD;
|
|
||||||
|
|
||||||
my ($out, $srcdir) = @ARGV;
|
|
||||||
defined($srcdir) or $srcdir = '.';
|
|
||||||
-d "$srcdir/icons" || die "$srcdir/icons/: directory not found";
|
|
||||||
|
|
||||||
open(OUT, ">$out") or die "$out: $!";
|
|
||||||
|
|
||||||
print OUT "/**** This is a generated file - do not edit ****/\n\n";
|
|
||||||
|
|
||||||
for my $file (sort <$srcdir/icons/char-*.png>) {
|
|
||||||
open(PNG, $file) or die "$file: $!\n";
|
|
||||||
my $img = newFromPng GD::Image(\*PNG) or die;
|
|
||||||
$img->trueColor(1);
|
|
||||||
close PNG;
|
|
||||||
|
|
||||||
my ($width, $height) = $img->getBounds();
|
|
||||||
die "$file: $width, $height" if ($width != 16) or ($height != 16);
|
|
||||||
|
|
||||||
for(my $x = 0; $x < 16; $x++) {
|
|
||||||
for(my $y = 0; $y < 16; $y++) {
|
|
||||||
my $index = $img->getPixel($x, $y);
|
|
||||||
my ($r, $g, $b) = $img->rgb($index);
|
|
||||||
if($r + $g + $b < 11) {
|
|
||||||
print OUT " 0, ";
|
|
||||||
} else {
|
|
||||||
print OUT "255, ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print OUT "\n";
|
|
||||||
}
|
|
||||||
print OUT "\n";
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,16 +4,14 @@ include_directories(
|
||||||
link_directories(
|
link_directories(
|
||||||
${PNG_LIBRARY_DIRS})
|
${PNG_LIBRARY_DIRS})
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
add_executable(ttf2c
|
|
||||||
ttf2c.cpp)
|
|
||||||
|
|
||||||
target_link_libraries(ttf2c
|
|
||||||
comctl32)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(png2c
|
add_executable(png2c
|
||||||
png2c.cpp)
|
png2c.cpp)
|
||||||
|
|
||||||
target_link_libraries(png2c
|
target_link_libraries(png2c
|
||||||
${PNG_LIBRARIES})
|
${PNG_LIBRARIES})
|
||||||
|
|
||||||
|
add_executable(unifont2c
|
||||||
|
unifont2c.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(unifont2c
|
||||||
|
${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
|
||||||
|
|
|
@ -94,9 +94,6 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
for(int i = 3; i < argc; i++) {
|
for(int i = 3; i < argc; i++) {
|
||||||
const char *filename = argv[i];
|
const char *filename = argv[i];
|
||||||
if(strstr(filename, "char-"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const char *basename = strrchr(filename, '/'); /* cmake uses / even on Windows */
|
const char *basename = strrchr(filename, '/'); /* cmake uses / even on Windows */
|
||||||
if(basename == NULL) {
|
if(basename == NULL) {
|
||||||
basename = filename;
|
basename = filename;
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Entry point into the program.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
if(argc != 2) {
|
|
||||||
fprintf(stderr, "usage: ttf2c [output]");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitCommonControls();
|
|
||||||
|
|
||||||
// A monospaced font
|
|
||||||
HFONT font = CreateFont(16, 9, 0, 0, FW_REGULAR, false,
|
|
||||||
false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
|
||||||
DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console");
|
|
||||||
|
|
||||||
HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
|
|
||||||
HBITMAP bitmap = CreateCompatibleBitmap(hdc, 30, 30);
|
|
||||||
|
|
||||||
SelectObject(hdc, bitmap);
|
|
||||||
SelectObject(hdc, font);
|
|
||||||
|
|
||||||
FILE* out = fopen(argv[1], "w");
|
|
||||||
if(!out) {
|
|
||||||
fprintf(stderr, "cannot open output file %s", argv[1]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(out, "static const uint8_t FontTexture[256*16*16] = {\n");
|
|
||||||
|
|
||||||
int c;
|
|
||||||
for(c = 0; c < 128; c++) {
|
|
||||||
|
|
||||||
RECT r;
|
|
||||||
r.left = 0; r.top = 0;
|
|
||||||
r.right = 30; r.bottom = 30;
|
|
||||||
FillRect(hdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));
|
|
||||||
|
|
||||||
SetBkColor(hdc, RGB(0, 0, 0));
|
|
||||||
SetTextColor(hdc, RGB(255, 255, 255));
|
|
||||||
char str[2] = { c, 0 };
|
|
||||||
TextOut(hdc, 0, 0, str, 1);
|
|
||||||
|
|
||||||
int i, j;
|
|
||||||
for(i = 0; i < 16; i++) {
|
|
||||||
for(j = 0; j < 16; j++) {
|
|
||||||
COLORREF c = GetPixel(hdc, i, j);
|
|
||||||
fprintf(out, "%3d, ", c ? 255 : 0);
|
|
||||||
}
|
|
||||||
fprintf(out, "\n");
|
|
||||||
}
|
|
||||||
fprintf(out, "\n");
|
|
||||||
}
|
|
||||||
fprintf(out, "#include \"bitmapextra.table.h\"\n");
|
|
||||||
fprintf(out, "};\n");
|
|
||||||
|
|
||||||
fclose(out);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -0,0 +1,178 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
#include <png.h>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#define die(msg) do { fprintf(stderr, "%s\n", msg); abort(); } while(0)
|
||||||
|
|
||||||
|
unsigned short* read_png(const char *filename) {
|
||||||
|
FILE *fp = fopen(filename, "rb");
|
||||||
|
if (!fp)
|
||||||
|
die("png fopen failed");
|
||||||
|
|
||||||
|
png_byte header[8] = {};
|
||||||
|
if(fread(header, 1, 8, fp) != 8)
|
||||||
|
die("png fread failed");
|
||||||
|
|
||||||
|
if(png_sig_cmp(header, 0, 8))
|
||||||
|
die("png_sig_cmp failed");
|
||||||
|
|
||||||
|
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
|
if(!png)
|
||||||
|
die("png_create_read_struct failed");
|
||||||
|
|
||||||
|
png_set_expand(png);
|
||||||
|
png_set_strip_alpha(png);
|
||||||
|
|
||||||
|
png_infop png_info = png_create_info_struct(png);
|
||||||
|
if (!png_info)
|
||||||
|
die("png_create_info_struct failed");
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png)))
|
||||||
|
die("png_init_io failed");
|
||||||
|
|
||||||
|
png_init_io(png, fp);
|
||||||
|
png_set_sig_bytes(png, 8);
|
||||||
|
|
||||||
|
png_read_info(png, png_info);
|
||||||
|
|
||||||
|
int width = png_get_image_width(png, png_info);
|
||||||
|
int height = png_get_image_height(png, png_info);
|
||||||
|
if(width != 16 || height != 16)
|
||||||
|
die("not a 16x16 png");
|
||||||
|
|
||||||
|
png_read_update_info(png, png_info);
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png)))
|
||||||
|
die("png_read_image failed");
|
||||||
|
|
||||||
|
png_bytepp image = (png_bytepp) malloc(sizeof(png_bytep) * height);
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
image[y] = (png_bytep) malloc(png_get_rowbytes(png, png_info));
|
||||||
|
|
||||||
|
png_read_image(png, (png_bytepp) image);
|
||||||
|
|
||||||
|
unsigned short *glyph = (unsigned short *) calloc(16, 2);
|
||||||
|
|
||||||
|
for(int y = 0; y < height; y++) {
|
||||||
|
for(int x = 0; x < (int)png_get_rowbytes(png, png_info); x += 3) {
|
||||||
|
unsigned char r = image[y][x + 0],
|
||||||
|
g = image[y][x + 1],
|
||||||
|
b = image[y][x + 2];
|
||||||
|
|
||||||
|
if(r + g + b >= 11) {
|
||||||
|
int pos = y * width + (width - x / 3);
|
||||||
|
glyph[pos / 16] |= 1 << (pos % 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
free(image[y]);
|
||||||
|
free(image);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return glyph;
|
||||||
|
}
|
||||||
|
|
||||||
|
const static unsigned short replacement[16] = {
|
||||||
|
0xAAAA, 0xAAAA, 0xAAAA, 0xAAAA,
|
||||||
|
0xAAAA, 0xAAAA, 0xAAAA, 0xAAAA,
|
||||||
|
0xAAAA, 0xAAAA, 0xAAAA, 0xAAAA,
|
||||||
|
0xAAAA, 0xAAAA, 0xAAAA, 0xAAAA,
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
if(argc < 3) {
|
||||||
|
fprintf(stderr, "Usage: %s <header/source out> <unifont.hex> <png glyph>...\n"
|
||||||
|
" where <png glyph>s are mapped into private use area\n"
|
||||||
|
" starting at U+0080.\n",
|
||||||
|
argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short *font[256] = {};
|
||||||
|
|
||||||
|
const int private_start = 0x80, private_count = argc - 3;
|
||||||
|
for(int i = 3; i < argc; i++) {
|
||||||
|
font[private_start + i - 3] = read_png(argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
gzFile unifont = gzopen(argv[2], "rb");
|
||||||
|
if(!unifont)
|
||||||
|
die("unifont fopen failed");
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
unsigned short codepoint;
|
||||||
|
unsigned short *glyph = (unsigned short *) calloc(32, 1);
|
||||||
|
|
||||||
|
char buf[100];
|
||||||
|
if(!gzgets(unifont, buf, sizeof(buf))){
|
||||||
|
if(gzeof(unifont)) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
die("unifont gzgets failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( sscanf(buf, "%4hx:%4hx%4hx%4hx%4hx%4hx%4hx%4hx%4hx"
|
||||||
|
"%4hx%4hx%4hx%4hx%4hx%4hx%4hx%4hx\n",
|
||||||
|
&codepoint,
|
||||||
|
&glyph[0], &glyph[1], &glyph[2], &glyph[3],
|
||||||
|
&glyph[4], &glyph[5], &glyph[6], &glyph[7],
|
||||||
|
&glyph[8], &glyph[9], &glyph[10], &glyph[11],
|
||||||
|
&glyph[12], &glyph[13], &glyph[14], &glyph[15]) == 17) {
|
||||||
|
/* read 16x16 character */
|
||||||
|
} else if(sscanf(buf, "%4hx:%2hx%2hx%2hx%2hx%2hx%2hx%2hx%2hx"
|
||||||
|
"%2hx%2hx%2hx%2hx%2hx%2hx%2hx%2hx\n",
|
||||||
|
&codepoint,
|
||||||
|
&glyph[0], &glyph[1], &glyph[2], &glyph[3],
|
||||||
|
&glyph[4], &glyph[5], &glyph[6], &glyph[7],
|
||||||
|
&glyph[8], &glyph[9], &glyph[10], &glyph[11],
|
||||||
|
&glyph[12], &glyph[13], &glyph[14], &glyph[15]) == 17) {
|
||||||
|
/* read 8x16 character */
|
||||||
|
for(int i = 0; i < 16; i++)
|
||||||
|
glyph[i] <<= 8;
|
||||||
|
} else {
|
||||||
|
die("parse unifont character");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(codepoint >= 0x00 && codepoint < 0x80) {
|
||||||
|
font[codepoint] = glyph;
|
||||||
|
} else {
|
||||||
|
free(glyph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gzclose(unifont);
|
||||||
|
|
||||||
|
FILE *source = fopen(argv[1], "wt");
|
||||||
|
if(!source)
|
||||||
|
die("source fopen failed");
|
||||||
|
|
||||||
|
fprintf(source, "/**** This is a generated file - do not edit ****/\n\n");
|
||||||
|
fprintf(source, "static const unsigned char FontTexture[256 * 16 * 16] = {\n");
|
||||||
|
|
||||||
|
for(int codepoint = 0; codepoint < 0x100; codepoint++) {
|
||||||
|
const unsigned short *glyph = font[codepoint] != NULL ? font[codepoint] : replacement;
|
||||||
|
for(int x = 15; x >= 0; x--) {
|
||||||
|
for(int y = 0; y < 16; y++) {
|
||||||
|
int pos = y * 16 + x;
|
||||||
|
if(glyph[pos / 16] & (1 << (pos % 16))) {
|
||||||
|
fprintf(source, "255, ");
|
||||||
|
} else {
|
||||||
|
fprintf(source, " 0, ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(source, "\n");
|
||||||
|
}
|
||||||
|
fprintf(source, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(source, "};\n");
|
||||||
|
|
||||||
|
fclose(source);
|
||||||
|
}
|