mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 00:41:09 +01:00
Merge branch 'main' into HVF
This commit is contained in:
commit
4162d3bf90
15 files changed
+182
-57
No files matched your search
@@ -19,3 +19,4 @@ objcopy = 'i686-w64-mingw32-objcopy'
|
||||
strip = 'i686-w64-mingw32-strip'
|
||||
windres = 'i686-w64-mingw32-windres'
|
||||
pkg-config = 'i686-w64-mingw32-pkg-config'
|
||||
#exe_wrapper = 'wine'
|
||||
@@ -19,3 +19,4 @@ objcopy = 'x86_64-w64-mingw32-objcopy'
|
||||
strip = 'x86_64-w64-mingw32-strip'
|
||||
windres = 'x86_64-w64-mingw32-windres'
|
||||
pkg-config = 'x86_64-w64-mingw32-pkg-config'
|
||||
#exe_wrapper = 'wine'
|
||||
@@ -5,13 +5,20 @@
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
if (argc < 3)
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s font-file [font-funcs] [wght]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hb_face_t *face = hb_face_create_from_file_or_fail (argv[1], 0);
|
||||
|
||||
if (!face)
|
||||
{
|
||||
fprintf (stderr, "Failed to create face\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
|
||||
if (argc > 2)
|
||||
File renamed without changes.
@@ -0,0 +1,45 @@
|
||||
#include <hb.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s font-file [font-funcs] [wght]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hb_face_t *face = hb_face_create_from_file_or_fail (argv[1], 0);
|
||||
|
||||
if (!face)
|
||||
{
|
||||
fprintf (stderr, "Failed to create face\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
|
||||
if (argc > 2)
|
||||
hb_font_set_funcs_using (font, argv[2]);
|
||||
|
||||
if (argc > 3)
|
||||
{
|
||||
hb_variation_t variations[] = {
|
||||
{ HB_TAG ('w', 'g', 'h', 't'), atoi (argv[3]) },
|
||||
};
|
||||
hb_font_set_variations (font, variations, 1);
|
||||
}
|
||||
|
||||
hb_paint_funcs_t *funcs = hb_paint_funcs_create ();
|
||||
|
||||
unsigned glyph_count = hb_face_get_glyph_count (face);
|
||||
for (unsigned gid = 0; gid < glyph_count; gid++)
|
||||
hb_font_paint_glyph (font, gid, funcs, NULL, 0, 0);
|
||||
|
||||
hb_paint_funcs_destroy (funcs);
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
return 0;
|
||||
}
|
||||
File renamed without changes.
@@ -38,3 +38,17 @@ foreach source : benchmarks_subset
|
||||
install: false,
|
||||
), workdir: meson.current_source_dir() / '..', timeout: 100)
|
||||
endforeach
|
||||
|
||||
hb_draw_all = executable('hb-draw-all', ['hb-draw-all.c'],
|
||||
cpp_args: cpp_args,
|
||||
include_directories: [incconfig, incsrc],
|
||||
link_with: [libharfbuzz],
|
||||
)
|
||||
meson.override_find_program('hb-draw-all', hb_draw_all)
|
||||
|
||||
hb_paint_all = executable('hb-paint-all', ['hb-paint-all.c'],
|
||||
cpp_args: cpp_args,
|
||||
include_directories: [incconfig, incsrc],
|
||||
link_with: [libharfbuzz],
|
||||
)
|
||||
meson.override_find_program('hb-paint-all', hb_paint_all)
|
||||
Generated
+4
-4
@@ -59,9 +59,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.27.4"
|
||||
version = "0.27.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d1cb3d8f1eff7ebef84ca77c0ef99e84e40459132a71bd678e96c6b7f0e6c1e"
|
||||
checksum = "f14974c88fb4fd0a7203719f98020209248c9dbebaf9d10d860337797a905097"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"font-types",
|
||||
@@ -69,9 +69,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.29.1"
|
||||
version = "0.29.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d58313d717b05488e8c8bae9b4cb34191aa6168d07430e17a2c0a12695fe735"
|
||||
checksum = "7c0ca53de9bb9bee1720c727606275148463cd938eb6bde249dcedeec4967747"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts",
|
||||
|
||||
@@ -4,7 +4,7 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
read-fonts = "0.27"
|
||||
skrifa = "0.29.1"
|
||||
skrifa = "0.29.2"
|
||||
|
||||
[lib]
|
||||
name = "harfbuzz_fontations"
|
||||
@@ -13,7 +13,7 @@ crate-type = ["staticlib"]
|
||||
|
||||
[profile.release]
|
||||
strip = true
|
||||
lto = true
|
||||
lto = "fat"
|
||||
panic = "abort"
|
||||
overflow-checks = false
|
||||
codegen-units = 1
|
||||
@@ -23,3 +23,6 @@ inherits = "release"
|
||||
debug = true
|
||||
codegen-units = 16
|
||||
strip = false
|
||||
|
||||
[profile.dev]
|
||||
lto = "fat"
|
||||
+30
-27
@@ -199,7 +199,7 @@ extern "C" fn _hb_fontations_get_nominal_glyphs(
|
||||
let Some(glyph) = char_map.map(unicode) else {
|
||||
return i;
|
||||
};
|
||||
let glyph_id = u32::from(glyph) as hb_codepoint_t;
|
||||
let glyph_id = glyph.to_u32() as hb_codepoint_t;
|
||||
*struct_at_offset_mut(first_glyph, i, glyph_stride) = glyph_id;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ extern "C" fn _hb_fontations_get_variation_glyph(
|
||||
|
||||
match char_map.map_variant(unicode, variation_selector) {
|
||||
Some(Variant(glyph_id)) => {
|
||||
unsafe { *glyph = u32::from(glyph_id) as hb_codepoint_t };
|
||||
unsafe { *glyph = glyph_id.to_u32() as hb_codepoint_t };
|
||||
true as hb_bool_t
|
||||
}
|
||||
_ => false as hb_bool_t,
|
||||
@@ -415,8 +415,6 @@ struct HbColorPainter<'a> {
|
||||
paint_data: *mut c_void,
|
||||
color_records: &'a [ColorRecord],
|
||||
foreground: hb_color_t,
|
||||
composite_mode: Vec<CompositeMode>,
|
||||
clip_transform_stack: Vec<bool>,
|
||||
}
|
||||
|
||||
impl HbColorPainter<'_> {
|
||||
@@ -544,22 +542,41 @@ impl ColorPainter for HbColorPainter<'_> {
|
||||
hb_paint_pop_transform(self.paint_funcs, self.paint_data);
|
||||
}
|
||||
}
|
||||
fn push_clip_glyph(&mut self, glyph: GlyphId) {
|
||||
let gid = u32::from(glyph);
|
||||
self.clip_transform_stack.push(true);
|
||||
fn fill_glyph(
|
||||
&mut self,
|
||||
glyph_id: GlyphId,
|
||||
brush_transform: Option<Transform>,
|
||||
brush: Brush<'_>,
|
||||
) {
|
||||
unsafe {
|
||||
hb_paint_push_inverse_font_transform(self.paint_funcs, self.paint_data, self.font);
|
||||
}
|
||||
self.push_clip_glyph(glyph_id);
|
||||
unsafe {
|
||||
hb_paint_push_font_transform(self.paint_funcs, self.paint_data, self.font);
|
||||
}
|
||||
if let Some(wrap_in_transform) = brush_transform {
|
||||
self.push_transform(wrap_in_transform);
|
||||
self.fill(brush);
|
||||
self.pop_transform();
|
||||
} else {
|
||||
self.fill(brush);
|
||||
}
|
||||
self.pop_transform();
|
||||
self.pop_clip();
|
||||
self.pop_transform();
|
||||
}
|
||||
fn push_clip_glyph(&mut self, glyph_id: GlyphId) {
|
||||
unsafe {
|
||||
hb_paint_push_clip_glyph(
|
||||
self.paint_funcs,
|
||||
self.paint_data,
|
||||
gid as hb_codepoint_t,
|
||||
glyph_id.to_u32() as hb_codepoint_t,
|
||||
self.font,
|
||||
);
|
||||
hb_paint_push_font_transform(self.paint_funcs, self.paint_data, self.font);
|
||||
}
|
||||
}
|
||||
fn push_clip_box(&mut self, bbox: BoundingBox) {
|
||||
self.clip_transform_stack.push(false);
|
||||
unsafe {
|
||||
hb_paint_push_clip_rectangle(
|
||||
self.paint_funcs,
|
||||
@@ -572,16 +589,9 @@ impl ColorPainter for HbColorPainter<'_> {
|
||||
}
|
||||
}
|
||||
fn pop_clip(&mut self) {
|
||||
let pop_transforms = self.clip_transform_stack.pop().unwrap_or(false);
|
||||
if pop_transforms {
|
||||
self.pop_transform();
|
||||
}
|
||||
unsafe {
|
||||
hb_paint_pop_clip(self.paint_funcs, self.paint_data);
|
||||
}
|
||||
if pop_transforms {
|
||||
self.pop_transform();
|
||||
}
|
||||
}
|
||||
fn fill(&mut self, brush: Brush) {
|
||||
match brush {
|
||||
@@ -695,18 +705,13 @@ impl ColorPainter for HbColorPainter<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
fn push_layer(&mut self, mode: CompositeMode) {
|
||||
self.composite_mode.push(mode);
|
||||
fn push_layer(&mut self, _mode: CompositeMode) {
|
||||
unsafe {
|
||||
hb_paint_push_group(self.paint_funcs, self.paint_data);
|
||||
}
|
||||
}
|
||||
fn pop_layer(&mut self) {
|
||||
let mode = self.composite_mode.pop();
|
||||
if mode.is_none() {
|
||||
return;
|
||||
}
|
||||
let mode = mode.unwrap() as hb_paint_composite_mode_t; // They are the same
|
||||
fn pop_layer_with_mode(&mut self, mode: CompositeMode) {
|
||||
let mode = mode as hb_paint_composite_mode_t; // They are the same
|
||||
unsafe {
|
||||
hb_paint_pop_group(self.paint_funcs, self.paint_data, mode);
|
||||
}
|
||||
@@ -766,8 +771,6 @@ extern "C" fn _hb_fontations_paint_glyph(
|
||||
paint_data,
|
||||
color_records,
|
||||
foreground,
|
||||
composite_mode: Vec::new(),
|
||||
clip_transform_stack: Vec::new(),
|
||||
};
|
||||
unsafe {
|
||||
hb_paint_push_font_transform(paint_funcs, paint_data, font);
|
||||
|
||||
+52
-14
@@ -71,7 +71,8 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<ELEM, CFF2Subrs>
|
||||
template <typename ACC>
|
||||
cff2_cs_interp_env_t (const hb_ubytes_t &str, ACC &acc, unsigned int fd,
|
||||
const int *coords_=nullptr, unsigned int num_coords_=0)
|
||||
: SUPER (str, acc.globalSubrs, acc.privateDicts[fd].localSubrs)
|
||||
: SUPER (str, acc.globalSubrs, acc.privateDicts[fd].localSubrs),
|
||||
cached_scalars_vector (&acc.cached_scalars_vector)
|
||||
{
|
||||
coords = coords_;
|
||||
num_coords = num_coords_;
|
||||
@@ -80,9 +81,39 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<ELEM, CFF2Subrs>
|
||||
set_ivs (acc.privateDicts[fd].ivs);
|
||||
}
|
||||
|
||||
void fini ()
|
||||
~cff2_cs_interp_env_t ()
|
||||
{
|
||||
SUPER::fini ();
|
||||
release_scalars_vector (scalars);
|
||||
}
|
||||
|
||||
hb_vector_t<float> *acquire_scalars_vector () const
|
||||
{
|
||||
hb_vector_t<float> *scalars = cached_scalars_vector->get_acquire ();
|
||||
|
||||
if (!scalars || !cached_scalars_vector->cmpexch (scalars, nullptr))
|
||||
{
|
||||
scalars = (hb_vector_t<float> *) hb_calloc (1, sizeof (hb_vector_t<float>));
|
||||
if (unlikely (!scalars))
|
||||
return nullptr;
|
||||
scalars->init ();
|
||||
}
|
||||
|
||||
return scalars;
|
||||
}
|
||||
|
||||
void release_scalars_vector (hb_vector_t<float> *scalars) const
|
||||
{
|
||||
if (!scalars)
|
||||
return;
|
||||
|
||||
scalars->clear ();
|
||||
|
||||
if (!cached_scalars_vector->cmpexch (nullptr, scalars))
|
||||
{
|
||||
scalars->fini ();
|
||||
hb_free (scalars);
|
||||
}
|
||||
scalars = nullptr;
|
||||
}
|
||||
|
||||
op_code_t fetch_op ()
|
||||
@@ -111,14 +142,20 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<ELEM, CFF2Subrs>
|
||||
{
|
||||
if (!seen_blend)
|
||||
{
|
||||
region_count = varStore->varStore.get_region_index_count (get_ivs ());
|
||||
if (do_blend)
|
||||
scalars = acquire_scalars_vector ();
|
||||
if (unlikely (!scalars))
|
||||
SUPER::set_error ();
|
||||
else
|
||||
{
|
||||
if (unlikely (!scalars.resize_exact (region_count)))
|
||||
SUPER::set_error ();
|
||||
else
|
||||
varStore->varStore.get_region_scalars (get_ivs (), coords, num_coords,
|
||||
&scalars[0], region_count);
|
||||
region_count = varStore->varStore.get_region_index_count (get_ivs ());
|
||||
if (do_blend)
|
||||
{
|
||||
if (unlikely (!scalars->resize_exact (region_count)))
|
||||
SUPER::set_error ();
|
||||
else
|
||||
varStore->varStore.get_region_scalars (get_ivs (), coords, num_coords,
|
||||
&(*scalars)[0], region_count);
|
||||
}
|
||||
}
|
||||
seen_blend = true;
|
||||
}
|
||||
@@ -149,11 +186,11 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<ELEM, CFF2Subrs>
|
||||
double v = 0;
|
||||
if (do_blend)
|
||||
{
|
||||
if (likely (scalars.length == deltas.length))
|
||||
if (likely (scalars && scalars->length == deltas.length))
|
||||
{
|
||||
unsigned count = scalars.length;
|
||||
unsigned count = scalars->length;
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
v += (double) scalars.arrayZ[i] * deltas.arrayZ[i].to_real ();
|
||||
v += (double) scalars->arrayZ[i] * deltas.arrayZ[i].to_real ();
|
||||
}
|
||||
}
|
||||
return v;
|
||||
@@ -167,7 +204,8 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<ELEM, CFF2Subrs>
|
||||
const CFF2ItemVariationStore *varStore;
|
||||
unsigned int region_count;
|
||||
unsigned int ivs;
|
||||
hb_vector_t<float> scalars;
|
||||
hb_vector_t<float> *scalars = nullptr;
|
||||
hb_atomic_t<hb_vector_t<float> *> *cached_scalars_vector = nullptr;
|
||||
bool do_blend;
|
||||
bool seen_vsindex_ = false;
|
||||
bool seen_blend = false;
|
||||
|
||||
@@ -482,6 +482,13 @@ struct cff2
|
||||
privateDicts.fini ();
|
||||
hb_blob_destroy (blob);
|
||||
blob = nullptr;
|
||||
|
||||
auto *scalars = cached_scalars_vector.get_acquire ();
|
||||
if (scalars && cached_scalars_vector.cmpexch (scalars, nullptr))
|
||||
{
|
||||
scalars->fini ();
|
||||
hb_free (scalars);
|
||||
}
|
||||
}
|
||||
|
||||
hb_vector_t<uint16_t> *create_glyph_to_sid_map () const
|
||||
@@ -509,6 +516,8 @@ struct cff2
|
||||
hb_vector_t<cff2_font_dict_values_t> fontDicts;
|
||||
hb_vector_t<PRIVDICTVAL> privateDicts;
|
||||
|
||||
mutable hb_atomic_t<hb_vector_t<float> *> cached_scalars_vector;
|
||||
|
||||
unsigned int num_glyphs = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
hb_draw_all = executable('hb-draw-all', ['hb-draw-all.c'],
|
||||
cpp_args: cpp_args,
|
||||
include_directories: [incconfig, incsrc],
|
||||
link_with: [libharfbuzz],
|
||||
)
|
||||
meson.override_find_program('hb-draw-all', hb_draw_all)
|
||||
@@ -3,4 +3,3 @@ subdir('fuzzing')
|
||||
subdir('threads')
|
||||
subdir('shape')
|
||||
subdir('api')
|
||||
subdir('draw')
|
||||
+13
-2
@@ -16,11 +16,18 @@ hb_shape, args = args[0], args[1:]
|
||||
env = os.environ.copy()
|
||||
env["LC_ALL"] = "C"
|
||||
|
||||
EXE_WRAPPER = os.environ.get("MESON_EXE_WRAPPER")
|
||||
|
||||
|
||||
def open_shape_batch_process():
|
||||
global hb_shape, env
|
||||
|
||||
cmd = [hb_shape, "--batch"]
|
||||
if EXE_WRAPPER:
|
||||
cmd = [EXE_WRAPPER] + cmd
|
||||
|
||||
process = subprocess.Popen(
|
||||
[hb_shape, "--batch"],
|
||||
cmd,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=sys.stdout,
|
||||
@@ -79,8 +86,12 @@ def all_whats(what):
|
||||
for what in ["shaper", "face-loader", "font-funcs"]:
|
||||
subcommand = "--list-" + plural(what)
|
||||
|
||||
cmd = [hb_shape, subcommand]
|
||||
if EXE_WRAPPER:
|
||||
cmd = [EXE_WRAPPER] + cmd
|
||||
|
||||
what_process = subprocess.Popen(
|
||||
[hb_shape, subcommand],
|
||||
cmd,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=sys.stdout,
|
||||
|
||||
Reference in new issue
Block a user