[subset] minor, adjust spaces

This commit is contained in:
Ebrahim Byagowi 2018-11-15 23:10:56 +03:30
parent d7c50ff0d6
commit 11aa0468ac
19 changed files with 500 additions and 534 deletions

View File

@ -731,12 +731,9 @@ struct SortedArrayOf : ArrayOf<Type, LenType>
{
int mid = ((unsigned int) min + (unsigned int) max) / 2;
int c = arr[mid].cmp (x);
if (c < 0)
max = mid - 1;
else if (c > 0)
min = mid + 1;
else
return mid;
if (c < 0) max = mid - 1;
else if (c > 0) min = mid + 1;
else return mid;
}
return -1;
}
@ -871,12 +868,9 @@ struct VarSizedBinSearchArrayOf
int mid = ((unsigned int) min + (unsigned int) max) / 2;
const Type *p = (const Type *) (((const char *) &bytesZ) + (mid * size));
int c = p->cmp (key);
if (c < 0)
max = mid - 1;
else if (c > 0)
min = mid + 1;
else
return p;
if (c < 0) max = mid - 1;
else if (c > 0) min = mid + 1;
else return p;
}
return nullptr;
}

View File

@ -191,13 +191,11 @@ struct CmapSubtableFormat4
return false;
}
if (cp > 0xFFFF) {
// We are now outside of unicode BMP, stop adding to this cmap.
break;
}
/* Stop adding to cmap if we are now outside of unicode BMP. */
if (cp > 0xFFFF) break;
if (!segment
|| cp != segment->end_code + 1u)
if (!segment ||
cp != segment->end_code + 1u)
{
segment = segments->push ();
segment->start_code.set (cp);
@ -559,10 +557,8 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
group->startCharCode.set (cp);
group->endCharCode.set (cp);
group->glyphID.set (new_gid);
} else
{
group->endCharCode.set (cp);
}
else group->endCharCode.set (cp);
}
DEBUG_MSG(SUBSET, nullptr, "cmap");

View File

@ -154,23 +154,18 @@ struct glyf
inline unsigned int get_size (void) const
{
unsigned int size = min_size;
if (flags & ARG_1_AND_2_ARE_WORDS) {
// arg1 and 2 are int16
size += 4;
} else {
if (flags & ARG_1_AND_2_ARE_WORDS) size += 4;
// arg1 and 2 are int8
size += 2;
}
if (flags & WE_HAVE_A_SCALE) {
else size += 2;
// One x 16 bit (scale)
size += 2;
} else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
if (flags & WE_HAVE_A_SCALE) size += 2;
// Two x 16 bit (xscale, yscale)
size += 4;
} else if (flags & WE_HAVE_A_TWO_BY_TWO) {
else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) size += 4;
// Four x 16 bit (xscale, scale01, scale10, yscale)
size += 8;
}
else if (flags & WE_HAVE_A_TWO_BY_TWO) size += 8;
return size;
}
@ -285,8 +280,7 @@ struct glyf
inline bool remove_padding (unsigned int start_offset,
unsigned int *end_offset) const
{
if (*end_offset - start_offset < GlyphHeader::static_size)
return true;
if (*end_offset - start_offset < GlyphHeader::static_size) return true;
const char *glyph = ((const char *) glyf_table) + start_offset;
const char * const glyph_end = glyph + (*end_offset - start_offset);
@ -330,15 +324,11 @@ struct glyf
unsigned int xBytes, yBytes;
xBytes = yBytes = 0;
if (flag & FLAG_X_SHORT)
xBytes = 1;
else if ((flag & FLAG_X_SAME) == 0)
xBytes = 2;
if (flag & FLAG_X_SHORT) xBytes = 1;
else if ((flag & FLAG_X_SAME) == 0) xBytes = 2;
if (flag & FLAG_Y_SHORT)
yBytes = 1;
else if ((flag & FLAG_Y_SAME) == 0)
yBytes = 2;
if (flag & FLAG_Y_SHORT) yBytes = 1;
else if ((flag & FLAG_Y_SAME) == 0) yBytes = 2;
coordBytes += (xBytes + yBytes) * repeat;
coordsWithFlags += repeat;

View File

@ -96,8 +96,8 @@ struct hmtxvmtx
hb_vector_t<hb_codepoint_t> &gids = plan->glyphs;
unsigned int num_advances = gids.len;
unsigned int last_advance = _mtx.get_advance (gids[num_advances - 1]);
while (num_advances > 1
&& last_advance == _mtx.get_advance (gids[num_advances - 2]))
while (num_advances > 1 &&
last_advance == _mtx.get_advance (gids[num_advances - 2]))
{
num_advances--;
}

View File

@ -1232,10 +1232,7 @@ struct ClassDefFormat1
inline bool add_class (set_t *glyphs, unsigned int klass) const {
unsigned int count = classValue.len;
for (unsigned int i = 0; i < count; i++)
{
if (classValue[i] == klass)
glyphs->add (startGlyph + i);
}
if (classValue[i] == klass) glyphs->add (startGlyph + i);
return true;
}
@ -1246,8 +1243,7 @@ struct ClassDefFormat1
hb_codepoint_t end = startGlyph + classValue.len;
for (hb_codepoint_t iter = startGlyph - 1;
hb_set_next (glyphs, &iter) && iter < end;)
if (classValue[iter - start])
return true;
if (classValue[iter - start]) return true;
return false;
}
inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const {
@ -1256,13 +1252,10 @@ struct ClassDefFormat1
{
/* Match if there's any glyph that is not listed! */
hb_codepoint_t g = HB_SET_VALUE_INVALID;
if (!hb_set_next (glyphs, &g))
return false;
if (g < startGlyph)
return true;
if (!hb_set_next (glyphs, &g)) return false;
if (g < startGlyph) return true;
g = startGlyph + count - 1;
if (hb_set_next (glyphs, &g))
return true;
if (hb_set_next (glyphs, &g)) return true;
/* Fall through. */
}
for (unsigned int i = 0; i < count; i++)

View File

@ -105,8 +105,7 @@ struct post
unsigned int table_length = table.get_length ();
version = table->version.to_int ();
if (version != 0x00020000)
return;
if (version != 0x00020000) return;
const postV2Tail &v2 = table->v2;
@ -130,10 +129,8 @@ struct post
char *buf, unsigned int buf_len) const
{
hb_bytes_t s = find_glyph_name (glyph);
if (!s.len)
return false;
if (!buf_len)
return true;
if (!s.len) return false;
if (!buf_len) return true;
unsigned int len = MIN (buf_len - 1, s.len);
strncpy (buf, s.arrayZ, len);
buf[len] = '\0';
@ -144,14 +141,11 @@ struct post
hb_codepoint_t *glyph) const
{
unsigned int count = get_glyph_count ();
if (unlikely (!count))
return false;
if (unlikely (!count)) return false;
if (len < 0)
len = strlen (name);
if (len < 0) len = strlen (name);
if (unlikely (!len))
return false;
if (unlikely (!len)) return false;
retry:
uint16_t *gids = gids_sorted_by_name.get ();

View File

@ -53,8 +53,8 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
*instruction_end = 0;
unsigned int start_offset, end_offset;
if (unlikely (!(glyf.get_offsets(next_glyph, &start_offset, &end_offset)
&& glyf.remove_padding(start_offset, &end_offset))))
if (unlikely (!(glyf.get_offsets (next_glyph, &start_offset, &end_offset) &&
glyf.remove_padding (start_offset, &end_offset))))
{
DEBUG_MSG(SUBSET, nullptr, "Invalid gid %d", next_glyph);
continue;
@ -170,8 +170,8 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan,
for (unsigned int i = 0; i < glyph_ids.len; i++)
{
unsigned int start_offset, end_offset;
if (unlikely (!(glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset)
&& glyf.remove_padding(start_offset, &end_offset))))
if (unlikely (!(glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset) &&
glyf.remove_padding (start_offset, &end_offset))))
end_offset = start_offset = 0;
unsigned int instruction_start = instruction_ranges[i * 2];

View File

@ -69,8 +69,7 @@ hb_subset_input_get_drop_layout (hb_subset_input_t *subset_input);
/* hb_subset () */
HB_EXTERN hb_face_t *
hb_subset (hb_face_t *source,
hb_subset_input_t *input);
hb_subset (hb_face_t *source, hb_subset_input_t *input);
HB_END_DECLS