* Google Author(s): Behdad Esfahbod
*/
+#include "hb-private.hh"
+#include "hb-debug.hh"
#define HB_SHAPER uniscribe
#include "hb-shaper-impl-private.hh"
#include "hb-ot-tag.h"
-#ifndef HB_DEBUG_UNISCRIBE
-#define HB_DEBUG_UNISCRIBE (HB_DEBUG+0)
-#endif
-
-
static inline uint16_t hb_uint16_swap (const uint16_t v)
{ return (v >> 8) | (v << 8); }
static inline uint32_t hb_uint32_swap (const uint32_t v)
inline void init (void)
{
HMODULE hinstLib;
- this->ScriptItemizeOpenType = NULL;
- this->ScriptShapeOpenType = NULL;
- this->ScriptPlaceOpenType = NULL;
+ this->ScriptItemizeOpenType = nullptr;
+ this->ScriptShapeOpenType = nullptr;
+ this->ScriptPlaceOpenType = nullptr;
hinstLib = GetModuleHandle (TEXT ("usp10.dll"));
if (hinstLib)
!this->ScriptShapeOpenType ||
!this->ScriptPlaceOpenType)
{
- DEBUG_MSG (UNISCRIBE, NULL, "OpenType versions of functions not found; falling back.");
+ DEBUG_MSG (UNISCRIBE, nullptr, "OpenType versions of functions not found; falling back.");
this->ScriptItemizeOpenType = hb_ScriptItemizeOpenType;
this->ScriptShapeOpenType = hb_ScriptShapeOpenType;
this->ScriptPlaceOpenType = hb_ScriptPlaceOpenType;
{
funcs = (hb_uniscribe_shaper_funcs_t *) calloc (1, sizeof (hb_uniscribe_shaper_funcs_t));
if (unlikely (!funcs))
- return NULL;
+ return nullptr;
funcs->init ();
- if (!hb_atomic_ptr_cmpexch (&uniscribe_funcs, NULL, funcs)) {
+ if (!hb_atomic_ptr_cmpexch (&uniscribe_funcs, nullptr, funcs)) {
free (funcs);
goto retry;
}
OPENTYPE_FEATURE_RECORD rec;
unsigned int order;
- static int cmp (const active_feature_t *a, const active_feature_t *b) {
+ static int cmp (const void *pa, const void *pb) {
+ const active_feature_t *a = (const active_feature_t *) pa;
+ const active_feature_t *b = (const active_feature_t *) pb;
return a->rec.tagFeature < b->rec.tagFeature ? -1 : a->rec.tagFeature > b->rec.tagFeature ? 1 :
a->order < b->order ? -1 : a->order > b->order ? 1 :
a->rec.lParameter < b->rec.lParameter ? -1 : a->rec.lParameter > b->rec.lParameter ? 1 :
bool start;
active_feature_t feature;
- static int cmp (const feature_event_t *a, const feature_event_t *b) {
+ static int cmp (const void *pa, const void *pb) {
+ const feature_event_t *a = (const feature_event_t *) pa;
+ const feature_event_t *b = (const feature_event_t *) pb;
return a->index < b->index ? -1 : a->index > b->index ? 1 :
a->start < b->start ? -1 : a->start > b->start ? 1 :
active_feature_t::cmp (&a->feature, &b->feature);
const char *enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
UUID id;
UuidCreate ((UUID*) &id);
- ASSERT_STATIC (2 + 3 * (16/2) < LF_FACESIZE);
+ static_assert ((2 + 3 * (16/2) < LF_FACESIZE), "");
unsigned int name_str_len = 0;
face_name[name_str_len++] = 'F';
face_name[name_str_len++] = '_';
* full, PS. All of them point to the same name data with our unique name.
*/
- blob = OT::Sanitizer<OT::OpenTypeFontFile>::sanitize (blob);
+ blob = OT::Sanitizer<OT::OpenTypeFontFile>().sanitize (blob);
unsigned int length, new_length, name_str_len;
const char *orig_sfnt_data = hb_blob_get_data (blob, &length);
if (!new_sfnt_data)
{
hb_blob_destroy (blob);
- return NULL;
+ return nullptr;
}
memcpy(new_sfnt_data, orig_sfnt_data, length);
{
free (new_sfnt_data);
hb_blob_destroy (blob);
- return NULL;
+ return nullptr;
}
}
hb_blob_destroy (blob);
return hb_blob_create ((const char *) new_sfnt_data, new_length,
- HB_MEMORY_MODE_WRITABLE, NULL, free);
+ HB_MEMORY_MODE_WRITABLE, nullptr, free);
}
hb_uniscribe_shaper_face_data_t *
{
hb_uniscribe_shaper_face_data_t *data = (hb_uniscribe_shaper_face_data_t *) calloc (1, sizeof (hb_uniscribe_shaper_face_data_t));
if (unlikely (!data))
- return NULL;
+ return nullptr;
data->funcs = hb_uniscribe_shaper_get_funcs ();
if (unlikely (!data->funcs))
{
free (data);
- return NULL;
+ return nullptr;
}
hb_blob_t *blob = hb_face_reference_blob (face);
if (unlikely (!blob))
{
free (data);
- return NULL;
+ return nullptr;
}
DWORD num_fonts_installed;
- data->fh = AddFontMemResourceEx ((void *) hb_blob_get_data (blob, NULL),
+ data->fh = AddFontMemResourceEx ((void *) hb_blob_get_data (blob, nullptr),
hb_blob_get_length (blob),
0, &num_fonts_installed);
if (unlikely (!data->fh))
{
DEBUG_MSG (UNISCRIBE, face, "Face AddFontMemResourceEx() failed");
free (data);
- return NULL;
+ return nullptr;
}
return data;
unsigned int font_size)
{
memset (lf, 0, sizeof (*lf));
- lf->lfHeight = -font_size;
+ lf->lfHeight = - (int) font_size;
lf->lfCharSet = DEFAULT_CHARSET;
hb_face_t *face = font->face;
hb_uniscribe_shaper_font_data_t *
_hb_uniscribe_shaper_font_data_create (hb_font_t *font)
{
- if (unlikely (!hb_uniscribe_shaper_face_data_ensure (font->face))) return NULL;
+ if (unlikely (!hb_uniscribe_shaper_face_data_ensure (font->face))) return nullptr;
hb_uniscribe_shaper_font_data_t *data = (hb_uniscribe_shaper_font_data_t *) calloc (1, sizeof (hb_uniscribe_shaper_font_data_t));
if (unlikely (!data))
- return NULL;
+ return nullptr;
int font_size = font->face->get_upem (); /* Default... */
/* No idea if the following is even a good idea. */
data->x_mult = (double) font->x_scale / font_size;
data->y_mult = (double) font->y_scale / font_size;
- data->hdc = GetDC (NULL);
+ data->hdc = GetDC (nullptr);
if (unlikely (!populate_log_font (&data->log_font, font, font_size))) {
DEBUG_MSG (UNISCRIBE, font, "Font populate_log_font() failed");
_hb_uniscribe_shaper_font_data_destroy (data);
- return NULL;
+ return nullptr;
}
data->hfont = CreateFontIndirectW (&data->log_font);
if (unlikely (!data->hfont)) {
DEBUG_MSG (UNISCRIBE, font, "Font CreateFontIndirectW() failed");
_hb_uniscribe_shaper_font_data_destroy (data);
- return NULL;
+ return nullptr;
}
if (!SelectObject (data->hdc, data->hfont)) {
DEBUG_MSG (UNISCRIBE, font, "Font SelectObject() failed");
_hb_uniscribe_shaper_font_data_destroy (data);
- return NULL;
+ return nullptr;
}
return data;
_hb_uniscribe_shaper_font_data_destroy (hb_uniscribe_shaper_font_data_t *data)
{
if (data->hdc)
- ReleaseDC (NULL, data->hdc);
+ ReleaseDC (nullptr, data->hdc);
if (data->hfont)
DeleteObject (data->hfont);
if (data->script_cache)
LOGFONTW *
hb_uniscribe_font_get_logfontw (hb_font_t *font)
{
- if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return NULL;
+ if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return nullptr;
hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
return &font_data->log_font;
}
HFONT
hb_uniscribe_font_get_hfont (hb_font_t *font)
{
- if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return NULL;
+ if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return nullptr;
hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
return font_data->hfont;
}
#define FAIL(...) \
HB_STMT_START { \
- DEBUG_MSG (UNISCRIBE, NULL, __VA_ARGS__); \
+ DEBUG_MSG (UNISCRIBE, nullptr, __VA_ARGS__); \
return false; \
} HB_STMT_END;
unsigned int glyphs_offset = 0;
unsigned int glyphs_len;
bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
- for (unsigned int i = 0; i < item_count; i++)
+ for (int i = 0; i < item_count; i++)
{
unsigned int chars_offset = items[i].iCharPos;
unsigned int item_chars_len = items[i + 1].iCharPos - chars_offset;
/* out */
advances + glyphs_offset,
offsets + glyphs_offset,
- NULL);
+ nullptr);
if (unlikely (FAILED (hr)))
FAIL ("ScriptPlaceOpenType() failed: 0x%08xL", hr);
if (backward)
hb_buffer_reverse (buffer);
+ buffer->unsafe_to_break_all ();
+
/* Wow, done! */
return true;
}