summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2015-10-21 01:14:13 +0300
committerOleg Oshmyan <chortos@inbox.lv>2015-10-23 02:36:53 +0300
commitef19a23fa852ae419679b74f690363bb39701709 (patch)
treef69fe2a5caea2c2c8a87c56690dab4cd6bb3d752
parentc03ca8b8e0124ab6149b602d35693b8c65d59865 (diff)
downloadlibass-ef19a23fa852ae419679b74f690363bb39701709.tar.bz2
libass-ef19a23fa852ae419679b74f690363bb39701709.tar.xz
fontselect: use stdbool.h wherever appropriate
-rw-r--r--libass/ass_coretext.c6
-rw-r--r--libass/ass_directwrite.c9
-rw-r--r--libass/ass_fontconfig.c12
-rw-r--r--libass/ass_fontselect.c20
-rw-r--r--libass/ass_fontselect.h6
5 files changed, 26 insertions, 27 deletions
diff --git a/libass/ass_coretext.c b/libass/ass_coretext.c
index 006547b..2eacd92 100644
--- a/libass/ass_coretext.c
+++ b/libass/ass_coretext.c
@@ -53,15 +53,15 @@ static void destroy_font(void *priv)
SAFE_CFRelease(set);
}
-static int check_glyph(void *priv, uint32_t code)
+static bool check_glyph(void *priv, uint32_t code)
{
CFCharacterSetRef set = priv;
if (!set)
- return 1;
+ return true;
if (code == 0)
- return 1;
+ return true;
return CFCharacterSetIsLongCharacterMember(set, code);
}
diff --git a/libass/ass_directwrite.c b/libass/ass_directwrite.c
index 13e20a3..bf40cfb 100644
--- a/libass/ass_directwrite.c
+++ b/libass/ass_directwrite.c
@@ -323,21 +323,20 @@ static size_t get_data(void *data, unsigned char *buf, size_t offset,
}
/*
- * Checks if the passed font has a specific unicode
- * character. Returns 0 for failure and 1 for success
+ * Check if the passed font has a specific unicode character.
*/
-static int check_glyph(void *data, uint32_t code)
+static bool check_glyph(void *data, uint32_t code)
{
HRESULT hr = S_OK;
FontPrivate *priv = (FontPrivate *) data;
BOOL exists = FALSE;
if (code == 0)
- return 1;
+ return true;
hr = IDWriteFont_HasCharacter(priv->font, code, &exists);
if (FAILED(hr))
- return 0;
+ return false;
return exists;
}
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c
index 8b0824b..b3b7100 100644
--- a/libass/ass_fontconfig.c
+++ b/libass/ass_fontconfig.c
@@ -40,23 +40,23 @@ typedef struct fc_private {
FcCharSet *fallback_chars;
} ProviderPrivate;
-static int check_glyph(void *priv, uint32_t code)
+static bool check_glyph(void *priv, uint32_t code)
{
FcPattern *pat = (FcPattern *)priv;
FcCharSet *charset;
if (!pat)
- return 1;
+ return true;
if (code == 0)
- return 1;
+ return true;
FcResult result = FcPatternGetCharSet(pat, FC_CHARSET, 0, &charset);
if (result != FcResultMatch)
- return 0;
+ return false;
if (FcCharSetHasChar(charset, code) == FcTrue)
- return 1;
- return 0;
+ return true;
+ return false;
}
static void destroy(void *priv)
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c
index 2f577f1..e179ed9 100644
--- a/libass/ass_fontselect.c
+++ b/libass/ass_fontselect.c
@@ -110,12 +110,12 @@ struct font_data_ft {
int idx;
};
-static int check_glyph_ft(void *data, uint32_t codepoint)
+static bool check_glyph_ft(void *data, uint32_t codepoint)
{
FontDataFT *fd = (FontDataFT *)data;
if (!codepoint)
- return 1;
+ return true;
return !!FT_Get_Char_Index(fd->face, codepoint);
}
@@ -243,7 +243,7 @@ static void ass_font_provider_free_fontinfo(ASS_FontInfo *info)
* \param data private data for the font
* \return success
*/
-int
+bool
ass_font_provider_add_font(ASS_FontProvider *provider,
ASS_FontProviderMetaData *meta, const char *path,
int index, void *data)
@@ -343,11 +343,11 @@ ass_font_provider_add_font(ASS_FontProvider *provider,
info->provider = provider;
selector->n_font++;
- return 0;
+ return false;
error:
ass_font_provider_free_fontinfo(info);
- return 1;
+ return true;
}
/**
@@ -487,7 +487,7 @@ static void font_info_dump(ASS_FontInfo *font_infos, size_t len)
}
#endif
-static int check_glyph(ASS_FontInfo *fi, uint32_t code)
+static bool check_glyph(ASS_FontInfo *fi, uint32_t code)
{
ASS_FontProvider *provider = fi->provider;
assert(provider && provider->funcs.check_glyph);
@@ -727,7 +727,7 @@ char *ass_font_select(ASS_FontSelector *priv, ASS_Library *library,
* \param info metadata, returned here
* \return success
*/
-static int
+static bool
get_font_info(FT_Library lib, FT_Face face, ASS_FontProviderMetaData *info)
{
int i;
@@ -742,7 +742,7 @@ get_font_info(FT_Library lib, FT_Face face, ASS_FontProviderMetaData *info)
// we're only interested in outlines
if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
- return 0;
+ return false;
for (i = 0; i < num_names; i++) {
FT_SfntName name;
@@ -816,7 +816,7 @@ get_font_info(FT_Library lib, FT_Face face, ASS_FontProviderMetaData *info)
info->n_fullname = num_fullname;
}
- return 0;
+ return false;
error:
for (i = 0; i < num_family; i++)
@@ -829,7 +829,7 @@ error:
free(info->fullnames);
free(postscript_name);
- return 1;
+ return true;
}
/**
diff --git a/libass/ass_fontselect.h b/libass/ass_fontselect.h
index 09749ad..eceb2f0 100644
--- a/libass/ass_fontselect.h
+++ b/libass/ass_fontselect.h
@@ -58,9 +58,9 @@ typedef size_t (*GetDataFunc)(void *font_priv, unsigned char *data,
*
* \param font_priv font private data
* \param codepont Unicode codepoint (UTF-32)
- * \return non-zero value if codepoint is supported by the font
+ * \return true if codepoint is supported by the font
*/
-typedef int (*CheckGlyphFunc)(void *font_priv, uint32_t codepoint);
+typedef bool (*CheckGlyphFunc)(void *font_priv, uint32_t codepoint);
/**
* Destroy a font's private data.
@@ -243,7 +243,7 @@ ass_create_font_provider(ASS_Renderer *priv, ASS_FontProviderFuncs *funcs,
* \return success
*
*/
-int
+bool
ass_font_provider_add_font(ASS_FontProvider *provider,
ASS_FontProviderMetaData *meta, const char *path,
int index, void *data);