if (unlikely (stop > states))
return_trace (false);
for (const HBUSHORT *p = states; stop < p; p--)
- num_entries = MAX<unsigned int> (num_entries, *(p - 1) + 1);
+ num_entries = hb_max (num_entries, *(p - 1) + 1);
state_neg = min_state;
}
}
if (unlikely (stop < states))
return_trace (false);
for (const HBUSHORT *p = &states[state_pos * num_classes]; p < stop; p++)
- num_entries = MAX<unsigned int> (num_entries, *p + 1);
+ num_entries = hb_max (num_entries, *p + 1);
state_pos = max_state + 1;
}
}
for (const Entry<Extra> *p = &entries[entry]; p < stop; p++)
{
int newState = new_state (p->newState);
- min_state = MIN (min_state, newState);
- max_state = MAX (max_state, newState);
+ min_state = hb_min (min_state, newState);
+ max_state = hb_max (max_state, newState);
}
entry = num_entries;
}
unsigned int feature_count = featureNameCount;
if (count && *count)
{
- unsigned int len = MIN (feature_count - start_offset, *count);
+ unsigned int len = hb_min (feature_count - start_offset, *count);
for (unsigned int i = 0; i < len; i++)
features[i] = namesZ[i + start_offset].get_feature_type ();
*count = len;
if (Format1EntryT::performAction (entry) && depth)
{
- unsigned int tuple_count = MAX (1u, table->header.tuple_count ());
+ unsigned int tuple_count = hb_max (1u, table->header.tuple_count ());
unsigned int kern_idx = Format1EntryT::kernActionIndex (entry);
kern_idx = Types::byteOffsetToIndex (kern_idx, &table->machine, kernAction.arrayZ);
start = buffer->idx;
if (flags & MarkLast)
- end = MIN (buffer->idx + 1, buffer->len);
+ end = hb_min (buffer->idx + 1, buffer->len);
if ((flags & Verb) && start < end)
{
};
unsigned int m = map[flags & Verb];
- unsigned int l = MIN<unsigned int> (2, m >> 4);
- unsigned int r = MIN<unsigned int> (2, m & 0x0F);
+ unsigned int l = hb_min (2u, m >> 4);
+ unsigned int r = hb_min (2u, m & 0x0F);
bool reverse_l = 3 == (m >> 4);
bool reverse_r = 3 == (m & 0x0F);
if (end - start >= l + r)
{
- buffer->merge_clusters (start, MIN (buffer->idx + 1, buffer->len));
+ buffer->merge_clusters (start, hb_min (buffer->idx + 1, buffer->len));
buffer->merge_clusters (start, end);
hb_glyph_info_t *info = buffer->info;
}
if (replacement)
{
- buffer->unsafe_to_break (mark, MIN (buffer->idx + 1, buffer->len));
+ buffer->unsafe_to_break (mark, hb_min (buffer->idx + 1, buffer->len));
buffer->info[mark].codepoint = *replacement;
ret = true;
}
replacement = nullptr;
- unsigned int idx = MIN (buffer->idx, buffer->len - 1);
+ unsigned int idx = hb_min (buffer->idx, buffer->len - 1);
if (Types::extended)
{
if (entry.data.currentIndex != 0xFFFF)
const EntryData &data = entries[i].data;
if (data.markIndex != 0xFFFF)
- num_lookups = MAX<unsigned int> (num_lookups, 1 + data.markIndex);
+ num_lookups = hb_max (num_lookups, 1 + data.markIndex);
if (data.currentIndex != 0xFFFF)
- num_lookups = MAX<unsigned int> (num_lookups, 1 + data.currentIndex);
+ num_lookups = hb_max (num_lookups, 1 + data.currentIndex);
}
return_trace (substitutionTables.sanitize (c, this, num_lookups));
buffer->move_to (end + count);
- buffer->unsafe_to_break_from_outbuffer (mark, MIN (buffer->idx + 1, buffer->len));
+ buffer->unsafe_to_break_from_outbuffer (mark, hb_min (buffer->idx + 1, buffer->len));
}
if (flags & SetMark)
}
HB_FUNCOBJ (hb_second);
+/* Note. In min/max, we can use hb_type_identity<T> for second argument.
+ * However, that would silently convert between different-signedness integers.
+ * Instead we accept two different types, such that compiler can err if
+ * comparing integers of different signedness. */
struct
{
template <typename T, typename T2> auto
static inline unsigned char TOLOWER (unsigned char c)
{ return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c; }
-#undef MIN
-template <typename Type>
-static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; }
-
-#undef MAX
-template <typename Type>
-static inline Type MAX (const Type &a, const Type &b) { return a > b ? a : b; }
-
static inline unsigned int DIV_CEIL (const unsigned int a, unsigned int b)
{ return (a + (b - 1)) / b; }
{
/* Pain because we don't know whether s is nul-terminated. */
char buf[64];
- len = MIN (ARRAY_LENGTH (buf) - 1, len);
+ len = hb_min (ARRAY_LENGTH (buf) - 1, len);
strncpy (buf, s, len);
buf[len] = '\0';
}
void qsort (unsigned int start, unsigned int end)
{
- end = MIN (end, length);
+ end = hb_min (end, length);
assert (start <= end);
if (likely (start < end))
::qsort (arrayZ + start, end - start, this->item_size, Type::cmp);
else
count -= start_offset;
if (seg_count)
- count = *seg_count = MIN (count, *seg_count);
+ count = *seg_count = hb_min (count, *seg_count);
return hb_array_t<Type> (arrayZ + start_offset, count);
}
hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const
hb_blob_make_immutable (parent);
blob = hb_blob_create (parent->data + offset,
- MIN (length, parent->length - offset),
+ hb_min (length, parent->length - offset),
HB_MEMORY_MODE_READONLY,
hb_blob_reference (parent),
_hb_blob_destroy);
*p++ = '"';
}
else
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster));
}
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS))
{
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"dx\":%d,\"dy\":%d",
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"dx\":%d,\"dy\":%d",
x+pos[i].x_offset, y+pos[i].y_offset));
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"ax\":%d,\"ay\":%d",
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"ax\":%d,\"ay\":%d",
pos[i].x_advance, pos[i].y_advance));
}
if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS)
{
if (info[i].mask & HB_GLYPH_FLAG_DEFINED)
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"fl\":%u", info[i].mask & HB_GLYPH_FLAG_DEFINED));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"fl\":%u", info[i].mask & HB_GLYPH_FLAG_DEFINED));
}
if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS)
{
hb_glyph_extents_t extents;
hb_font_get_glyph_extents(font, info[i].codepoint, &extents);
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"xb\":%d,\"yb\":%d",
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"xb\":%d,\"yb\":%d",
extents.x_bearing, extents.y_bearing));
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"w\":%d,\"h\":%d",
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"w\":%d,\"h\":%d",
extents.width, extents.height));
}
p += strlen (p);
}
else
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster));
}
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS))
{
if (x+pos[i].x_offset || y+pos[i].y_offset)
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "@%d,%d", x+pos[i].x_offset, y+pos[i].y_offset));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "@%d,%d", x+pos[i].x_offset, y+pos[i].y_offset));
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
{
*p++ = '+';
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance));
if (pos[i].y_advance)
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance));
}
}
if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS)
{
if (info[i].mask & HB_GLYPH_FLAG_DEFINED)
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "#%X", info[i].mask &HB_GLYPH_FLAG_DEFINED));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "#%X", info[i].mask &HB_GLYPH_FLAG_DEFINED));
}
if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS)
{
hb_glyph_extents_t extents;
hb_font_get_glyph_extents(font, info[i].codepoint, &extents);
- p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "<%d,%d,%d,%d>", extents.x_bearing, extents.y_bearing, extents.width, extents.height));
+ p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "<%d,%d,%d,%d>", extents.x_bearing, extents.y_bearing, extents.width, extents.height));
}
unsigned int l = p - b;
parse_uint (const char *pp, const char *end, uint32_t *pv)
{
char buf[32];
- unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - pp));
+ unsigned int len = hb_min (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - pp));
strncpy (buf, pp, len);
buf[len] = '\0';
parse_int (const char *pp, const char *end, int32_t *pv)
{
char buf[32];
- unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - pp));
+ unsigned int len = hb_min (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - pp));
strncpy (buf, pp, len);
buf[len] = '\0';
unsigned int cluster = info[start].cluster;
for (unsigned int i = start + 1; i < end; i++)
- cluster = MIN<unsigned int> (cluster, info[i].cluster);
+ cluster = hb_min (cluster, info[i].cluster);
/* Extend end */
while (end < len && info[end - 1].cluster == info[end].cluster)
unsigned int cluster = out_info[start].cluster;
for (unsigned int i = start + 1; i < end; i++)
- cluster = MIN<unsigned int> (cluster, out_info[i].cluster);
+ cluster = hb_min (cluster, out_info[i].cluster);
/* Extend start */
while (start && out_info[start - 1].cluster == out_info[start].cluster)
unsigned int cluster) const
{
for (unsigned int i = start; i < end; i++)
- cluster = MIN<unsigned int> (cluster, infos[i].cluster);
+ cluster = hb_min (cluster, infos[i].cluster);
return cluster;
}
void
{
/* NUL-terminate it. */
char strbuf[64];
- len = MIN (len, (int) sizeof (strbuf) - 1);
+ len = hb_min (len, (int) sizeof (strbuf) - 1);
memcpy (strbuf, str, len);
strbuf[len] = '\0';
item = lang_find_or_insert (strbuf);
parse_uint (const char **pp, const char *end, unsigned int *pv)
{
char buf[32];
- unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
+ unsigned int len = hb_min (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
strncpy (buf, *pp, len);
buf[len] = '\0';
parse_uint32 (const char **pp, const char *end, uint32_t *pv)
{
char buf[32];
- unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
+ unsigned int len = hb_min (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
strncpy (buf, *pp, len);
buf[len] = '\0';
parse_float (const char **pp, const char *end, float *pv)
{
char buf[32];
- unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
+ unsigned int len = hb_min (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
strncpy (buf, *pp, len);
buf[len] = '\0';
{
s[len++] = '[';
if (feature->start)
- len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->start));
+ len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->start));
if (feature->end != feature->start + 1) {
s[len++] = ':';
if (feature->end != (unsigned int) -1)
- len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->end));
+ len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->end));
}
s[len++] = ']';
}
if (feature->value > 1)
{
s[len++] = '=';
- len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->value));
+ len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->value));
}
assert (len < ARRAY_LENGTH (s));
- len = MIN (len, size - 1);
+ len = hb_min (len, size - 1);
memcpy (buf, s, len);
buf[len] = '\0';
}
while (len && s[len - 1] == ' ')
len--;
s[len++] = '=';
- len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%g", (double) variation->value));
+ len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%g", (double) variation->value));
assert (len < ARRAY_LENGTH (s));
- len = MIN (len, size - 1);
+ len = hb_min (len, size - 1);
memcpy (buf, s, len);
buf[len] = '\0';
}
feature.start < chars_len && feature.start < feature.end)
{
CFRange feature_range = CFRangeMake (feature.start,
- MIN (feature.end, chars_len) - feature.start);
+ hb_min (feature.end, chars_len) - feature.start);
if (feature.value)
CFAttributedStringRemoveAttribute (attr_string, feature_range, kCTKernAttributeName);
else
unsigned int cluster = info[count - 1].cluster;
for (unsigned int i = count - 1; i > 0; i--)
{
- cluster = MIN (cluster, info[i - 1].cluster);
+ cluster = hb_min (cluster, info[i - 1].cluster);
info[i - 1].cluster = cluster;
}
}
unsigned int cluster = info[0].cluster;
for (unsigned int i = 1; i < count; i++)
{
- cluster = MIN (cluster, info[i].cluster);
+ cluster = hb_min (cluster, info[i].cluster);
info[i].cluster = cluster;
}
}
VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR;
fprintf (stderr, "%2u %s" VRBAR "%s",
level,
- bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars) - 1, (unsigned int) (sizeof (VBAR) - 1) * level),
+ bars + sizeof (bars) - 1 - hb_min ((unsigned int) sizeof (bars) - 1, (unsigned int) (sizeof (VBAR) - 1) * level),
level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR);
} else
fprintf (stderr, " " VRBAR LBAR);
{
uint32_t *p =
&vis_clusters[log_clusters[buffer->info[i].utf16_index ()]];
- *p = MIN (*p, buffer->info[i].cluster);
+ *p = hb_min (*p, buffer->info[i].cluster);
}
for (unsigned int i = 1; i < glyphCount; i++)
if (vis_clusters[i] == (uint32_t) -1)
else {
/* Make a nul-terminated version. */
char buf[128];
- len = MIN (len, (int) sizeof (buf) - 1);
+ len = hb_min (len, (int) sizeof (buf) - 1);
strncpy (buf, name, len);
buf[len] = '\0';
*glyph = FT_Get_Name_Index (ft_face, buf);
__item_t__ __item__ () const { return __item_t__ (*a, *b); }
__item_t__ __item_at__ (unsigned i) const { return __item_t__ (a[i], b[i]); }
bool __more__ () const { return a && b; }
- unsigned __len__ () const { return MIN (a.len (), b.len ()); }
+ unsigned __len__ () const { return hb_min (a.len (), b.len ()); }
void __next__ () { ++a; ++b; }
void __forward__ (unsigned n) { a += n; b += n; }
void __prev__ () { --a; --b; }
if (start_offset >= tables.len)
*table_count = 0;
else
- *table_count = MIN<unsigned int> (*table_count, tables.len - start_offset);
+ *table_count = hb_min (*table_count, tables.len - start_offset);
const TableRecord *sub_tables = tables.arrayZ + start_offset;
unsigned int count = *table_count;
{
len = v;
assert (len == v);
- entrySelector = MAX (1u, hb_bit_storage (v)) - 1;
+ entrySelector = hb_max (1u, hb_bit_storage (v)) - 1;
searchRange = 16 * (1u << entrySelector);
rangeShift = v * 16 > searchRange
? 16 * v - searchRange
this->length = get_sub_table_size (segments);
this->segCountX2 = segments.length * 2;
- this->entrySelector = MAX (1u, hb_bit_storage (segments.length)) - 1;
+ this->entrySelector = hb_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
/* Some broken fonts have too long of a "length" value.
* If that is the case, just change the value to truncate
* the subtable at the end of the blob. */
- uint16_t new_length = (uint16_t) MIN ((uintptr_t) 65535,
+ uint16_t new_length = (uint16_t) hb_min ((uintptr_t) 65535,
(uintptr_t) (c->end -
(char *) this));
if (!c->try_set (&length, new_length))
{
for (unsigned int i = 0; i < this->groups.len; i++) {
out->add_range (this->groups[i].startCharCode,
- MIN ((hb_codepoint_t) this->groups[i].endCharCode,
+ hb_min ((hb_codepoint_t) this->groups[i].endCharCode,
(hb_codepoint_t) HB_UNICODE_MAX));
}
}
for (unsigned int i = 0; i < count; i++)
{
hb_codepoint_t first = arrayZ[i].startUnicodeValue;
- hb_codepoint_t last = MIN ((hb_codepoint_t) (first + arrayZ[i].additionalCount),
+ hb_codepoint_t last = hb_min ((hb_codepoint_t) (first + arrayZ[i].additionalCount),
(hb_codepoint_t) HB_UNICODE_MAX);
out->add_range (first, last);
}
if (unlikely (!count))
return Null(BitmapSizeTable);
- unsigned int requested_ppem = MAX (font->x_ppem, font->y_ppem);
+ unsigned int requested_ppem = hb_max (font->x_ppem, font->y_ppem);
if (!requested_ppem)
requested_ppem = 1<<30; /* Choose largest strike. */
unsigned int best_i = 0;
- unsigned int best_ppem = MAX (sizeTables[0].ppemX, sizeTables[0].ppemY);
+ unsigned int best_ppem = hb_max (sizeTables[0].ppemX, sizeTables[0].ppemY);
for (unsigned int i = 1; i < count; i++)
{
- unsigned int ppem = MAX (sizeTables[i].ppemX, sizeTables[i].ppemY);
+ unsigned int ppem = hb_max (sizeTables[i].ppemX, sizeTables[i].ppemY);
if ((requested_ppem <= ppem && ppem < best_ppem) ||
(requested_ppem > best_ppem && ppem > best_ppem))
{
{
hb_array_t<const BGRAColor> segment_colors = palette_colors.sub_array (start_offset, *color_count);
/* Always return numColors colors per palette even if it has out-of-bounds start index. */
- unsigned int count = MIN<unsigned int> (MAX<int> (numColors - start_offset, 0), *color_count);
+ unsigned int count = hb_min ((unsigned) hb_max ((int) (numColors - start_offset), 0), *color_count);
*color_count = count;
for (unsigned int i = 0; i < count; i++)
colors[i] = segment_colors[i]; /* Bound-checked read. */
if (unlikely (!count))
return Null(SBIXStrike);
- unsigned int requested_ppem = MAX (font->x_ppem, font->y_ppem);
+ unsigned int requested_ppem = hb_max (font->x_ppem, font->y_ppem);
if (!requested_ppem)
requested_ppem = 1<<30; /* Choose largest strike. */
/* TODO Add DPI sensitivity as well? */
public:
DEFINE_SIZE_MIN (0); /* In reality, this is UNBOUNDED() type; but since we always
* check the size externally, allow Null() object of it by
- * defining it MIN() instead. */
+ * defining it _MIN instead. */
};
loca_table = hb_sanitize_context_t ().reference_table<loca> (face);
glyf_table = hb_sanitize_context_t ().reference_table<glyf> (face);
- num_glyphs = MAX (1u, loca_table.get_length () / (short_offset ? 2 : 4)) - 1;
+ num_glyphs = hb_max (1u, loca_table.get_length () / (short_offset ? 2 : 4)) - 1;
}
void fini ()
const GlyphHeader &glyph_header = StructAtOffset<GlyphHeader> (glyf_table, start_offset);
- extents->x_bearing = MIN (glyph_header.xMin, glyph_header.xMax);
- extents->y_bearing = MAX (glyph_header.yMin, glyph_header.yMax);
- extents->width = MAX (glyph_header.xMin, glyph_header.xMax) - extents->x_bearing;
- extents->height = MIN (glyph_header.yMin, glyph_header.yMax) - extents->y_bearing;
+ extents->x_bearing = hb_min (glyph_header.xMin, glyph_header.xMax);
+ extents->y_bearing = hb_max (glyph_header.yMin, glyph_header.yMax);
+ extents->width = hb_max (glyph_header.xMin, glyph_header.xMax) - extents->x_bearing;
+ extents->height = hb_min (glyph_header.yMin, glyph_header.yMax) - extents->y_bearing;
return true;
}
public:
DEFINE_SIZE_MIN (0); /* In reality, this is UNBOUNDED() type; but since we always
* check the size externally, allow Null() object of it by
- * defining it MIN() instead. */
+ * defining it _MIN instead. */
};
struct glyf_accelerator_t : glyf::accelerator_t {};
return default_advance;
}
- return table->longMetricZ[MIN (glyph, (uint32_t) num_advances - 1)].advance;
+ return table->longMetricZ[hb_min (glyph, (uint32_t) num_advances - 1)].advance;
}
unsigned int get_advance (hb_codepoint_t glyph,
unsigned int mark_id = _hb_glyph_info_get_lig_id (&buffer->cur());
unsigned int mark_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
if (lig_id && lig_id == mark_id && mark_comp > 0)
- comp_index = MIN (comp_count, _hb_glyph_info_get_lig_comp (&buffer->cur())) - 1;
+ comp_index = hb_min (comp_count, _hb_glyph_info_get_lig_comp (&buffer->cur())) - 1;
else
comp_index = comp_count - 1;
unsigned int shift = hb_ctz (lookup_mask);
unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift);
- /* If alt_index is MAX, randomize feature if it is the rand feature. */
+ /* If alt_index is MAX_VALUE, randomize feature if it is the rand feature. */
if (alt_index == HB_OT_MAP_MAX_VALUE && c->random)
alt_index = c->random_number () % count + 1;
if (unlikely (!ligature.serialize (c, ligatures.length))) return_trace (false);
for (unsigned int i = 0; i < ligatures.length; i++)
{
- unsigned int component_count = MAX<int> (component_count_list[i] - 1, 0);
+ unsigned int component_count = (unsigned) hb_max ((int) component_count_list[i] - 1, 0);
if (unlikely (!ligature[i].serialize (c, this)
.serialize (c,
ligatures[i],
if (this_comp == 0)
this_comp = last_num_components;
unsigned int new_lig_comp = components_so_far - last_num_components +
- MIN (this_comp, last_num_components);
+ hb_min (this_comp, last_num_components);
_hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, new_lig_comp);
}
buffer->next_glyph ();
if (!this_comp)
break;
unsigned int new_lig_comp = components_so_far - last_num_components +
- MIN (this_comp, last_num_components);
+ hb_min (this_comp, last_num_components);
_hb_glyph_info_set_lig_props_for_mark (&buffer->info[i], lig_id, new_lig_comp);
} else
break;
else
{
/* NOTE: delta is negative. */
- delta = MAX (delta, (int) next - (int) count);
+ delta = hb_max (delta, (int) next - (int) count);
next -= delta;
}
unsigned int len = 0;
if (char_count && characters && start_offset < cv_params.characters.len)
{
- len = MIN (cv_params.characters.len - start_offset, *char_count);
+ len = hb_min (cv_params.characters.len - start_offset, *char_count);
for (unsigned int i = 0; i < len; ++i)
characters[i] = cv_params.characters[start_offset + i];
}
feature_infos[j].default_value = feature_infos[i].default_value;
} else {
feature_infos[j].flags &= ~F_GLOBAL;
- feature_infos[j].max_value = MAX (feature_infos[j].max_value, feature_infos[i].max_value);
+ feature_infos[j].max_value = hb_max (feature_infos[j].max_value, feature_infos[i].max_value);
/* Inherit default_value from j */
}
feature_infos[j].flags |= (feature_infos[i].flags & F_HAS_FALLBACK);
- feature_infos[j].stage[0] = MIN (feature_infos[j].stage[0], feature_infos[i].stage[0]);
- feature_infos[j].stage[1] = MIN (feature_infos[j].stage[1], feature_infos[i].stage[1]);
+ feature_infos[j].stage[0] = hb_min (feature_infos[j].stage[0], feature_infos[i].stage[0]);
+ feature_infos[j].stage[1] = hb_min (feature_infos[j].stage[1], feature_infos[i].stage[1]);
}
feature_infos.shrink (j + 1);
}
bits_needed = 0;
else
/* Limit bits per feature. */
- bits_needed = MIN(HB_OT_MAP_MAX_BITS, hb_bit_storage (info->max_value));
+ bits_needed = hb_min (HB_OT_MAP_MAX_BITS, hb_bit_storage (info->max_value));
if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t))
continue; /* Feature disabled, or not enough bits. */
hb_bytes_t s = find_glyph_name (glyph);
if (!s.length) return false;
if (!buf_len) return true;
- unsigned int len = MIN (buf_len - 1, s.length);
+ unsigned int len = hb_min (buf_len - 1, s.length);
strncpy (buf, s.arrayZ, len);
buf[len] = '\0';
return true;
/* Reorder characters */
for (unsigned int i = start; i < base; i++)
- info[i].indic_position() = MIN (POS_PRE_C, (indic_position_t) info[i].indic_position());
+ info[i].indic_position() = hb_min (POS_PRE_C, (indic_position_t) info[i].indic_position());
if (base < end)
info[base].indic_position() = POS_BASE_C;
unsigned int j = start + info[i].syllable();
while (j != i)
{
- max = MAX (max, j);
+ max = hb_max (max, j);
unsigned int next = start + info[j].syllable();
info[j].syllable() = 255; /* So we don't process j later again. */
j = next;
/* Note: this merge_clusters() is intentionally *after* the reordering.
* Indic matra reordering is special and tricky... */
- buffer->merge_clusters (new_pos, MIN (end, base + 1));
+ buffer->merge_clusters (new_pos, hb_min (end, base + 1));
new_pos--;
}
} else {
for (unsigned int i = start; i < base; i++)
if (info[i].indic_position () == POS_PRE_M) {
- buffer->merge_clusters (i, MIN (end, base + 1));
+ buffer->merge_clusters (i, hb_min (end, base + 1));
break;
}
}
foreach_syllable (buffer, start, end)
{
- unsigned int limit = info[start].use_category() == USE_R ? 1 : MIN (3u, end - start);
+ unsigned int limit = info[start].use_category() == USE_R ? 1 : hb_min (3u, end - start);
for (unsigned int i = start; i < start + limit; i++)
info[i].mask |= mask;
}
c->buffer->scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT;
if (likely (!hb_unsigned_mul_overflows (c->buffer->len, HB_BUFFER_MAX_LEN_FACTOR)))
{
- c->buffer->max_len = MAX (c->buffer->len * HB_BUFFER_MAX_LEN_FACTOR,
+ c->buffer->max_len = hb_max (c->buffer->len * HB_BUFFER_MAX_LEN_FACTOR,
(unsigned) HB_BUFFER_MAX_LEN_MIN);
}
if (likely (!hb_unsigned_mul_overflows (c->buffer->len, HB_BUFFER_MAX_OPS_FACTOR)))
{
- c->buffer->max_ops = MAX (c->buffer->len * HB_BUFFER_MAX_OPS_FACTOR,
+ c->buffer->max_ops = hb_max (c->buffer->len * HB_BUFFER_MAX_OPS_FACTOR,
(unsigned) HB_BUFFER_MAX_OPS_MIN);
}
p = strchr (b, '-');
db = p ? (unsigned int) (p - b) : strlen (b);
- return strncmp (a, b, MAX (da, db));
+ return strncmp (a, b, hb_max (da, db));
}
int cmp (const LangTag *that) const
{ return cmp (that->language); }
void map_coords (int *coords, unsigned int coords_length) const
{
- unsigned int count = MIN<unsigned int> (coords_length, axisCount);
+ unsigned int count = hb_min (coords_length, axisCount);
const SegmentMaps *map = &firstAxisSegmentMaps;
for (unsigned int i = 0; i < count; i++)
info->name_id = axis.axisNameID;
info->default_value = axis.defaultValue / 65536.;
/* Ensure order, to simplify client math. */
- info->min_value = MIN<float> (info->default_value, axis.minValue / 65536.);
- info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.);
+ info->min_value = hb_min (info->default_value, axis.minValue / 65536.);
+ info->max_value = hb_max (info->default_value, axis.maxValue / 65536.);
}
void get_axis_info (unsigned int axis_index,
info->flags = (hb_ot_var_axis_flags_t) (unsigned int) axis.flags;
info->default_value = axis.defaultValue / 65536.;
/* Ensure order, to simplify client math. */
- info->min_value = MIN<float> (info->default_value, axis.minValue / 65536.);
- info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.);
+ info->min_value = hb_min (info->default_value, axis.minValue / 65536.);
+ info->max_value = hb_max (info->default_value, axis.maxValue / 65536.);
info->reserved = 0;
}
{
/* TODO Rewrite as hb_array_t<>::sub-array() */
unsigned int count = axisCount;
- start_offset = MIN (start_offset, count);
+ start_offset = hb_min (start_offset, count);
count -= start_offset;
axes_array += start_offset;
- count = MIN (count, *axes_count);
+ count = hb_min (count, *axes_count);
*axes_count = count;
for (unsigned int i = 0; i < count; i++)
{
/* TODO Rewrite as hb_array_t<>::sub-array() */
unsigned int count = axisCount;
- start_offset = MIN (start_offset, count);
+ start_offset = hb_min (start_offset, count);
count -= start_offset;
axes_array += start_offset;
- count = MIN (count, *axes_count);
+ count = hb_min (count, *axes_count);
*axes_count = count;
for (unsigned int i = 0; i < count; i++)
hb_ot_var_axis_info_t axis;
get_axis_info (axis_index, &axis);
- v = MAX (MIN (v, axis.max_value), axis.min_value); /* Clamp. */
+ v = hb_max (hb_min (v, axis.max_value), axis.min_value); /* Clamp. */
if (v == axis.default_value)
return 0;
else
{
this->start = obj_start;
- this->end = obj_start + MIN<uintptr_t> (this->end - obj_start, obj->get_size ());
+ this->end = obj_start + hb_min (this->end - obj_start, obj->get_size ());
}
}
void start_processing ()
{
reset_object ();
- this->max_ops = MAX ((unsigned int) (this->end - this->start) * HB_SANITIZE_MAX_OPS_FACTOR,
+ this->max_ops = hb_max ((unsigned int) (this->end - this->start) * HB_SANITIZE_MAX_OPS_FACTOR,
(unsigned) HB_SANITIZE_MAX_OPS_MIN);
this->edit_count = 0;
this->debug_depth = 0;
vis_clusters[i] = (uint32_t) -1;
for (unsigned int i = 0; i < buffer->len; i++) {
uint32_t *p = &vis_clusters[log_clusters[buffer->info[i].utf16_index()]];
- *p = MIN (*p, buffer->info[i].cluster);
+ *p = hb_min (*p, buffer->info[i].cluster);
}
for (unsigned int i = 1; i < glyphs_len; i++)
if (vis_clusters[i] == (uint32_t) -1)