mirror of
https://github.com/mpv-player/mpv
synced 2024-12-29 10:32:15 +00:00
Limit ass_font_set_transform to nonrotating transformations.
Rotations are not needed here (they are performed in transform3d) and they disable autohinter. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23317 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
92b7c0aae0
commit
b51b557529
@ -32,6 +32,7 @@
|
||||
#include "ass_bitmap.h"
|
||||
#include "ass_cache.h"
|
||||
#include "ass_fontconfig.h"
|
||||
#include "ass_utils.h"
|
||||
#include "mputils.h"
|
||||
|
||||
/**
|
||||
@ -62,6 +63,17 @@ static void charmap_magic(FT_Face face)
|
||||
}
|
||||
}
|
||||
|
||||
static void update_transform(ass_font_t* font)
|
||||
{
|
||||
int i;
|
||||
FT_Matrix m;
|
||||
m.xx = double_to_d16(font->scale_x);
|
||||
m.yy = double_to_d16(font->scale_y);
|
||||
m.xy = m.yx = 0;
|
||||
for (i = 0; i < font->n_faces; ++i)
|
||||
FT_Set_Transform(font->faces[i], &m, &font->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief find a memory font by name
|
||||
*/
|
||||
@ -118,8 +130,7 @@ ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_
|
||||
font.desc.bold = desc->bold;
|
||||
font.desc.italic = desc->italic;
|
||||
|
||||
font.m.xx = font.m.yy = (FT_Fixed)0x10000L;
|
||||
font.m.xy = font.m.yy = 0;
|
||||
font.scale_x = font.scale_y = 1.;
|
||||
font.v.x = font.v.y = 0;
|
||||
font.size = 0;
|
||||
|
||||
@ -133,17 +144,13 @@ ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_
|
||||
/**
|
||||
* \brief Set font transformation matrix and shift vector
|
||||
**/
|
||||
void ass_font_set_transform(ass_font_t* font, FT_Matrix* m, FT_Vector* v)
|
||||
void ass_font_set_transform(ass_font_t* font, double scale_x, double scale_y, FT_Vector* v)
|
||||
{
|
||||
int i;
|
||||
font->m.xx = m->xx;
|
||||
font->m.xy = m->xy;
|
||||
font->m.yx = m->yx;
|
||||
font->m.yy = m->yy;
|
||||
font->scale_x = scale_x;
|
||||
font->scale_y = scale_y;
|
||||
font->v.x = v->x;
|
||||
font->v.y = v->y;
|
||||
for (i = 0; i < font->n_faces; ++i)
|
||||
FT_Set_Transform(font->faces[i], &font->m, &font->v);
|
||||
update_transform(font);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,8 +198,7 @@ static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font, uint32_t
|
||||
}
|
||||
|
||||
font->faces[font->n_faces++] = face;
|
||||
|
||||
FT_Set_Transform(face, &font->m, &font->v);
|
||||
update_transform(font);
|
||||
FT_Set_Pixel_Sizes(face, 0, font->size);
|
||||
}
|
||||
#endif
|
||||
|
@ -38,7 +38,7 @@ typedef struct ass_font_s {
|
||||
FT_Library ftlibrary;
|
||||
FT_Face faces[ASS_FONT_MAX_FACES];
|
||||
int n_faces;
|
||||
FT_Matrix m; // current transformation
|
||||
double scale_x, scale_y; // current transform
|
||||
FT_Vector v; // current shift
|
||||
int size;
|
||||
#ifdef HAVE_FONTCONFIG
|
||||
@ -47,7 +47,7 @@ typedef struct ass_font_s {
|
||||
} ass_font_t;
|
||||
|
||||
ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_priv, ass_font_desc_t* desc);
|
||||
void ass_font_set_transform(ass_font_t* font, FT_Matrix* m, FT_Vector* v);
|
||||
void ass_font_set_transform(ass_font_t* font, double scale_x, double scale_y, 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, ass_hinting_t hinting);
|
||||
|
@ -1759,15 +1759,10 @@ static int ass_render_event(ass_event_t* event, event_images_t* event_images)
|
||||
shift.x = pen.x & 63;
|
||||
shift.y = pen.y & 63;
|
||||
|
||||
{
|
||||
FT_Matrix matrix;
|
||||
matrix.xx = (FT_Fixed)( render_context.scale_x * frame_context.font_scale_x * 0x10000L );
|
||||
matrix.xy = (FT_Fixed)( 0 * 0x10000L );
|
||||
matrix.yx = (FT_Fixed)( 0 * 0x10000L );
|
||||
matrix.yy = (FT_Fixed)( render_context.scale_y * 0x10000L );
|
||||
|
||||
ass_font_set_transform(render_context.font, &matrix, &shift );
|
||||
}
|
||||
ass_font_set_transform(render_context.font,
|
||||
render_context.scale_x * frame_context.font_scale_x,
|
||||
render_context.scale_y,
|
||||
&shift );
|
||||
|
||||
get_outline_glyph(code, text_info.glyphs + text_info.length, &shift);
|
||||
|
||||
|
@ -50,6 +50,12 @@ static inline double d6_to_double(int x) {
|
||||
static inline int double_to_d6(double x) {
|
||||
return (int)(x * 64);
|
||||
}
|
||||
static inline double d16_to_double(int x) {
|
||||
return ((double)x) / 0x10000;
|
||||
}
|
||||
static inline int double_to_d16(double x) {
|
||||
return (int)(x * 0x10000);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user