mirror of
https://github.com/love2d/megasource.git
synced 2026-08-21 05:02:11 +02:00
update harfbuzz to 10.1.0
This commit is contained in:
@@ -29,10 +29,13 @@
|
||||
|
||||
#include "face-options.hh"
|
||||
|
||||
#include <hb-ot.h>
|
||||
#ifdef HAVE_FREETYPE
|
||||
#include <hb-ft.h>
|
||||
#endif
|
||||
#include <hb-ot.h>
|
||||
#ifdef HAVE_CORETEXT
|
||||
#include <hb-coretext.h>
|
||||
#endif
|
||||
|
||||
#define FONT_SIZE_UPEM 0x7FFFFFFF
|
||||
#define FONT_SIZE_NONE 0
|
||||
@@ -63,19 +66,23 @@ struct font_options_t : face_options_t
|
||||
int x_ppem = 0;
|
||||
int y_ppem = 0;
|
||||
double ptem = 0.;
|
||||
double x_embolden = 0.;
|
||||
double y_embolden = 0.;
|
||||
hb_bool_t embolden_in_place = false;
|
||||
double slant = 0.;
|
||||
unsigned int subpixel_bits = SUBPIXEL_BITS;
|
||||
mutable double font_size_x = DEFAULT_FONT_SIZE;
|
||||
mutable double font_size_y = DEFAULT_FONT_SIZE;
|
||||
char *font_funcs = nullptr;
|
||||
int ft_load_flags = 2;
|
||||
unsigned int named_instance = HB_FONT_NO_VAR_NAMED_INSTANCE;
|
||||
|
||||
hb_font_t *font = nullptr;
|
||||
};
|
||||
|
||||
|
||||
static struct supported_font_funcs_t {
|
||||
char name[4];
|
||||
char name[9];
|
||||
void (*func) (hb_font_t *);
|
||||
} supported_font_funcs[] =
|
||||
{
|
||||
@@ -83,6 +90,9 @@ static struct supported_font_funcs_t {
|
||||
#ifdef HAVE_FREETYPE
|
||||
{"ft", hb_ft_font_set_funcs},
|
||||
#endif
|
||||
#ifdef HAVE_CORETEXT
|
||||
{"coretext", hb_coretext_font_set_funcs},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -100,6 +110,9 @@ font_options_t::post_parse (GError **error)
|
||||
hb_font_set_ppem (font, x_ppem, y_ppem);
|
||||
hb_font_set_ptem (font, ptem);
|
||||
|
||||
hb_font_set_synthetic_bold (font,
|
||||
(float) x_embolden, (float) y_embolden,
|
||||
embolden_in_place);
|
||||
hb_font_set_synthetic_slant (font, slant);
|
||||
|
||||
int scale_x = (int) scalbnf (font_size_x, subpixel_bits);
|
||||
@@ -107,6 +120,7 @@ font_options_t::post_parse (GError **error)
|
||||
hb_font_set_scale (font, scale_x, scale_y);
|
||||
|
||||
#ifndef HB_NO_VAR
|
||||
hb_font_set_var_named_instance (font, named_instance);
|
||||
hb_font_set_variations (font, variations, num_variations);
|
||||
#endif
|
||||
|
||||
@@ -157,7 +171,6 @@ font_options_t::post_parse (GError **error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef HB_NO_VAR
|
||||
static gboolean
|
||||
parse_variations (const char *name G_GNUC_UNUSED,
|
||||
@@ -244,13 +257,52 @@ parse_font_ppem (const char *name G_GNUC_UNUSED,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_font_embolden (const char *name G_GNUC_UNUSED,
|
||||
const char *arg,
|
||||
gpointer data,
|
||||
GError **error G_GNUC_UNUSED)
|
||||
{
|
||||
font_options_t *font_opts = (font_options_t *) data;
|
||||
switch (sscanf (arg, "%lf%*[ ,]%lf", &font_opts->x_embolden, &font_opts->y_embolden)) {
|
||||
case 1: font_opts->y_embolden = font_opts->x_embolden; HB_FALLTHROUGH;
|
||||
case 2: return true;
|
||||
default:
|
||||
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
|
||||
"%s argument should be one or two space-separated numbers",
|
||||
name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_font_bold (const char *name G_GNUC_UNUSED,
|
||||
const char *arg,
|
||||
gpointer data,
|
||||
GError **error G_GNUC_UNUSED)
|
||||
{
|
||||
font_options_t *font_opts = (font_options_t *) data;
|
||||
font_opts->embolden_in_place = false;
|
||||
return parse_font_embolden ( name, arg, data, error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_font_grade (const char *name G_GNUC_UNUSED,
|
||||
const char *arg,
|
||||
gpointer data,
|
||||
GError **error G_GNUC_UNUSED)
|
||||
{
|
||||
font_options_t *font_opts = (font_options_t *) data;
|
||||
font_opts->embolden_in_place = true;
|
||||
return parse_font_embolden ( name, arg, data, error);
|
||||
}
|
||||
|
||||
void
|
||||
font_options_t::add_options (option_parser_t *parser)
|
||||
{
|
||||
face_options_t::add_options (parser);
|
||||
|
||||
char *text = nullptr;
|
||||
|
||||
char *font_funcs_text = nullptr;
|
||||
{
|
||||
static_assert ((ARRAY_LENGTH_CONST (supported_font_funcs) > 0),
|
||||
"No supported font-funcs found.");
|
||||
@@ -263,8 +315,8 @@ font_options_t::add_options (option_parser_t *parser)
|
||||
g_string_append_c (s, '/');
|
||||
g_string_append (s, supported_font_funcs[i].name);
|
||||
}
|
||||
text = g_string_free (s, FALSE);
|
||||
parser->free_later (text);
|
||||
font_funcs_text = g_string_free (s, FALSE);
|
||||
parser->free_later (font_funcs_text);
|
||||
}
|
||||
|
||||
char *font_size_text;
|
||||
@@ -272,7 +324,7 @@ font_options_t::add_options (option_parser_t *parser)
|
||||
font_size_text = (char *) "Font size (default: upem)";
|
||||
else
|
||||
{
|
||||
font_size_text = g_strdup_printf ("Font size (default: %d)", DEFAULT_FONT_SIZE);
|
||||
font_size_text = g_strdup_printf ("Font size (default: %u)", DEFAULT_FONT_SIZE);
|
||||
parser->free_later (font_size_text);
|
||||
}
|
||||
|
||||
@@ -283,11 +335,15 @@ font_options_t::add_options (option_parser_t *parser)
|
||||
G_OPTION_ARG_CALLBACK, (gpointer) &parse_font_size, font_size_text, "1/2 integers or 'upem'"},
|
||||
{"font-ppem", 0, font_size_flags,
|
||||
G_OPTION_ARG_CALLBACK, (gpointer) &parse_font_ppem, "Set x,y pixels per EM (default: 0; disabled)", "1/2 integers"},
|
||||
{"font-ptem", 0, 0,
|
||||
{"font-ptem", 0, font_size_flags,
|
||||
G_OPTION_ARG_DOUBLE, &this->ptem, "Set font point-size (default: 0; disabled)", "point-size"},
|
||||
{"font-slant", 0, 0,
|
||||
{"font-bold", 0, font_size_flags,
|
||||
G_OPTION_ARG_CALLBACK, (gpointer) &parse_font_bold, "Set synthetic bold (default: 0)", "1/2 numbers; eg. 0.05"},
|
||||
{"font-grade", 0, font_size_flags,
|
||||
G_OPTION_ARG_CALLBACK, (gpointer) &parse_font_grade, "Set synthetic grade (default: 0)", "1/2 numbers; eg. 0.05"},
|
||||
{"font-slant", 0, font_size_flags,
|
||||
G_OPTION_ARG_DOUBLE, &this->slant, "Set synthetic slant (default: 0)", "slant ratio; eg. 0.2"},
|
||||
{"font-funcs", 0, 0, G_OPTION_ARG_STRING, &this->font_funcs, text, "impl"},
|
||||
{"font-funcs", 0, 0, G_OPTION_ARG_STRING, &this->font_funcs, font_funcs_text, "impl"},
|
||||
{"sub-font", 0, G_OPTION_FLAG_HIDDEN,
|
||||
G_OPTION_ARG_NONE, &this->sub_font, "Create a sub-font (default: false)", "boolean"},
|
||||
{"ft-load-flags", 0, 0, G_OPTION_ARG_INT, &this->ft_load_flags, "Set FreeType load-flags (default: 2)", "integer"},
|
||||
@@ -315,6 +371,7 @@ font_options_t::add_options (option_parser_t *parser)
|
||||
|
||||
GOptionEntry entries2[] =
|
||||
{
|
||||
{"named-instance", 0, 0, G_OPTION_ARG_INT, &this->named_instance, "Set named-instance index (default: none)", "index"},
|
||||
{"variations", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_variations, variations_help, "list"},
|
||||
{nullptr}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user