update packages and add valign
This commit is contained in:
@@ -95,10 +95,12 @@ exec_privileged() {
|
||||
retval=$?
|
||||
sudo -k
|
||||
return $retval
|
||||
elif which doas >/dev/null 2>&1; then
|
||||
doas -- "$@"
|
||||
elif which su >/dev/null 2>&1; then
|
||||
su -c "$(quote "$@")"
|
||||
else
|
||||
echo "No such program: sudo or su"
|
||||
echo "No such program: sudo, doas or su"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -306,6 +308,26 @@ os_debian() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Android using Termux
|
||||
os_android() {
|
||||
if ! [ -d "/data/data/com.termux/files/home" ]; then
|
||||
return 1
|
||||
fi
|
||||
PACKAGES="autoconf
|
||||
automake
|
||||
binutils
|
||||
clang
|
||||
libpng
|
||||
poppler
|
||||
zlib
|
||||
make
|
||||
xorgproto
|
||||
pkg-config"
|
||||
PKGCMD=pkg
|
||||
PKGARGS="install"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Msys2
|
||||
os_msys2() {
|
||||
if [ -z "$MSYSTEM" ] || ! [ -r "/etc/profile" ]; then
|
||||
@@ -332,6 +354,16 @@ os_msys2() {
|
||||
mingw-w64-i686-toolchain
|
||||
mingw-w64-i686-openssl
|
||||
mingw-w64-i686-zlib" ;;
|
||||
UCRT64)
|
||||
PACKAGES="base-devel
|
||||
autoconf
|
||||
automake
|
||||
mingw-w64-ucrt-x86_64-libpng
|
||||
mingw-w64-ucrt-x86_64-poppler
|
||||
mingw-w64-ucrt-x86_64-imagemagick
|
||||
mingw-w64-ucrt-x86_64-toolchain
|
||||
mingw-w64-ucrt-x86_64-openssl
|
||||
mingw-w64-ucrt-x86_64-zlib" ;;
|
||||
MSYS)
|
||||
case $(uname -m) in
|
||||
x86_64)
|
||||
@@ -348,7 +380,7 @@ os_msys2() {
|
||||
exit 1 ;;
|
||||
esac
|
||||
PKGCMD=pacman
|
||||
PKGARGS="-S --needed"
|
||||
PKGARGS="-S --needed --noconfirm"
|
||||
PKG_INSTALL_AS_ROOT=
|
||||
return 0
|
||||
}
|
||||
@@ -367,7 +399,7 @@ os_macos() {
|
||||
# explanation has to do with 'keg-only' installs). If you do,
|
||||
# please update:
|
||||
# https://github.com/vedang/pdf-tools/issues/270
|
||||
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$(brew --prefix libffi)/lib/pkgconfig/:$(brew --prefix zlib)/lib/pkgconfig/:$(brew --prefix glib)/lib/pkgconfig/"
|
||||
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$(brew --prefix poppler)/lib/pkgconfig/:$(brew --prefix libffi)/lib/pkgconfig/:$(brew --prefix zlib)/lib/pkgconfig/:$(brew --prefix glib)/lib/pkgconfig/:$(brew --prefix pcre2)/lib/pkgconfig/"
|
||||
elif which port >/dev/null 2>&1; then
|
||||
PKGCMD=port
|
||||
PKGARGS=install
|
||||
@@ -493,6 +525,30 @@ os_alpine() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Nobara
|
||||
os_nobara() {
|
||||
if ! [ -e "/etc/nobara-release" ]; then
|
||||
return 1
|
||||
fi
|
||||
PKGCMD=dnf
|
||||
PKGARGS=install
|
||||
PACKAGES="autoconf
|
||||
automake
|
||||
gcc
|
||||
libpng-devel
|
||||
make
|
||||
poppler-devel
|
||||
poppler-glib-devel
|
||||
zlib-devel"
|
||||
VERSION=$(source_var /etc/os-release VERSION_ID)
|
||||
if [ -n "$VERSION" ] && [ "$VERSION" -ge 26 ]; then
|
||||
PACKAGES="$PACKAGES pkgconf"
|
||||
else
|
||||
PACKAGES="$PACKAGES pkgconfig"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# By Parameter --os
|
||||
os_argument() {
|
||||
[ -z "$OS" ] && return 1
|
||||
@@ -511,6 +567,8 @@ os_argument() {
|
||||
void) os_void "$@";;
|
||||
opensuse) os_opensuse "$@";;
|
||||
alpine) os_alpine "$@";;
|
||||
nobara) os_nobara "$@";;
|
||||
android) os_android "$@";;
|
||||
*) echo "Invalid --os argument: $OS"
|
||||
exit 1
|
||||
esac || {
|
||||
@@ -541,6 +599,8 @@ os_nixos "$@" || \
|
||||
os_void "$@" || \
|
||||
os_opensuse "$@" || \
|
||||
os_alpine "$@" || \
|
||||
os_nobara "$@" || \
|
||||
os_android "$@" || \
|
||||
{
|
||||
OS_IS_HANDLED=
|
||||
if [ -z "$DRY_RUN" ]; then
|
||||
|
||||
2
lisp/pdf-tools/build/server/autobuild.android
Executable file
2
lisp/pdf-tools/build/server/autobuild.android
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
sh autobuild "$@"
|
||||
@@ -36,7 +36,7 @@ AC_COMPILE_IFELSE(
|
||||
AM_CONDITIONAL(HAVE_W32, [test "$have_w32" = true])
|
||||
|
||||
if test "$have_w32" = true; then
|
||||
if test "$MSYSTEM" = MINGW32 -o "$MSYSTEM" = MINGW64; then
|
||||
if test "$MSYSTEM" = MINGW32 -o "$MSYSTEM" = MINGW64 -o "$MSYSTEM" = UCRT64; then
|
||||
# glib won't work properly on msys2 without it.
|
||||
CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $CFLAGS"
|
||||
fi
|
||||
@@ -84,7 +84,7 @@ AC_C_BIGENDIAN
|
||||
# Checks for library functions.
|
||||
AC_FUNC_ERROR_AT_LINE
|
||||
AC_FUNC_STRTOD
|
||||
AC_CHECK_FUNCS([strcspn strtol getline])
|
||||
AC_CHECK_FUNCS([strcspn strtol getline _tempnam])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -346,12 +346,13 @@ strchomp (char *str)
|
||||
static char*
|
||||
mktempfile()
|
||||
{
|
||||
#if defined (HAVE__TEMPNAM)
|
||||
char *filename = NULL;
|
||||
int tries = 3;
|
||||
while (! filename && tries-- > 0)
|
||||
{
|
||||
|
||||
filename = tempnam(NULL, "epdfinfo");
|
||||
filename = _tempnam(NULL, "epdfinfo");
|
||||
if (filename)
|
||||
{
|
||||
int fd = open(filename, O_CREAT | O_EXCL | O_RDONLY, S_IRUSR | S_IWUSR);
|
||||
@@ -366,7 +367,20 @@ mktempfile()
|
||||
}
|
||||
if (! filename)
|
||||
fprintf (stderr, "Unable to create tempfile");
|
||||
|
||||
#else
|
||||
char template[] = P_tmpdir "/epdfinfoXXXXXX";
|
||||
char *filename = malloc(sizeof(template));
|
||||
memcpy(filename, template, sizeof(template));
|
||||
int fd = mkstemp(filename);
|
||||
if (fd == -1)
|
||||
{
|
||||
fprintf (stderr, "Unable to create tempfile");
|
||||
free(filename);
|
||||
filename = NULL;
|
||||
}
|
||||
else
|
||||
close(fd);
|
||||
#endif
|
||||
return filename;
|
||||
}
|
||||
|
||||
@@ -469,7 +483,8 @@ static inline gboolean color_equal(struct color a, struct color b)
|
||||
|
||||
static void
|
||||
image_recolor (cairo_surface_t * surface, const PopplerColor * fg,
|
||||
const PopplerColor * bg, int usecolors)
|
||||
const PopplerColor * bg, int usecolors,
|
||||
double gamma, int gammabeforeinvert)
|
||||
{
|
||||
/* Performs one of two kinds of image recoloring depending on the value of usecolors:
|
||||
|
||||
@@ -529,9 +544,9 @@ image_recolor (cairo_surface_t * surface, const PopplerColor * fg,
|
||||
{
|
||||
/* Careful. data color components blue, green, red. */
|
||||
struct color rgb = {
|
||||
.r = (double) data[2] / 256.,
|
||||
.g = (double) data[1] / 256.,
|
||||
.b = (double) data[0] / 256.
|
||||
.r = (double) data[2] / 255.,
|
||||
.g = (double) data[1] / 255.,
|
||||
.b = (double) data[0] / 255.
|
||||
};
|
||||
|
||||
/* Linear interpolation between bg and fg based on the
|
||||
@@ -557,6 +572,7 @@ image_recolor (cairo_surface_t * surface, const PopplerColor * fg,
|
||||
white->background and black->foreground and have a single entry cache to
|
||||
speed up computation */
|
||||
const struct color white = {.r = 1.0, .g = 1.0, .b = 1.0};
|
||||
const struct color black = {.r = 0.0, .g = 0.0, .b = 0.0};
|
||||
struct color precomputed_rgb = white;
|
||||
struct color precomputed_inv_rgb = rgb_bg;
|
||||
|
||||
@@ -564,8 +580,6 @@ image_recolor (cairo_surface_t * surface, const PopplerColor * fg,
|
||||
struct color oklab_fg = rgb2oklab(rgb_fg);
|
||||
struct color oklab_bg = rgb2oklab(rgb_bg);
|
||||
|
||||
const double oklab_diff_l = oklab_fg.l - oklab_bg.l;
|
||||
|
||||
unsigned int y;
|
||||
for (y = 0; y < page_height * rowstride; y += rowstride)
|
||||
{
|
||||
@@ -576,9 +590,9 @@ image_recolor (cairo_surface_t * surface, const PopplerColor * fg,
|
||||
{
|
||||
/* Careful. data color components blue, green, red. */
|
||||
struct color rgb = {
|
||||
.r = (double) data[2] / 256.,
|
||||
.g = (double) data[1] / 256.,
|
||||
.b = (double) data[0] / 256.
|
||||
.r = (double) data[2] / 255.,
|
||||
.g = (double) data[1] / 255.,
|
||||
.b = (double) data[0] / 255.
|
||||
};
|
||||
|
||||
/* Convert to Oklab coordinates, invert perceived lightness,
|
||||
@@ -587,6 +601,10 @@ image_recolor (cairo_surface_t * surface, const PopplerColor * fg,
|
||||
{
|
||||
rgb = rgb_bg;
|
||||
}
|
||||
else if (color_equal(black, rgb))
|
||||
{
|
||||
rgb = rgb_fg;
|
||||
}
|
||||
else if (color_equal(precomputed_rgb, rgb))
|
||||
{
|
||||
rgb = precomputed_inv_rgb;
|
||||
@@ -599,7 +617,20 @@ image_recolor (cairo_surface_t * surface, const PopplerColor * fg,
|
||||
/* Invert the perceived lightness, and scales it */
|
||||
double l = oklab.l;
|
||||
double inv_l = 1.0 - l;
|
||||
oklab.l = oklab_bg.l + oklab_diff_l * inv_l;
|
||||
|
||||
/* Nonlinearly scale lightness */
|
||||
if (gammabeforeinvert)
|
||||
{
|
||||
l = pow(l, gamma);
|
||||
inv_l = 1.0 - l;
|
||||
}
|
||||
else
|
||||
{
|
||||
inv_l = pow(inv_l, gamma);
|
||||
l = 1.0 - inv_l;
|
||||
}
|
||||
|
||||
oklab.l = oklab_bg.l * l + oklab_fg.l * inv_l;
|
||||
|
||||
/* Have a and b parameters (which encode hue and saturation)
|
||||
start at the background value and interpolate up to
|
||||
@@ -692,7 +723,8 @@ image_render_page(PopplerDocument *pdf, PopplerPage *page,
|
||||
cairo_paint (cr);
|
||||
|
||||
if (options && (options->usecolors))
|
||||
image_recolor (surface, &options->fg, &options->bg, options->usecolors);
|
||||
image_recolor (surface, &options->fg, &options->bg, options->usecolors,
|
||||
options->gamma, options->gammabeforeinvert);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
||||
@@ -1105,6 +1137,15 @@ command_arg_parse_arg (const epdfinfo_t *ctx, const char *arg,
|
||||
error_msg, "Expected 0 or 1:%s", arg);
|
||||
cmd_arg->value.flag = *arg == '1';
|
||||
break;
|
||||
case ARG_DOUBLE:
|
||||
{
|
||||
char *endptr;
|
||||
double n = strtod (arg, &endptr);
|
||||
cerror_if_not (! (*endptr),
|
||||
error_msg, "Expected double (floating point): %s", arg);
|
||||
cmd_arg->value.scalar = n;
|
||||
}
|
||||
break;
|
||||
case ARG_NONEMPTY_STRING:
|
||||
cerror_if_not (*arg, error_msg, "Non-empty string expected");
|
||||
/* fall through */
|
||||
@@ -1246,6 +1287,9 @@ command_arg_print(const command_arg_t *arg)
|
||||
case ARG_BOOL:
|
||||
printf ("%d", arg->value.flag ? 1 : 0);
|
||||
break;
|
||||
case ARG_DOUBLE:
|
||||
printf ("%f", arg->value.scalar);
|
||||
break;
|
||||
case ARG_NONEMPTY_STRING: /* fall */
|
||||
case ARG_STRING:
|
||||
print_response_string (arg->value.string, NONE);
|
||||
@@ -1297,6 +1341,7 @@ command_arg_type_size(command_arg_type_t type)
|
||||
case ARG_INVALID: return 0;
|
||||
case ARG_DOC: return sizeof (arg.value.doc);
|
||||
case ARG_BOOL: return sizeof (arg.value.flag);
|
||||
case ARG_DOUBLE: return sizeof (arg.value.scalar);
|
||||
case ARG_NONEMPTY_STRING: /* fall */
|
||||
case ARG_STRING: return sizeof (arg.value.string);
|
||||
case ARG_NATNUM: return sizeof (arg.value.natnum);
|
||||
@@ -3653,6 +3698,8 @@ const document_option_t document_options [] =
|
||||
DEC_DOPT (":render/printed", ARG_BOOL, render.printed),
|
||||
DEC_DOPT (":render/foreground", ARG_COLOR, render.fg),
|
||||
DEC_DOPT (":render/background", ARG_COLOR, render.bg),
|
||||
DEC_DOPT (":render/gamma", ARG_DOUBLE, render.gamma),
|
||||
DEC_DOPT (":render/gammabeforeinvert", ARG_BOOL, render.gammabeforeinvert),
|
||||
};
|
||||
|
||||
const command_arg_type_t cmd_getoptions_spec[] =
|
||||
|
||||
@@ -165,6 +165,7 @@ typedef enum
|
||||
ARG_INVALID = 0,
|
||||
ARG_DOC,
|
||||
ARG_BOOL,
|
||||
ARG_DOUBLE,
|
||||
ARG_STRING,
|
||||
ARG_NONEMPTY_STRING,
|
||||
ARG_NATNUM,
|
||||
@@ -188,6 +189,8 @@ typedef struct
|
||||
PopplerColor bg, fg;
|
||||
gboolean usecolors;
|
||||
gboolean printed;
|
||||
gboolean gammabeforeinvert;
|
||||
gdouble gamma;
|
||||
} render_options_t;
|
||||
|
||||
typedef struct
|
||||
@@ -214,6 +217,7 @@ typedef struct
|
||||
union
|
||||
{
|
||||
gboolean flag;
|
||||
gdouble scalar;
|
||||
const char *string;
|
||||
long natnum;
|
||||
document_t *doc;
|
||||
|
||||
@@ -8415,7 +8415,8 @@ static int _synctex_updater_print(synctex_updater_p updater, const char * format
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_WIN32)
|
||||
// define vasprintf as it’s available only on Linux and macOS.
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
@@ -8424,17 +8425,14 @@ static int vasprintf(char **ret,
|
||||
const char *format,
|
||||
va_list ap)
|
||||
{
|
||||
int len;
|
||||
len = _vsnprintf(NULL, 0, format, ap);
|
||||
int len = vsnprintf(NULL, 0, format, ap);
|
||||
if (len < 0) return -1;
|
||||
*ret = malloc(len + 1);
|
||||
if (!*ret) return -1;
|
||||
_vsnprintf(*ret, len+1, format, ap);
|
||||
(*ret)[len] = '\0';
|
||||
return len;
|
||||
return vsnprintf(*ret, len + 1, format, ap);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // _WIN32
|
||||
|
||||
/**
|
||||
* gzvprintf is not available until OSX 10.10
|
||||
|
||||
Reference in New Issue
Block a user