diff options
author | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-04-27 14:25:36 +0000 |
---|---|---|
committer | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-04-27 14:25:36 +0000 |
commit | c67220c86fa6267d8e0aa5b69d0eebbe17e0ede2 (patch) | |
tree | b8e7d650db0b09986770f59af665319b048f38e7 /libass | |
parent | 13156cd7946705c89ad04edba05c6434d1675e46 (diff) |
Add -ass-hinting option for setting font hinting method.
It is possible to separately configure hinting for scaled and unscaled osd.
The default is native hinter for unscaled osd (only vo_gl at this point),
no hinting for vf_ass.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23152 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass.h | 8 | ||||
-rw-r--r-- | libass/ass_font.c | 12 | ||||
-rw-r--r-- | libass/ass_font.h | 2 | ||||
-rw-r--r-- | libass/ass_mp.c | 9 | ||||
-rw-r--r-- | libass/ass_mp.h | 3 | ||||
-rw-r--r-- | libass/ass_render.c | 11 |
6 files changed, 39 insertions, 6 deletions
diff --git a/libass/ass.h b/libass/ass.h index 7cba671ffd..2e1aa1ab96 100644 --- a/libass/ass.h +++ b/libass/ass.h @@ -37,6 +37,13 @@ typedef struct ass_image_s { struct ass_image_s* next; // linked list } ass_image_t; +/// Hinting type +typedef enum {ASS_HINTING_NONE = 0, + ASS_HINTING_LIGHT, + ASS_HINTING_NORMAL, + ASS_HINTING_NATIVE +} ass_hinting_t; + /** * \brief initialize the library * \return library handle or NULL if failed @@ -77,6 +84,7 @@ void ass_set_margins(ass_renderer_t* priv, int t, int b, int l, int r); void ass_set_use_margins(ass_renderer_t* priv, int use); void ass_set_aspect_ratio(ass_renderer_t* priv, double ar); void ass_set_font_scale(ass_renderer_t* priv, double font_scale); +void ass_set_hinting(ass_renderer_t* priv, ass_hinting_t ht); /** * \brief set font lookup defaults diff --git a/libass/ass_font.c b/libass/ass_font.c index 285ecde63a..57423d1dd7 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -229,13 +229,14 @@ void ass_font_get_asc_desc(ass_font_t* font, uint32_t ch, int* asc, int* desc) * \brief Get a glyph * \param ch character code **/ -FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch) +FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch, ass_hinting_t hinting) { int error; int index = 0; int i; FT_Glyph glyph; FT_Face face = 0; + int flags = 0; if (ch < 0x20) return 0; @@ -264,7 +265,14 @@ FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch } #endif - error = FT_Load_Glyph(face, index, FT_LOAD_NO_BITMAP ); + switch (hinting) { + case ASS_HINTING_NONE: flags = FT_LOAD_NO_HINTING; break; + case ASS_HINTING_LIGHT: flags = FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_LIGHT; break; + case ASS_HINTING_NORMAL: flags = FT_LOAD_FORCE_AUTOHINT; break; + case ASS_HINTING_NATIVE: flags = 0; break; + } + + error = FT_Load_Glyph(face, index, FT_LOAD_NO_BITMAP | flags); if (error) { mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorLoadingGlyph); return 0; diff --git a/libass/ass_font.h b/libass/ass_font.h index 5d986e9f0b..e7793849fe 100644 --- a/libass/ass_font.h +++ b/libass/ass_font.h @@ -50,7 +50,7 @@ ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_ void ass_font_set_transform(ass_font_t* font, FT_Matrix* m, FT_Vector* v); void ass_font_set_size(ass_font_t* font, int size); void ass_font_get_asc_desc(ass_font_t* font, uint32_t ch, int* asc, int* desc); -FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch); +FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch, ass_hinting_t hinting); FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2); void ass_font_free(ass_font_t* font); diff --git a/libass/ass_mp.c b/libass/ass_mp.c index e2c1092bca..02f81e4c7f 100644 --- a/libass/ass_mp.c +++ b/libass/ass_mp.c @@ -50,6 +50,7 @@ int ass_use_margins = 0; char* ass_color = NULL; char* ass_border_color = NULL; char* ass_styles_file = NULL; +int ass_hinting = ASS_HINTING_NATIVE + 4; // native hinting for unscaled osd #ifdef HAVE_FONTCONFIG extern int font_fontconfig; @@ -218,11 +219,17 @@ ass_track_t* ass_read_subdata(ass_library_t* library, sub_data* subdata, double char *get_path(char *); -void ass_configure(ass_renderer_t* priv, int w, int h) { +void ass_configure(ass_renderer_t* priv, int w, int h, int unscaled) { + int hinting; ass_set_frame_size(priv, w, h); ass_set_margins(priv, ass_top_margin, ass_bottom_margin, 0, 0); ass_set_use_margins(priv, ass_use_margins); ass_set_font_scale(priv, ass_font_scale); + if (!unscaled && (ass_hinting & 4)) + hinting = 0; + else + hinting = ass_hinting & 3; + ass_set_hinting(priv, hinting); } void ass_configure_fonts(ass_renderer_t* priv) { diff --git a/libass/ass_mp.h b/libass/ass_mp.h index 5d8b722c28..7f98840d58 100644 --- a/libass/ass_mp.h +++ b/libass/ass_mp.h @@ -35,12 +35,13 @@ extern int ass_use_margins; extern char* ass_color; extern char* ass_border_color; extern char* ass_styles_file; +extern int ass_hinting; ass_track_t* ass_default_track(ass_library_t* library); int ass_process_subtitle(ass_track_t* track, subtitle* sub); ass_track_t* ass_read_subdata(ass_library_t* library, sub_data* subdata, double fps); -void ass_configure(ass_renderer_t* priv, int w, int h); +void ass_configure(ass_renderer_t* priv, int w, int h, int hinting); void ass_configure_fonts(ass_renderer_t* priv); ass_library_t* ass_init(void); diff --git a/libass/ass_render.c b/libass/ass_render.c index f69c0c9518..da4d98ae9e 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -56,6 +56,7 @@ typedef struct ass_settings_s { int use_margins; // 0 - place all subtitles inside original frame // 1 - use margins for placing toptitles and subtitles double aspect; // frame aspect ratio, d_width / d_height. + ass_hinting_t hinting; char* default_font; char* default_family; @@ -1249,7 +1250,7 @@ static void get_outline_glyph(int symbol, glyph_info_t* info, FT_Vector* advance info->advance.y = val->advance.y; } else { glyph_hash_val_t v; - info->glyph = ass_font_get_glyph(frame_context.ass_priv->fontconfig_priv, render_context.font, symbol); + info->glyph = ass_font_get_glyph(frame_context.ass_priv->fontconfig_priv, render_context.font, symbol, global_settings->hinting); if (!info->glyph) return; info->advance.x = d16_to_d6(info->glyph->advance.x); @@ -2049,6 +2050,14 @@ void ass_set_font_scale(ass_renderer_t* priv, double font_scale) } } +void ass_set_hinting(ass_renderer_t* priv, ass_hinting_t ht) +{ + if (priv->settings.hinting != ht) { + priv->settings.hinting = ht; + ass_reconfigure(priv); + } +} + int ass_set_fonts(ass_renderer_t* priv, const char* default_font, const char* default_family) { if (priv->settings.default_font) |