]> granicus.if.org Git - libass/commitdiff
Limit ass_font_set_transform to nonrotating transformations.
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Mon, 14 May 2007 20:24:53 +0000 (20:24 +0000)
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Mon, 14 May 2007 20:24:53 +0000 (20:24 +0000)
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

libass/ass_font.c
libass/ass_font.h
libass/ass_render.c
libass/ass_utils.h

index 7217f4082573c62c06560e45e687df3301a35921..34a15ed4e1176050bbe4d7e5c1d532aecc10cdb3 100644 (file)
@@ -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
index e7793849fefbf31c912382f0bb64b663451b6d0e..331db55d9d4f6bab90bae6ffb4c49f104416cae2 100644 (file)
@@ -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);
index 923f4b192c53d28289de84a311cc65bfa14ba109..1b7938105f22b4102d079d6a96f4fb8b4e8962d2 100644 (file)
@@ -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);
                
index 6c4eccecd5d41072f90f8c283700028f7b316ea4..53b4b4f96ab7138c9dd9de41e8ff60dbc21a1141 100644 (file)
@@ -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