[MPlayer-cvslog] r23317 - in trunk/libass: ass_font.c ass_font.h ass_render.c ass_utils.h

eugeni subversion at mplayerhq.hu
Mon May 14 22:24:53 CEST 2007


Author: eugeni
Date: Mon May 14 22:24:53 2007
New Revision: 23317

Log:
Limit ass_font_set_transform to nonrotating transformations.
Rotations are not needed here (they are performed in transform3d) and they
disable autohinter.


Modified:
   trunk/libass/ass_font.c
   trunk/libass/ass_font.h
   trunk/libass/ass_render.c
   trunk/libass/ass_utils.h

Modified: trunk/libass/ass_font.c
==============================================================================
--- trunk/libass/ass_font.c	(original)
+++ trunk/libass/ass_font.c	Mon May 14 22:24:53 2007
@@ -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* 
 	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* 
 /**
  * \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* font
 	}
 
 	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

Modified: trunk/libass/ass_font.h
==============================================================================
--- trunk/libass/ass_font.h	(original)
+++ trunk/libass/ass_font.h	Mon May 14 22:24:53 2007
@@ -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);

Modified: trunk/libass/ass_render.c
==============================================================================
--- trunk/libass/ass_render.c	(original)
+++ trunk/libass/ass_render.c	Mon May 14 22:24:53 2007
@@ -1759,15 +1759,10 @@ static int ass_render_event(ass_event_t*
 		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);
 		

Modified: trunk/libass/ass_utils.h
==============================================================================
--- trunk/libass/ass_utils.h	(original)
+++ trunk/libass/ass_utils.h	Mon May 14 22:24:53 2007
@@ -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
 



More information about the MPlayer-cvslog mailing list