changeset 23299:0ee56ec36a40

Limit ass_font_set_transform to nonrotating transformations. Rotations are not needed here (they are performed in transform3d) and they disable autohinter.
author eugeni
date Mon, 14 May 2007 20:24:53 +0000
parents 4726edea2edd
children 04dbd42b3962
files libass/ass_font.c libass/ass_font.h libass/ass_render.c libass/ass_utils.h
diffstat 4 files changed, 30 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_font.c	Mon May 14 18:21:39 2007 +0000
+++ b/libass/ass_font.c	Mon May 14 20:24:53 2007 +0000
@@ -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 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 @@
 	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 @@
 /**
  * \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 @@
 	}
 
 	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
--- a/libass/ass_font.h	Mon May 14 18:21:39 2007 +0000
+++ b/libass/ass_font.h	Mon May 14 20:24:53 2007 +0000
@@ -38,7 +38,7 @@
 	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 @@
 } 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);
--- a/libass/ass_render.c	Mon May 14 18:21:39 2007 +0000
+++ b/libass/ass_render.c	Mon May 14 20:24:53 2007 +0000
@@ -1759,15 +1759,10 @@
 		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);
 		
--- a/libass/ass_utils.h	Mon May 14 18:21:39 2007 +0000
+++ b/libass/ass_utils.h	Mon May 14 20:24:53 2007 +0000
@@ -50,6 +50,12 @@
 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