[C++11] Remove IntType::set() in favor of operator=

This commit is contained in:
Behdad Esfahbod 2019-03-29 20:17:46 -07:00
parent 58ad357951
commit b986c6a321
25 changed files with 206 additions and 200 deletions

View File

@ -272,11 +272,11 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
HBUINT8 *p = c->allocate_size<HBUINT8> (1);
if (unlikely (p == nullptr)) return_trace (false);
p->set (intOp);
*p = intOp;
INTTYPE *ip = c->allocate_size<INTTYPE> (INTTYPE::static_size);
if (unlikely (ip == nullptr)) return_trace (false);
ip->set ((unsigned int)value);
*ip = (unsigned int) value;
return_trace (true);
}

View File

@ -96,7 +96,7 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
ft_font->load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
ft_font->cached_x_scale.set (0);
ft_font->cached_x_scale.set_relaxed (0);
ft_font->advance_cache.init ();
return ft_font;

View File

@ -83,12 +83,6 @@ struct hb_static_size
template <typename T, typename V, typename B>
struct _hb_assign
{ static inline void value (T &o, const V v) { o = v; } };
template <typename T, typename V>
struct _hb_assign<T, V, hb_bool_tt<true || sizeof (T::min_size)> >
{ static inline void value (T &o, const V v) { o.set (v); } };
template <typename T>
struct _hb_assign<T, T, hb_bool_tt<true || sizeof (T::min_size)> >
{ static inline void value (T &o, const T v) { o = v; } };
template <typename T, typename V>
static inline void hb_assign (T &o, const V v)

View File

@ -106,7 +106,7 @@ typedef struct OffsetTable
bool find_table_index (hb_tag_t tag, unsigned int *table_index) const
{
Tag t;
t.set (tag);
t = tag;
return tables.bfind (t, table_index, HB_BFIND_NOT_FOUND_STORE, Index::NOT_FOUND_INDEX);
}
const TableRecord& get_table_by_tag (hb_tag_t tag) const
@ -127,7 +127,7 @@ typedef struct OffsetTable
/* Alloc 12 for the OTHeader. */
if (unlikely (!c->extend_min (*this))) return_trace (false);
/* Write sfntVersion (bytes 0..3). */
sfnt_version.set (sfnt_tag);
sfnt_version = sfnt_tag;
/* Take space for numTables, searchRange, entrySelector, RangeShift
* and the TableRecords themselves. */
if (unlikely (!tables.serialize (c, items.length))) return_trace (false);
@ -140,8 +140,8 @@ typedef struct OffsetTable
{
TableRecord &rec = tables.arrayZ[i];
hb_blob_t *blob = items[i].blob;
rec.tag.set (items[i].tag);
rec.length.set (hb_blob_get_length (blob));
rec.tag = items[i].tag;
rec.length = hb_blob_get_length (blob);
rec.offset.serialize (c, this);
/* Allocate room for the table and copy it. */
@ -159,7 +159,7 @@ typedef struct OffsetTable
{
head *h = (head *) start;
checksum_adjustment = &h->checkSumAdjustment;
checksum_adjustment->set (0);
*checksum_adjustment = 0;
}
rec.checkSum.set_for_data (start, end - start);
@ -177,10 +177,10 @@ typedef struct OffsetTable
for (unsigned int i = 0; i < items.length; i++)
{
TableRecord &rec = tables.arrayZ[i];
checksum.set (checksum + rec.checkSum);
checksum = checksum + rec.checkSum;
}
checksum_adjustment->set (0xB1B0AFBAu - checksum);
*checksum_adjustment = 0xB1B0AFBAu - checksum;
}
return_trace (true);

View File

@ -60,7 +60,6 @@ struct IntType
typedef typename hb_signedness_int (hb_is_signed (Type)) wide_type;
IntType<Type, Size>& operator = (wide_type i) { v = i; return *this; }
void set (wide_type i) { v = i; }
operator wide_type () const { return v; }
bool operator == (const IntType<Type,Size> &o) const { return (Type) v == (Type) o.v; }
bool operator != (const IntType<Type,Size> &o) const { return !(*this == o); }
@ -107,6 +106,7 @@ typedef HBUINT16 UFWORD;
/* 16-bit signed fixed number with the low 14 bits of fraction (2.14). */
struct F2DOT14 : HBINT16
{
F2DOT14& operator = (uint16_t i ) { HBINT16::operator= (i); return *this; }
// 16384 means 1<<14
float to_float () const { return ((int32_t) v) / 16384.f; }
void set_float (float f) { v = round (f * 16384.f); }
@ -117,6 +117,7 @@ struct F2DOT14 : HBINT16
/* 32-bit signed fixed-point number (16.16). */
struct Fixed : HBINT32
{
Fixed& operator = (uint32_t i) { HBINT32::operator= (i); return *this; }
// 65536 means 1<<16
float to_float () const { return ((int32_t) v) / 65536.f; }
void set_float (float f) { v = round (f * 65536.f); }
@ -144,6 +145,7 @@ struct LONGDATETIME
* system, feature, or baseline */
struct Tag : HBUINT32
{
Tag& operator = (uint32_t i) { HBUINT32::operator= (i); return *this; }
/* What the char* converters return is NOT nul-terminated. Print using "%.4s" */
operator const char* () const { return reinterpret_cast<const char *> (&this->v); }
operator char* () { return reinterpret_cast<char *> (&this->v); }
@ -152,11 +154,15 @@ struct Tag : HBUINT32
};
/* Glyph index number, same as uint16 (length = 16 bits) */
struct GlyphID : HBUINT16 {};
struct GlyphID : HBUINT16
{
GlyphID& operator = (uint16_t i) { HBUINT16::operator= (i); return *this; }
};
/* Script/language-system/feature index */
struct Index : HBUINT16 {
static constexpr unsigned NOT_FOUND_INDEX = 0xFFFFu;
Index& operator = (uint16_t i) { HBUINT16::operator= (i); return *this; }
};
DECLARE_NULL_NAMESPACE_BYTES (OT, Index);
@ -166,6 +172,8 @@ typedef Index NameID;
template <typename Type, bool has_null=true>
struct Offset : Type
{
Offset& operator = (typename Type::type i) { Type::operator= (i); return *this; }
typedef Type type;
bool is_null () const { return has_null && 0 == *this; }
@ -173,7 +181,7 @@ struct Offset : Type
void *serialize (hb_serialize_context_t *c, const void *base)
{
void *t = c->start_embed<void> ();
this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */
*this = (char *) t - (char *) base; /* TODO(serialize) Overflow? */
return t;
}
@ -188,6 +196,8 @@ typedef Offset<HBUINT32> Offset32;
/* CheckSum */
struct CheckSum : HBUINT32
{
CheckSum& operator = (uint32_t i) { HBUINT32::operator= (i); return *this; }
/* This is reference implementation from the spec. */
static uint32_t CalcTableChecksum (const HBUINT32 *Table, uint32_t Length)
{
@ -202,7 +212,7 @@ struct CheckSum : HBUINT32
/* Note: data should be 4byte aligned and have 4byte padding at the end. */
void set_for_data (const void *data, unsigned int length)
{ set (CalcTableChecksum ((const HBUINT32 *) data, length)); }
{ *this = CalcTableChecksum ((const HBUINT32 *) data, length); }
public:
DEFINE_SIZE_STATIC (4);
@ -252,6 +262,8 @@ struct _hb_has_null<Type, true>
template <typename Type, typename OffsetType=HBUINT16, bool has_null=true>
struct OffsetTo : Offset<OffsetType, has_null>
{
OffsetTo& operator = (typename OffsetType::type i) { OffsetType::operator= (i); return *this; }
const Type& operator () (const void *base) const
{
if (unlikely (this->is_null ())) return *_hb_has_null<Type, has_null>::get_null ();
@ -273,12 +285,12 @@ struct OffsetTo : Offset<OffsetType, has_null>
{
if (&src == &Null (T))
{
this->set (0);
*this = 0;
return;
}
serialize (c->serializer, base);
if (!src.subset (c))
this->set (0);
*this = 0;
}
bool sanitize_shallow (hb_sanitize_context_t *c, const void *base) const
@ -558,7 +570,7 @@ struct ArrayOf
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
len.set (items_len); /* TODO(serialize) Overflow? */
len = items_len; /* TODO(serialize) Overflow? */
if (unlikely (!c->extend (*this))) return_trace (false);
return_trace (true);
}
@ -717,7 +729,7 @@ struct HeadlessArrayOf
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
lenP1.set (items.length + 1); /* TODO(serialize) Overflow? */
lenP1 = items.length + 1; /* TODO(serialize) Overflow? */
if (unlikely (!c->extend (*this))) return_trace (false);
for (unsigned int i = 0; i < items.length; i++)
arrayZ[i] = items[i];
@ -872,15 +884,16 @@ struct BinSearchHeader
return_trace (c->check_struct (this));
}
void set (unsigned int v)
BinSearchHeader& operator = (unsigned int v)
{
len.set (v);
len = v;
assert (len == v);
entrySelector.set (MAX (1u, hb_bit_storage (v)) - 1);
searchRange.set (16 * (1u << entrySelector));
rangeShift.set (v * 16 > searchRange
? 16 * v - searchRange
: 0);
entrySelector = MAX (1u, hb_bit_storage (v)) - 1;
searchRange = 16 * (1u << entrySelector);
rangeShift = v * 16 > searchRange
? 16 * v - searchRange
: 0;
return *this;
}
protected:

View File

@ -124,14 +124,14 @@ struct CFFIndex
{
COUNT *dest = c->allocate_min<COUNT> ();
if (unlikely (dest == nullptr)) return_trace (false);
dest->set (0);
*dest = 0;
}
else
{
/* serialize CFFIndex header */
if (unlikely (!c->extend_min (*this))) return_trace (false);
this->count.set (byteArray.length);
this->offSize.set (offSize_);
this->count = byteArray.length;
this->offSize = offSize_;
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (byteArray.length + 1))))
return_trace (false);
@ -181,7 +181,7 @@ struct CFFIndex
for (; size; size--)
{
--p;
p->set (offset & 0xFF);
*p = offset & 0xFF;
offset >>= 8;
}
}
@ -275,8 +275,8 @@ struct CFFIndexOf : CFFIndex<COUNT>
TRACE_SERIALIZE (this);
/* serialize CFFIndex header */
if (unlikely (!c->extend_min (*this))) return_trace (false);
this->count.set (dataArrayLen);
this->offSize.set (offSize_);
this->count = dataArrayLen;
this->offSize = offSize_;
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (dataArrayLen + 1))))
return_trace (false);
@ -376,11 +376,11 @@ struct Dict : UnsizedByteStr
if (unlikely (p == nullptr)) return_trace (false);
if (Is_OpCode_ESC (op))
{
p->set (OpCode_escape);
*p = OpCode_escape;
op = Unmake_OpCode_ESC (op);
p++;
}
p->set (op);
*p = op;
return_trace (true);
}
@ -477,8 +477,8 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
this->count.set (fontDicts.length);
this->offSize.set (offSize_);
this->count = fontDicts.length;
this->offSize = offSize_;
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fontDicts.length + 1))))
return_trace (false);
@ -514,8 +514,8 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
this->count.set (fdCount);
this->offSize.set (offSize_);
this->count = fdCount;
this->offSize = offSize_;
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fdCount + 1))))
return_trace (false);

View File

@ -196,18 +196,18 @@ struct Encoding {
TRACE_SERIALIZE (this);
Encoding *dest = c->extend_min (*this);
if (unlikely (dest == nullptr)) return_trace (false);
dest->format.set (format | ((supp_codes.length > 0)? 0x80: 0));
dest->format = format | ((supp_codes.length > 0)? 0x80: 0);
if (format == 0)
{
Encoding0 *fmt0 = c->allocate_size<Encoding0> (Encoding0::min_size + HBUINT8::static_size * enc_count);
if (unlikely (fmt0 == nullptr)) return_trace (false);
fmt0->nCodes ().set (enc_count);
fmt0->nCodes () = enc_count;
unsigned int glyph = 0;
for (unsigned int i = 0; i < code_ranges.length; i++)
{
hb_codepoint_t code = code_ranges[i].code;
for (int left = (int)code_ranges[i].glyph; left >= 0; left--)
fmt0->codes[glyph++].set (code++);
fmt0->codes[glyph++] = code++;
if (unlikely (!((glyph <= 0x100) && (code <= 0x100))))
return_trace (false);
}
@ -216,24 +216,24 @@ struct Encoding {
{
Encoding1 *fmt1 = c->allocate_size<Encoding1> (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.length);
if (unlikely (fmt1 == nullptr)) return_trace (false);
fmt1->nRanges ().set (code_ranges.length);
fmt1->nRanges () = code_ranges.length;
for (unsigned int i = 0; i < code_ranges.length; i++)
{
if (unlikely (!((code_ranges[i].code <= 0xFF) && (code_ranges[i].glyph <= 0xFF))))
return_trace (false);
fmt1->ranges[i].first.set (code_ranges[i].code);
fmt1->ranges[i].nLeft.set (code_ranges[i].glyph);
fmt1->ranges[i].first = code_ranges[i].code;
fmt1->ranges[i].nLeft = code_ranges[i].glyph;
}
}
if (supp_codes.length > 0)
{
CFF1SuppEncData *suppData = c->allocate_size<CFF1SuppEncData> (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.length);
if (unlikely (suppData == nullptr)) return_trace (false);
suppData->nSups ().set (supp_codes.length);
suppData->nSups () = supp_codes.length;
for (unsigned int i = 0; i < supp_codes.length; i++)
{
suppData->supps[i].code.set (supp_codes[i].code);
suppData->supps[i].glyph.set (supp_codes[i].glyph); /* actually SID */
suppData->supps[i].code = supp_codes[i].code;
suppData->supps[i].glyph = supp_codes[i].glyph; /* actually SID */
}
}
return_trace (true);
@ -469,7 +469,7 @@ struct Charset {
TRACE_SERIALIZE (this);
Charset *dest = c->extend_min (*this);
if (unlikely (dest == nullptr)) return_trace (false);
dest->format.set (format);
dest->format = format;
if (format == 0)
{
Charset0 *fmt0 = c->allocate_size<Charset0> (Charset0::min_size + HBUINT16::static_size * (num_glyphs - 1));
@ -479,7 +479,7 @@ struct Charset {
{
hb_codepoint_t sid = sid_ranges[i].code;
for (int left = (int)sid_ranges[i].glyph; left >= 0; left--)
fmt0->sids[glyph++].set (sid++);
fmt0->sids[glyph++] = sid++;
}
}
else if (format == 1)
@ -490,8 +490,8 @@ struct Charset {
{
if (unlikely (!(sid_ranges[i].glyph <= 0xFF)))
return_trace (false);
fmt1->ranges[i].first.set (sid_ranges[i].code);
fmt1->ranges[i].nLeft.set (sid_ranges[i].glyph);
fmt1->ranges[i].first = sid_ranges[i].code;
fmt1->ranges[i].nLeft = sid_ranges[i].glyph;
}
}
else /* format 2 */
@ -502,8 +502,8 @@ struct Charset {
{
if (unlikely (!(sid_ranges[i].glyph <= 0xFFFF)))
return_trace (false);
fmt2->ranges[i].first.set (sid_ranges[i].code);
fmt2->ranges[i].nLeft.set (sid_ranges[i].glyph);
fmt2->ranges[i].first = sid_ranges[i].code;
fmt2->ranges[i].nLeft = sid_ranges[i].glyph;
}
}
return_trace (true);
@ -577,7 +577,7 @@ struct CFF1StringIndex : CFF1Index
{
if (!unlikely (c->extend_min (this->count)))
return_trace (false);
count.set (0);
count = 0;
return_trace (true);
}

View File

@ -89,15 +89,15 @@ struct CmapSubtableFormat4
if (unlikely (!c->extend_min (*this))) return_trace (false);
this->format.set (4);
this->length.set (get_sub_table_size (segments));
this->format = 4;
this->length = get_sub_table_size (segments);
this->segCountX2.set (segments.length * 2);
this->entrySelector.set (MAX (1u, hb_bit_storage (segments.length)) - 1);
this->searchRange.set (2 * (1u << this->entrySelector));
this->rangeShift.set (segments.length * 2 > this->searchRange
? 2 * segments.length - this->searchRange
: 0);
this->segCountX2 = segments.length * 2;
this->entrySelector = MAX (1u, hb_bit_storage (segments.length)) - 1;
this->searchRange = 2 * (1u << this->entrySelector);
this->rangeShift = segments.length * 2 > this->searchRange
? 2 * segments.length - this->searchRange
: 0;
HBUINT16 *end_count = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.length);
c->allocate_size<HBUINT16> (HBUINT16::static_size); // 2 bytes of padding.
@ -110,17 +110,17 @@ struct CmapSubtableFormat4
for (unsigned int i = 0; i < segments.length; i++)
{
end_count[i].set (segments[i].end_code);
start_count[i].set (segments[i].start_code);
end_count[i] = segments[i].end_code;
start_count[i] = segments[i].start_code;
if (segments[i].use_delta)
{
hb_codepoint_t cp = segments[i].start_code;
hb_codepoint_t start_gid = 0;
if (unlikely (!plan->new_gid_for_codepoint (cp, &start_gid) && cp != 0xFFFF))
return_trace (false);
id_delta[i].set (start_gid - segments[i].start_code);
id_delta[i] = start_gid - segments[i].start_code;
} else {
id_delta[i].set (0);
id_delta[i] = 0;
unsigned int num_codepoints = segments[i].end_code - segments[i].start_code + 1;
HBUINT16 *glyph_id_array = c->allocate_size<HBUINT16> (HBUINT16::static_size * num_codepoints);
if (glyph_id_array == nullptr)
@ -138,15 +138,14 @@ struct CmapSubtableFormat4
// id_range_offset[i]
// =
// 2 * (glyph_id_array - id_range_offset - i)
id_range_offset[i].set (2 * (
glyph_id_array - id_range_offset - i));
id_range_offset[i] = 2 * (glyph_id_array - id_range_offset - i);
for (unsigned int j = 0; j < num_codepoints; j++)
{
hb_codepoint_t cp = segments[i].start_code + j;
hb_codepoint_t new_gid;
if (unlikely (!plan->new_gid_for_codepoint (cp, &new_gid)))
return_trace (false);
glyph_id_array[j].set (new_gid);
glyph_id_array[j] = new_gid;
}
}
}
@ -198,11 +197,11 @@ struct CmapSubtableFormat4
cp != segment->end_code + 1u)
{
segment = segments->push ();
segment->start_code.set (cp);
segment->end_code.set (cp);
segment->start_code = cp;
segment->end_code = cp;
segment->use_delta = true;
} else {
segment->end_code.set (cp);
segment->end_code = cp;
if (last_gid + 1u != new_gid)
// gid's are not consecutive in this segment so delta
// cannot be used.
@ -216,8 +215,8 @@ struct CmapSubtableFormat4
if (segment == nullptr || segment->end_code != 0xFFFF)
{
segment = segments->push ();
segment->start_code.set (0xFFFF);
segment->end_code.set (0xFFFF);
segment->start_code = 0xFFFF;
segment->end_code = 0xFFFF;
segment->use_delta = true;
}
@ -523,9 +522,9 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
{
if (unlikely (!c->extend_min (*this))) return false;
this->format.set (12);
this->reserved.set (0);
this->length.set (get_sub_table_size (groups));
this->format = 12;
this->reserved = 0;
this->length = get_sub_table_size (groups);
return CmapSubtableLongSegmented<CmapSubtableFormat12>::serialize (c, groups);
}
@ -552,11 +551,11 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
if (!group || !_is_gid_consecutive (group, cp, new_gid))
{
group = groups->push ();
group->startCharCode.set (cp);
group->endCharCode.set (cp);
group->glyphID.set (new_gid);
group->startCharCode = cp;
group->endCharCode = cp;
group->glyphID = new_gid;
}
else group->endCharCode.set (cp);
else group->endCharCode = cp;
}
DEBUG_MSG(SUBSET, nullptr, "cmap");
@ -879,7 +878,7 @@ struct cmap
return false;
}
table->version.set (0);
table->version = 0;
if (unlikely (!table->encodingRecord.serialize (&c, /* numTables */ 3)))
return false;
@ -888,24 +887,24 @@ struct cmap
// Format 4, Plat 0 Encoding Record
EncodingRecord &format4_plat0_rec = table->encodingRecord[0];
format4_plat0_rec.platformID.set (0); // Unicode
format4_plat0_rec.encodingID.set (3);
format4_plat0_rec.platformID = 0; // Unicode
format4_plat0_rec.encodingID = 3;
// Format 4, Plat 3 Encoding Record
EncodingRecord &format4_plat3_rec = table->encodingRecord[1];
format4_plat3_rec.platformID.set (3); // Windows
format4_plat3_rec.encodingID.set (1); // Unicode BMP
format4_plat3_rec.platformID = 3; // Windows
format4_plat3_rec.encodingID = 1; // Unicode BMP
// Format 12 Encoding Record
EncodingRecord &format12_rec = table->encodingRecord[2];
format12_rec.platformID.set (3); // Windows
format12_rec.encodingID.set (10); // Unicode UCS-4
format12_rec.platformID = 3; // Windows
format12_rec.encodingID = 10; // Unicode UCS-4
// Write out format 4 sub table
{
CmapSubtable &subtable = format4_plat0_rec.subtable.serialize (&c, table);
format4_plat3_rec.subtable.set (format4_plat0_rec.subtable);
subtable.u.format.set (4);
format4_plat3_rec.subtable = format4_plat0_rec.subtable;
subtable.u.format = 4;
CmapSubtableFormat4 &format4 = subtable.u.format4;
if (unlikely (!format4.serialize (&c, plan, cmap_subset_plan.format4_segments)))
@ -915,7 +914,7 @@ struct cmap
// Write out format 12 sub table.
{
CmapSubtable &subtable = format12_rec.subtable.serialize (&c, table);
subtable.u.format.set (12);
subtable.u.format = 12;
CmapSubtableFormat12 &format12 = subtable.u.format12;
if (unlikely (!format12.serialize (&c, cmap_subset_plan.format12_groups)))
@ -1144,8 +1143,8 @@ struct cmap
unsigned int encoding_id) const
{
EncodingRecord key;
key.platformID.set (platform_id);
key.encodingID.set (encoding_id);
key.platformID = platform_id;
key.encodingID = encoding_id;
const EncodingRecord &result = encodingRecord.bsearch (key);
if (!result.subtable)

View File

@ -112,7 +112,7 @@ struct glyf
return false;
head *head_prime = (head *) hb_blob_get_data_writable (head_prime_blob, nullptr);
head_prime->indexToLocFormat.set (use_short_loca ? 0 : 1);
head_prime->indexToLocFormat = use_short_loca ? 0 : 1;
bool success = plan->add_table (HB_OT_TAG_head, head_prime_blob);
hb_blob_destroy (head_prime_blob);

View File

@ -88,8 +88,8 @@ struct DeviceRecord
return_trace (false);
}
this->pixelSize.set (subset_view.source_device_record->pixelSize);
this->maxWidth.set (subset_view.source_device_record->maxWidth);
this->pixelSize = subset_view.source_device_record->pixelSize;
this->maxWidth = subset_view.source_device_record->maxWidth;
for (unsigned int i = 0; i < subset_view.len (); i++)
{
@ -99,7 +99,7 @@ struct DeviceRecord
DEBUG_MSG(SUBSET, nullptr, "HDMX width for new gid %d is missing.", i);
return_trace (false);
}
widthsZ[i].set (*width);
widthsZ[i] = *width;
}
return_trace (true);
@ -141,9 +141,9 @@ struct hdmx
if (unlikely (!c->extend_min ((*this)))) return_trace (false);
this->version.set (source_hdmx->version);
this->numRecords.set (source_hdmx->numRecords);
this->sizeDeviceRecord.set (DeviceRecord::get_size (plan->num_output_glyphs ()));
this->version = source_hdmx->version;
this->numRecords = source_hdmx->numRecords;
this->sizeDeviceRecord = DeviceRecord::get_size (plan->num_output_glyphs ());
for (unsigned int i = 0; i < source_hdmx->numRecords; i++)
{

View File

@ -78,7 +78,7 @@ struct hmtxvmtx
unsigned int length;
H *table = (H *) hb_blob_get_data (dest_blob, &length);
table->numberOfLongMetrics.set (num_hmetrics);
table->numberOfLongMetrics = num_hmetrics;
bool result = plan->add_table (H::tableTag, dest_blob);
hb_blob_destroy (dest_blob);
@ -128,12 +128,12 @@ struct hmtxvmtx
bool has_advance = i < num_advances;
if (has_advance)
{
((LongMetric *) dest_pos)->advance.set (advance);
((LongMetric *) dest_pos)->sb.set (side_bearing);
((LongMetric *) dest_pos)->advance = advance;
((LongMetric *) dest_pos)->sb = side_bearing;
}
else
{
((FWORD *) dest_pos)->set (side_bearing);
*((FWORD *) dest_pos) = side_bearing;
}
dest_pos += (has_advance ? 4 : 2);
}

View File

@ -561,7 +561,7 @@ struct Feature
TRACE_SUBSET (this);
struct Feature *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
out->featureParams.set (0); /* TODO(subset) FeatureParams. */
out->featureParams = 0; /* TODO(subset) FeatureParams. */
return_trace (true);
}
@ -599,7 +599,7 @@ struct Feature
OffsetTo<FeatureParams> new_offset;
/* Check that it did not overflow. */
new_offset.set (new_offset_int);
new_offset = new_offset_int;
if (new_offset == new_offset_int &&
c->try_set (&featureParams, new_offset) &&
!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE))
@ -703,14 +703,14 @@ struct Lookup
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
lookupType.set (lookup_type);
lookupFlag.set (lookup_props & 0xFFFFu);
lookupType = lookup_type;
lookupFlag = lookup_props & 0xFFFFu;
if (unlikely (!subTable.serialize (c, num_subtables))) return_trace (false);
if (lookupFlag & LookupFlag::UseMarkFilteringSet)
{
if (unlikely (!c->extend (*this))) return_trace (false);
HBUINT16 &markFilteringSet = StructAfter<HBUINT16> (subTable);
markFilteringSet.set (lookup_props >> 16);
markFilteringSet = lookup_props >> 16;
}
return_trace (true);
}
@ -901,7 +901,7 @@ struct CoverageFormat2
if (unlikely (!glyphs))
{
rangeRecord.len.set (0);
rangeRecord.len = 0;
return_trace (true);
}
/* TODO(iter) Port to non-random-access iterator interface. */
@ -911,19 +911,19 @@ struct CoverageFormat2
for (unsigned int i = 1; i < count; i++)
if (glyphs[i - 1] + 1 != glyphs[i])
num_ranges++;
rangeRecord.len.set (num_ranges);
rangeRecord.len = num_ranges;
if (unlikely (!c->extend (rangeRecord))) return_trace (false);
unsigned int range = 0;
rangeRecord[range].start = glyphs[0];
rangeRecord[range].value.set (0);
rangeRecord[range].value = 0;
for (unsigned int i = 1; i < count; i++)
{
if (glyphs[i - 1] + 1 != glyphs[i])
{
range++;
rangeRecord[range].start = glyphs[i];
rangeRecord[range].value.set (i);
rangeRecord[range].value = i;
}
rangeRecord[range].end = glyphs[i];
}
@ -1066,7 +1066,7 @@ struct Coverage
for (unsigned int i = 1; i < count; i++)
if (glyphs[i - 1] + 1 != glyphs[i])
num_ranges++;
u.format.set (count * 2 < num_ranges * 3 ? 1 : 2);
u.format = count * 2 < num_ranges * 3 ? 1 : 2;
switch (u.format)
{
@ -1212,16 +1212,16 @@ struct ClassDefFormat1
if (unlikely (!glyphs))
{
startGlyph.set (0);
classValue.len.set (0);
startGlyph = 0;
classValue.len = 0;
return_trace (true);
}
hb_codepoint_t glyph_min = glyphs[0];
hb_codepoint_t glyph_max = glyphs[glyphs.length - 1];
startGlyph.set (glyph_min);
classValue.len.set (glyph_max - glyph_min + 1);
startGlyph = glyph_min;
classValue.len = glyph_max - glyph_min + 1;
if (unlikely (!c->extend (classValue))) return_trace (false);
for (unsigned int i = 0; i < glyphs.length; i++)
@ -1245,8 +1245,8 @@ struct ClassDefFormat1
if (!glyphset.has (g)) continue;
unsigned int value = classValue[g - start];
if (!value) continue;
glyphs.push()->set (glyph_map[g]);
klasses.push()->set (value);
glyphs.push(glyph_map[g]);
klasses.push(value);
}
c->serializer->propagate_error (glyphs, klasses);
ClassDef_serialize (c->serializer, glyphs, klasses);
@ -1348,7 +1348,7 @@ struct ClassDefFormat2
if (unlikely (!glyphs))
{
rangeRecord.len.set (0);
rangeRecord.len = 0;
return_trace (true);
}
@ -1357,12 +1357,12 @@ struct ClassDefFormat2
if (glyphs[i - 1] + 1 != glyphs[i] ||
klasses[i - 1] != klasses[i])
num_ranges++;
rangeRecord.len.set (num_ranges);
rangeRecord.len = num_ranges;
if (unlikely (!c->extend (rangeRecord))) return_trace (false);
unsigned int range = 0;
rangeRecord[range].start = glyphs[0];
rangeRecord[range].value.set (klasses[0]);
rangeRecord[range].value = klasses[0];
for (unsigned int i = 1; i < glyphs.length; i++)
{
if (glyphs[i - 1] + 1 != glyphs[i] ||
@ -1395,8 +1395,8 @@ struct ClassDefFormat2
for (hb_codepoint_t g = start; g < end; g++)
{
if (!glyphset.has (g)) continue;
glyphs.push ()->set (glyph_map[g]);
klasses.push ()->set (value);
glyphs.push (glyph_map[g]);
klasses.push (value);
}
}
c->serializer->propagate_error (glyphs, klasses);
@ -1519,7 +1519,7 @@ struct ClassDef
if (1 + (glyph_max - glyph_min + 1) < num_ranges * 3)
format = 1;
}
u.format.set (format);
u.format = format;
switch (u.format)
{

View File

@ -443,15 +443,15 @@ struct GDEF
if (unlikely (!out)) return_trace (false);
out->glyphClassDef.serialize_subset (c, this+glyphClassDef, out);
out->attachList.set (0);//TODO(subset) serialize_subset (c, this+attachList, out);
out->ligCaretList.set (0);//TODO(subset) serialize_subset (c, this+ligCaretList, out);
out->attachList = 0;//TODO(subset) serialize_subset (c, this+attachList, out);
out->ligCaretList = 0;//TODO(subset) serialize_subset (c, this+ligCaretList, out);
out->markAttachClassDef.serialize_subset (c, this+markAttachClassDef, out);
if (version.to_int () >= 0x00010002u)
out->markGlyphSetsDef.set (0);// TODO(subset) serialize_subset (c, this+markGlyphSetsDef, out);
out->markGlyphSetsDef = 0;// TODO(subset) serialize_subset (c, this+markGlyphSetsDef, out);
if (version.to_int () >= 0x00010003u)
out->varStore.set (0);// TODO(subset) serialize_subset (c, this+varStore, out);
out->varStore = 0;// TODO(subset) serialize_subset (c, this+varStore, out);
return_trace (true);
}

View File

@ -88,7 +88,7 @@ struct SingleSubstFormat1
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs))) return_trace (false);
deltaGlyphID.set (delta); /* TODO(serialize) overflow? */
deltaGlyphID = delta; /* TODO(serialize) overflow? */
return_trace (true);
}
@ -103,8 +103,8 @@ struct SingleSubstFormat1
for (auto it = hb_iter (this+coverage)
| hb_filter (glyphset); it; ++it)
{
from.push ()->set (glyph_map[*it]);
to.push ()->set (glyph_map[(*it + delta) & 0xFFFF]);
from.push (glyph_map[*it]);
to.push (glyph_map[(*it + delta) & 0xFFFF]);
}
c->serializer->propagate_error (from, to);
SingleSubst_serialize (c->serializer, from, to);
@ -193,8 +193,8 @@ struct SingleSubstFormat2
for (auto it = hb_zip (this+coverage, substitute)
| hb_filter (glyphset, hb_first); it; ++it)
{
from.push ()->set (glyph_map[(*it).first]);
to.push ()->set (glyph_map[(*it).second]);
from.push (glyph_map[(*it).first]);
to.push (glyph_map[(*it).second]);
}
c->serializer->propagate_error (from, to);
SingleSubst_serialize (c->serializer, from, to);
@ -240,7 +240,7 @@ struct SingleSubst
break;
}
}
u.format.set (format);
u.format = format;
switch (u.format) {
case 1: return_trace (u.format1.serialize (c, glyphs, delta));
case 2: return_trace (u.format2.serialize (c, glyphs, substitutes));
@ -433,7 +433,7 @@ struct MultipleSubst
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (u.format))) return_trace (false);
unsigned int format = 1;
u.format.set (format);
u.format = format;
switch (u.format) {
case 1: return_trace (u.format1.serialize (c, glyphs, substitute_len_list, substitute_glyphs_list));
default:return_trace (false);
@ -610,7 +610,7 @@ struct AlternateSubst
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (u.format))) return_trace (false);
unsigned int format = 1;
u.format.set (format);
u.format = format;
switch (u.format) {
case 1: return_trace (u.format1.serialize (c, glyphs, alternate_len_list, alternate_glyphs_list));
default:return_trace (false);
@ -942,7 +942,7 @@ struct LigatureSubst
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (u.format))) return_trace (false);
unsigned int format = 1;
u.format.set (format);
u.format = format;
switch (u.format) {
case 1: return_trace (u.format1.serialize (c,
first_glyphs,

View File

@ -77,7 +77,7 @@ struct maxp
void set_num_glyphs (unsigned int count)
{
numGlyphs.set (count);
numGlyphs = count;
}
bool sanitize (hb_sanitize_context_t *c) const
@ -119,13 +119,13 @@ struct maxp
if (maxp_prime->version.major == 1)
{
maxpV1Tail &v1 = StructAfter<maxpV1Tail> (*maxp_prime);
v1.maxZones.set (1);
v1.maxTwilightPoints.set (0);
v1.maxStorage.set (0);
v1.maxFunctionDefs.set (0);
v1.maxInstructionDefs.set (0);
v1.maxStackElements.set (0);
v1.maxSizeOfInstructions.set (0);
v1.maxZones = 1;
v1.maxTwilightPoints = 0;
v1.maxStorage = 0;
v1.maxFunctionDefs = 0;
v1.maxInstructionDefs = 0;
v1.maxStackElements = 0;
v1.maxSizeOfInstructions = 0;
}
}

View File

@ -160,8 +160,8 @@ struct OS2
uint16_t min_cp, max_cp;
find_min_and_max_codepoint (plan->unicodes, &min_cp, &max_cp);
os2_prime->usFirstCharIndex.set (min_cp);
os2_prime->usLastCharIndex.set (max_cp);
os2_prime->usFirstCharIndex = min_cp;
os2_prime->usLastCharIndex = max_cp;
_update_unicode_ranges (plan->unicodes, os2_prime->ulUnicodeRange);
bool result = plan->add_table (HB_OT_TAG_OS2, os2_prime_blob);
@ -174,7 +174,7 @@ struct OS2
HBUINT32 ulUnicodeRange[4]) const
{
for (unsigned int i = 0; i < 4; i++)
ulUnicodeRange[i].set (0);
ulUnicodeRange[i] = 0;
hb_codepoint_t cp = HB_SET_VALUE_INVALID;
while (codepoints->next (&cp)) {
@ -184,14 +184,14 @@ struct OS2
unsigned int block = bit / 32;
unsigned int bit_in_block = bit % 32;
unsigned int mask = 1 << bit_in_block;
ulUnicodeRange[block].set (ulUnicodeRange[block] | mask);
ulUnicodeRange[block] = ulUnicodeRange[block] | mask;
}
if (cp >= 0x10000 && cp <= 0x110000)
{
/* the spec says that bit 57 ("Non Plane 0") implies that there's
at least one codepoint beyond the BMP; so I also include all
the non-BMP codepoints here */
ulUnicodeRange[1].set (ulUnicodeRange[1] | (1 << 25));
ulUnicodeRange[1] = ulUnicodeRange[1] | (1 << 25);
}
}
}

View File

@ -88,7 +88,7 @@ struct post
return false;
}
post_prime->version.major.set (3); // Version 3 does not have any glyph names.
post_prime->version.major = 3; // Version 3 does not have any glyph names.
bool result = plan->add_table (HB_OT_TAG_post, post_prime_blob);
hb_blob_destroy (post_prime_blob);

View File

@ -66,8 +66,8 @@ arabic_fallback_synthesize_lookup_single (const hb_ot_shape_plan_t *plan HB_UNUS
u_glyph > 0xFFFFu || s_glyph > 0xFFFFu)
continue;
glyphs[num_glyphs].set (u_glyph);
substitutes[num_glyphs].set (s_glyph);
glyphs[num_glyphs] = u_glyph;
substitutes[num_glyphs] = s_glyph;
num_glyphs++;
}
@ -120,7 +120,7 @@ arabic_fallback_synthesize_lookup_ligature (const hb_ot_shape_plan_t *plan HB_UN
hb_codepoint_t first_glyph;
if (!hb_font_get_glyph (font, first_u, 0, &first_glyph))
continue;
first_glyphs[num_first_glyphs].set (first_glyph);
first_glyphs[num_first_glyphs] = first_glyph;
ligature_per_first_glyph_count_list[num_first_glyphs] = 0;
first_glyphs_indirection[num_first_glyphs] = first_glyph_idx;
num_first_glyphs++;
@ -146,9 +146,9 @@ arabic_fallback_synthesize_lookup_ligature (const hb_ot_shape_plan_t *plan HB_UN
ligature_per_first_glyph_count_list[i]++;
ligature_list[num_ligatures].set (ligature_glyph);
ligature_list[num_ligatures] = ligature_glyph;
component_count_list[num_ligatures] = 2;
component_list[num_ligatures].set (second_glyph);
component_list[num_ligatures] = second_glyph;
num_ligatures++;
}
}

View File

@ -81,11 +81,11 @@ struct VORG
if (unlikely (!c.extend_min (*subset_table)))
return false;
subset_table->version.major.set (1);
subset_table->version.minor.set (0);
subset_table->version.major = 1;
subset_table->version.minor = 0;
subset_table->defaultVertOriginY.set (vorg_table->defaultVertOriginY);
subset_table->vertYOrigins.len.set (subset_metrics.length);
subset_table->defaultVertOriginY = vorg_table->defaultVertOriginY;
subset_table->vertYOrigins.len = subset_metrics.length;
bool success = true;
if (subset_metrics.length > 0)
@ -130,8 +130,8 @@ struct VORG
if (plan->new_gid_for_old_gid (old_glyph, &new_glyph))
{
VertOriginMetric *metrics = subset_metrics.push ();
metrics->glyph.set (new_glyph);
metrics->vertOriginY.set (vertYOrigins[i].vertOriginY);
metrics->glyph = new_glyph;
metrics->vertOriginY = vertYOrigins[i].vertOriginY;
}
}
}

View File

@ -160,13 +160,13 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c,
TRACE_SERIALIZE (this);
FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size);
if (unlikely (p == nullptr)) return_trace (false);
p->nRanges ().set (fdselect_ranges.length);
p->nRanges () = fdselect_ranges.length;
for (unsigned int i = 0; i < fdselect_ranges.length; i++)
{
p->ranges[i].first.set (fdselect_ranges[i].glyph);
p->ranges[i].fd.set (fdselect_ranges[i].code);
p->ranges[i].first = fdselect_ranges[i].glyph;
p->ranges[i].fd = fdselect_ranges[i].code;
}
p->sentinel().set (num_glyphs);
p->sentinel() = num_glyphs;
return_trace (true);
}
@ -186,7 +186,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
TRACE_SERIALIZE (this);
FDSelect *p = c->allocate_min<FDSelect> ();
if (unlikely (p == nullptr)) return_trace (false);
p->format.set (fdselect_format);
p->format = fdselect_format;
size -= FDSelect::min_size;
switch (fdselect_format)
@ -205,7 +205,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
{
fd = fdselect_ranges[range_index++].code;
}
p->fds[i].set (fd);
p->fds[i] = fd;
}
break;
}

View File

@ -209,7 +209,7 @@ struct cff_font_dict_op_serializer_t : op_serializer_t
/* serialize the opcode */
HBUINT8 *p = c->allocate_size<HBUINT8> (1);
if (unlikely (p == nullptr)) return_trace (false);
p->set (OpCode_Private);
*p = OpCode_Private;
return_trace (true);
}

View File

@ -147,7 +147,7 @@ struct cff1_top_dict_op_serializer_t : cff_top_dict_op_serializer_t<cff1_top_dic
return_trace (false);
HBUINT8 *p = c->allocate_size<HBUINT8> (1);
if (unlikely (p == nullptr)) return_trace (false);
p->set (OpCode_Private);
*p = OpCode_Private;
}
break;
@ -892,10 +892,10 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
return false;
/* header */
cff->version.major.set (0x01);
cff->version.minor.set (0x00);
cff->nameIndex.set (cff->min_size);
cff->offSize.set (4); /* unused? */
cff->version.major = 0x01;
cff->version.minor = 0x00;
cff->nameIndex = cff->min_size;
cff->offSize = 4; /* unused? */
/* name INDEX */
{

View File

@ -451,14 +451,14 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
return false;
/* header */
cff2->version.major.set (0x02);
cff2->version.minor.set (0x00);
cff2->topDict.set (OT::cff2::static_size);
cff2->version.major = 0x02;
cff2->version.minor = 0x00;
cff2->topDict = OT::cff2::static_size;
/* top dict */
{
assert (cff2->topDict == (unsigned) (c.head - c.start));
cff2->topDictSize.set (plan.offsets.topDictInfo.size);
cff2->topDictSize = plan.offsets.topDictInfo.size;
TopDict &dict = cff2 + cff2->topDict;
cff2_top_dict_op_serializer_t topSzr;
if (unlikely (!dict.serialize (&c, acc.topDict, topSzr, plan.offsets)))

View File

@ -43,9 +43,9 @@ struct loca_data_t
if ((id + 1) * entry_size <= size)
{
if (is_short) {
((OT::HBUINT16*) data) [id].set (offset / 2);
((OT::HBUINT16*) data) [id] = offset / 2;
} else {
((OT::HBUINT32*) data) [id].set (offset);
((OT::HBUINT32*) data) [id] = offset;
}
return true;
}
@ -164,7 +164,7 @@ _update_components (const hb_subset_plan_t *plan,
&new_gid))
continue;
((OT::glyf::CompositeGlyphHeader *) iterator.current)->glyphIndex.set (new_gid);
((OT::glyf::CompositeGlyphHeader *) iterator.current)->glyphIndex = new_gid;
} while (iterator.move_to_next ());
}
}
@ -178,7 +178,7 @@ static bool _remove_composite_instruction_flag (char *glyf_prime, unsigned int l
do {
glyph = composite_it.current;
OT::HBUINT16 *flags = const_cast<OT::HBUINT16 *> (&glyph->flags);
flags->set ( (uint16_t) *flags & ~OT::glyf::CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS);
*flags = (uint16_t) *flags & ~OT::glyf::CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS;
} while (composite_it.move_to_next ());
return true;
}

View File

@ -396,18 +396,18 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
memcpy(new_sfnt_data, orig_sfnt_data, length);
OT::name &name = StructAtOffset<OT::name> (new_sfnt_data, name_table_offset);
name.format.set (0);
name.count.set (ARRAY_LENGTH (name_IDs));
name.stringOffset.set (name.get_size ());
name.format = 0;
name.count = ARRAY_LENGTH (name_IDs);
name.stringOffset = name.get_size ();
for (unsigned int i = 0; i < ARRAY_LENGTH (name_IDs); i++)
{
OT::NameRecord &record = name.nameRecordZ[i];
record.platformID.set (3);
record.encodingID.set (1);
record.languageID.set (0x0409u); /* English */
record.nameID.set (name_IDs[i]);
record.length.set (name_str_len * 2);
record.offset.set (0);
record.platformID = 3;
record.encodingID = 1;
record.languageID = 0x0409u; /* English */
record.nameID = name_IDs[i];
record.length = name_str_len * 2;
record.offset = 0;
}
/* Copy string data from new_name, converting wchar_t to UTF16BE. */
@ -431,8 +431,8 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
{
OT::TableRecord &record = const_cast<OT::TableRecord &> (face.get_table (index));
record.checkSum.set_for_data (&name, padded_name_table_length);
record.offset.set (name_table_offset);
record.length.set (name_table_length);
record.offset = name_table_offset;
record.length = name_table_length;
}
else if (face_index == 0) /* Fail if first face doesn't have 'name' table. */
{