summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2015-10-23 02:20:19 +0300
committerOleg Oshmyan <chortos@inbox.lv>2015-10-23 02:47:03 +0300
commitb4ab3d89805f4dfd5df9a9711fb41f09000a55e6 (patch)
treef591c0c7a9cecd7b548d8b98bdbf029e76342a10
parentf16cf28b7a8275594ec8397aaa9d5ab8d178c629 (diff)
downloadlibass-b4ab3d89805f4dfd5df9a9711fb41f09000a55e6.tar.bz2
libass-b4ab3d89805f4dfd5df9a9711fb41f09000a55e6.tar.xz
fontselect: don't trim font names
This matches the behavior of GDI and hence VSFilter. Note that \fn arguments are trimmed during parsing. However, none of the names inside fonts should be trimmed, and @-prefixed fonts should keep whitespace following the @, both of which this commit addresses. Remove strdup_trimmed because it is no longer used. Also remove the declaration of a function that was deleted a few months ago.
-rw-r--r--libass/ass_fontselect.c21
-rw-r--r--libass/ass_utils.c22
-rw-r--r--libass/ass_utils.h2
3 files changed, 6 insertions, 39 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c
index ce24f7e..2259265 100644
--- a/libass/ass_fontselect.c
+++ b/libass/ass_fontselect.c
@@ -595,22 +595,21 @@ static char *select_font(ASS_FontSelector *priv, ASS_Library *library,
{
ASS_FontProvider *default_provider = priv->default_provider;
ASS_FontProviderMetaData meta = {0};
- char *family_trim = strdup_trimmed(family);
char *result = NULL;
bool name_match = false;
- if (family_trim == NULL)
+ if (family == NULL)
return NULL;
ASS_FontProviderMetaData default_meta = {
.n_fullname = 1,
- .fullnames = &family_trim,
+ .fullnames = &family,
};
// Get a list of substitutes if applicable, and use it for matching.
if (default_provider && default_provider->funcs.get_substitutions) {
default_provider->funcs.get_substitutions(default_provider->priv,
- family_trim, &meta);
+ family, &meta);
}
if (!meta.n_fullname) {
@@ -636,7 +635,6 @@ static char *select_font(ASS_FontSelector *priv, ASS_Library *library,
}
// cleanup
- free(family_trim);
if (meta.fullnames != default_meta.fullnames) {
for (int i = 0; i < meta.n_fullname; i++)
free(meta.fullnames[i]);
@@ -732,7 +730,6 @@ get_font_info(FT_Library lib, FT_Face face, ASS_FontProviderMetaData *info)
int slant, weight;
char *fullnames[MAX_FULLNAME];
char *families[MAX_FULLNAME];
- char *postscript_name = NULL;
PS_FontInfoRec postscript_info;
// we're only interested in outlines
@@ -753,14 +750,14 @@ get_font_info(FT_Library lib, FT_Face face, ASS_FontProviderMetaData *info)
name.string_len);
if (name.name_id == TT_NAME_ID_FULL_NAME) {
- fullnames[num_fullname] = strdup_trimmed(buf);
+ fullnames[num_fullname] = strdup(buf);
if (fullnames[num_fullname] == NULL)
goto error;
num_fullname++;
}
if (name.name_id == TT_NAME_ID_FONT_FAMILY) {
- families[num_family] = strdup_trimmed(buf);
+ families[num_family] = strdup(buf);
if (families[num_family] == NULL)
goto error;
num_family++;
@@ -781,10 +778,6 @@ get_font_info(FT_Library lib, FT_Face face, ASS_FontProviderMetaData *info)
if (num_family == 0)
goto error;
- postscript_name = FT_Get_Postscript_Name(face);
- if (postscript_name != NULL)
- postscript_name = strdup_trimmed(postscript_name);
-
// calculate sensible slant and weight from style attributes
slant = 110 * !!(face->style_flags & FT_STYLE_FLAG_ITALIC);
weight = 300 * !!(face->style_flags & FT_STYLE_FLAG_BOLD) + 400;
@@ -794,7 +787,7 @@ get_font_info(FT_Library lib, FT_Face face, ASS_FontProviderMetaData *info)
info->weight = weight;
info->width = 100; // FIXME, should probably query the OS/2 table
- info->postscript_name = postscript_name;
+ info->postscript_name = FT_Get_Postscript_Name(face);
info->is_postscript = !FT_Get_PS_Font_Info(face, &postscript_info);
info->families = calloc(sizeof(char *), num_family);
@@ -822,7 +815,6 @@ error:
free(info->families);
free(info->fullnames);
- free(postscript_name);
return true;
}
@@ -844,7 +836,6 @@ static void free_font_info(ASS_FontProviderMetaData *meta)
free(meta->families);
free(meta->fullnames);
- free(meta->postscript_name);
}
/**
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index ab1ea02..bcaeec1 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -334,28 +334,6 @@ void ass_msg(ASS_Library *priv, int lvl, const char *fmt, ...)
va_end(va);
}
-/**
- * Return a string with spaces trimmed at start and end.
- * \param str input string
- * \return output string, can be released with free()
- */
-char *strdup_trimmed(const char *str)
-{
- int left = 0;
- int right = strlen(str) - 1;
- char *out = NULL;
-
- while (ass_isspace(str[left])) left++;
- while (right > left && ass_isspace(str[right])) right--;
-
- out = calloc(1, right-left+2);
-
- if (out)
- memcpy(out, str + left, right-left+1);
-
- return out;
-}
-
unsigned ass_utf8_get_char(char **str)
{
uint8_t *strp = (uint8_t *) * str;
diff --git a/libass/ass_utils.h b/libass/ass_utils.h
index c2f5a19..5c3f65f 100644
--- a/libass/ass_utils.h
+++ b/libass/ass_utils.h
@@ -84,8 +84,6 @@ int mystrtoi32(char **p, int base, int32_t *res);
int32_t parse_alpha_tag(char *str);
uint32_t parse_color_tag(char *str);
uint32_t parse_color_header(char *str);
-char *trim_space(char *str);
-char *strdup_trimmed(const char *str);
char parse_bool(char *str);
int parse_ycbcr_matrix(char *str);
unsigned ass_utf8_get_char(char **str);