Better fix for -Wcast-align errors
This commit is contained in:
parent
81ec543d80
commit
447323b85a
@ -141,11 +141,8 @@ hb_font_get_nominal_glyphs_default (hb_font_t *font,
|
|||||||
if (!font->get_nominal_glyph (*first_unicode, first_glyph))
|
if (!font->get_nominal_glyph (*first_unicode, first_glyph))
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
first_unicode = &StructAtOffsetUnaligned<hb_codepoint_t> (first_unicode, unicode_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||||
first_unicode = (hb_codepoint_t *) &StructAtOffset<char> (first_unicode, unicode_stride);
|
|
||||||
first_glyph = (hb_codepoint_t *) &StructAtOffset<char> (first_glyph, glyph_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -241,11 +238,8 @@ hb_font_get_glyph_h_advances_default (hb_font_t* font,
|
|||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
*first_advance = font->get_glyph_h_advance (*first_glyph);
|
*first_advance = font->get_glyph_h_advance (*first_glyph);
|
||||||
#pragma GCC diagnostic push
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
||||||
first_glyph = (hb_codepoint_t *) &StructAtOffset<char> (first_glyph, glyph_stride);
|
|
||||||
first_advance = (hb_position_t *) &StructAtOffset<char> (first_advance, advance_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -256,10 +250,7 @@ hb_font_get_glyph_h_advances_default (hb_font_t* font,
|
|||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
*first_advance = font->parent_scale_x_distance (*first_advance);
|
*first_advance = font->parent_scale_x_distance (*first_advance);
|
||||||
#pragma GCC diagnostic push
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
|
||||||
first_advance = (hb_position_t *) &StructAtOffset<char> (first_advance, advance_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,11 +270,8 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font,
|
|||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
*first_advance = font->get_glyph_v_advance (*first_glyph);
|
*first_advance = font->get_glyph_v_advance (*first_glyph);
|
||||||
#pragma GCC diagnostic push
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
||||||
first_glyph = (hb_codepoint_t *) &StructAtOffset<char> (first_glyph, glyph_stride);
|
|
||||||
first_advance = (hb_position_t *) &StructAtOffset<char> (first_advance, advance_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -294,10 +282,7 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font,
|
|||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
*first_advance = font->parent_scale_y_distance (*first_advance);
|
*first_advance = font->parent_scale_y_distance (*first_advance);
|
||||||
#pragma GCC diagnostic push
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
|
||||||
first_advance = (hb_position_t *) &StructAtOffset<char> (first_advance, advance_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
src/hb-ft.cc
14
src/hb-ft.cc
@ -228,11 +228,8 @@ hb_ft_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
|
|||||||
done < count && (*first_glyph = FT_Get_Char_Index (ft_font->ft_face, *first_unicode));
|
done < count && (*first_glyph = FT_Get_Char_Index (ft_font->ft_face, *first_unicode));
|
||||||
done++)
|
done++)
|
||||||
{
|
{
|
||||||
#pragma GCC diagnostic push
|
first_unicode = &StructAtOffsetUnaligned<hb_codepoint_t> (first_unicode, unicode_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||||
first_unicode = (hb_codepoint_t *) &StructAtOffset<char> (first_unicode, unicode_stride);
|
|
||||||
first_glyph = (hb_codepoint_t *) &StructAtOffset<char> (first_glyph, glyph_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
/* We don't need to do ft_font->symbol dance here, since HB calls the singular
|
/* We don't need to do ft_font->symbol dance here, since HB calls the singular
|
||||||
* nominal_glyph() for what we don't handle here. */
|
* nominal_glyph() for what we don't handle here. */
|
||||||
@ -295,11 +292,8 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*first_advance = (v * mult + (1<<9)) >> 10;
|
*first_advance = (v * mult + (1<<9)) >> 10;
|
||||||
#pragma GCC diagnostic push
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
||||||
first_glyph = (hb_codepoint_t *) &StructAtOffset<char> (first_glyph, glyph_stride);
|
|
||||||
first_advance = (hb_position_t *) &StructAtOffset<char> (first_advance, advance_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,22 @@ static inline const Type& StructAtOffset(const void *P, unsigned int offset)
|
|||||||
template<typename Type>
|
template<typename Type>
|
||||||
static inline Type& StructAtOffset(void *P, unsigned int offset)
|
static inline Type& StructAtOffset(void *P, unsigned int offset)
|
||||||
{ return * reinterpret_cast<Type*> ((char *) P + offset); }
|
{ return * reinterpret_cast<Type*> ((char *) P + offset); }
|
||||||
|
template<typename Type>
|
||||||
|
static inline const Type& StructAtOffsetUnaligned(const void *P, unsigned int offset)
|
||||||
|
{
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||||
|
return * reinterpret_cast<Type*> ((char *) P + offset);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
}
|
||||||
|
template<typename Type>
|
||||||
|
static inline Type& StructAtOffsetUnaligned(void *P, unsigned int offset)
|
||||||
|
{
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||||
|
return * reinterpret_cast<Type*> ((char *) P + offset);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
}
|
||||||
|
|
||||||
/* StructAfter<T>(X) returns the struct T& that is placed after X.
|
/* StructAfter<T>(X) returns the struct T& that is placed after X.
|
||||||
* Works with X of variable size also. X must implement get_size() */
|
* Works with X of variable size also. X must implement get_size() */
|
||||||
|
@ -1054,11 +1054,8 @@ struct cmap
|
|||||||
done < count && get_glyph_funcZ (get_glyph_data, *first_unicode, first_glyph);
|
done < count && get_glyph_funcZ (get_glyph_data, *first_unicode, first_glyph);
|
||||||
done++)
|
done++)
|
||||||
{
|
{
|
||||||
#pragma GCC diagnostic push
|
first_unicode = &StructAtOffsetUnaligned<hb_codepoint_t> (first_unicode, unicode_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||||
first_unicode = (hb_codepoint_t *) &StructAtOffset<char> (first_unicode, unicode_stride);
|
|
||||||
first_glyph = (hb_codepoint_t *) &StructAtOffset<char> (first_glyph, glyph_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
@ -112,11 +112,8 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data,
|
|||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
*first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font));
|
*first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font));
|
||||||
#pragma GCC diagnostic push
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
||||||
first_glyph = (hb_codepoint_t *) &StructAtOffset<char> (first_glyph, glyph_stride);
|
|
||||||
first_advance = (hb_position_t *) &StructAtOffset<char> (first_advance, advance_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,11 +132,8 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data,
|
|||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
*first_advance = font->em_scale_y (-(int) vmtx.get_advance (*first_glyph, font));
|
*first_advance = font->em_scale_y (-(int) vmtx.get_advance (*first_glyph, font));
|
||||||
#pragma GCC diagnostic push
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
||||||
first_glyph = (hb_codepoint_t *) &StructAtOffset<char> (first_glyph, glyph_stride);
|
|
||||||
first_advance = (hb_position_t *) &StructAtOffset<char> (first_advance, advance_stride);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user