sketch a subset<T> and call it for cmap. Add subset to cmap, albeit not working even for the msot basic case just yet
This commit is contained in:
parent
c1ab95dd90
commit
0859a00669
|
@ -27,8 +27,8 @@
|
|||
#ifndef HB_OT_CMAP_TABLE_HH
|
||||
#define HB_OT_CMAP_TABLE_HH
|
||||
|
||||
#include "hb-open-type-private.hh"
|
||||
|
||||
#include "hb-open-type-private.hh"
|
||||
#include "hb-subset-plan.hh"
|
||||
|
||||
namespace OT {
|
||||
|
||||
|
@ -504,6 +504,20 @@ struct cmap
|
|||
encodingRecord.sanitize (c, this));
|
||||
}
|
||||
|
||||
inline bool subset(hb_subset_plan_t *plan, OT::hb_serialize_context_t *out) const
|
||||
{
|
||||
// Same version
|
||||
OT::cmap new_cmap;
|
||||
new_cmap.version = version;
|
||||
new_cmap.encodingRecord.len.set(1); // one format 12 subtable
|
||||
|
||||
// TODO we need to actually build the format 12 subtable
|
||||
|
||||
// TODO: this fails
|
||||
// out->extend_min(new_cmap);
|
||||
return true;
|
||||
}
|
||||
|
||||
struct accelerator_t
|
||||
{
|
||||
inline void init (hb_face_t *face)
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
*/
|
||||
|
||||
#include "hb-object-private.hh"
|
||||
#include "hb-open-type-private.hh"
|
||||
|
||||
#include "hb-private.hh"
|
||||
|
||||
#include "hb-subset-glyf.hh"
|
||||
|
@ -33,6 +35,7 @@
|
|||
#include "hb-subset-plan.hh"
|
||||
|
||||
#include "hb-open-file-private.hh"
|
||||
#include "hb-ot-cmap-table.hh"
|
||||
#include "hb-ot-glyf-table.hh"
|
||||
|
||||
|
||||
|
@ -104,6 +107,26 @@ hb_subset_input_destroy(hb_subset_input_t *subset_input)
|
|||
free (subset_input);
|
||||
}
|
||||
|
||||
template<typename TableType>
|
||||
hb_bool_t
|
||||
subset(hb_subset_plan_t *plan, hb_face_t *face, hb_blob_t **out)
|
||||
{
|
||||
OT::Sanitizer<TableType> sanitizer;
|
||||
hb_blob_t *table_blob = sanitizer.sanitize (face->reference_table (TableType::tableTag));
|
||||
if (unlikely(!table_blob)) {
|
||||
return false;
|
||||
}
|
||||
const TableType *table = OT::Sanitizer<TableType>::lock_instance (table_blob);
|
||||
|
||||
// TODO actually manage the context/output memory
|
||||
size_t dest_sz = 64536; // as much as anyone would ever need
|
||||
void *dest = malloc(dest_sz);
|
||||
OT::hb_serialize_context_t context(dest, dest_sz);
|
||||
hb_bool_t result = table->subset(plan, &context);
|
||||
// TODO populate out
|
||||
hb_blob_destroy (table_blob);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -289,6 +312,13 @@ hb_subset (hb_face_t *source,
|
|||
}
|
||||
hb_blob_destroy (glyf_prime);
|
||||
|
||||
hb_blob_t *cmap_prime = nullptr;
|
||||
if (subset<const OT::cmap>(plan, source, &cmap_prime)) {
|
||||
DEBUG_MSG(SUBSET, nullptr, "subset cmap success!");
|
||||
} else {
|
||||
DEBUG_MSG(SUBSET, nullptr, "subset cmap FAILED!");
|
||||
}
|
||||
|
||||
hb_subset_plan_destroy (plan);
|
||||
|
||||
return face;
|
||||
|
|
Loading…
Reference in New Issue