[MPlayer-cvslog] r23318 - in trunk/libass: ass.c ass_cache.h ass_font.c ass_font.h ass_render.c ass_types.h

eugeni subversion at mplayerhq.hu
Mon May 14 22:41:15 CEST 2007


Author: eugeni
Date: Mon May 14 22:41:14 2007
New Revision: 23318

Log:
Support fractional font sizes.


Modified:
   trunk/libass/ass.c
   trunk/libass/ass_cache.h
   trunk/libass/ass_font.c
   trunk/libass/ass_font.h
   trunk/libass/ass_render.c
   trunk/libass/ass_types.h

Modified: trunk/libass/ass.c
==============================================================================
--- trunk/libass/ass.c	(original)
+++ trunk/libass/ass.c	Mon May 14 22:41:14 2007
@@ -347,7 +347,7 @@ void process_force_style(ass_track_t* tr
 					COLORVAL(SecondaryColour)
 					COLORVAL(OutlineColour)
 					COLORVAL(BackColour)
-					INTVAL(FontSize)
+					FPVAL(FontSize)
 					INTVAL(Bold)
 					INTVAL(Italic)
 					INTVAL(Underline)
@@ -435,7 +435,7 @@ static int process_style(ass_track_t* tr
 				// this will destroy SSA's TertiaryColour, but i'm not going to use it anyway
 				if (track->track_type == TRACK_TYPE_SSA)
 					target->OutlineColour = target->BackColour;
-			INTVAL(FontSize)
+			FPVAL(FontSize)
 			INTVAL(Bold)
 			INTVAL(Italic)
 			INTVAL(Underline)

Modified: trunk/libass/ass_cache.h
==============================================================================
--- trunk/libass/ass_cache.h	(original)
+++ trunk/libass/ass_cache.h	Mon May 14 22:41:14 2007
@@ -31,7 +31,7 @@ void ass_font_cache_done(void);
 typedef struct bitmap_hash_key_s {
 	char bitmap; // bool : true = bitmap, false = outline
 	ass_font_t* font;
-	int size; // font size
+	double size; // font size
 	uint32_t ch; // character code
 	unsigned outline; // border width, 16.16 fixed point value
 	int bold, italic;
@@ -61,7 +61,7 @@ void ass_bitmap_cache_done(void);
 // describes an outline glyph
 typedef struct glyph_hash_key_s {
 	ass_font_t* font;
-	int size; // font size
+	double size; // font size
 	uint32_t ch; // character code
 	int bold, italic;
 	unsigned scale_x, scale_y; // 16.16

Modified: trunk/libass/ass_font.c
==============================================================================
--- trunk/libass/ass_font.c	(original)
+++ trunk/libass/ass_font.c	Mon May 14 22:41:14 2007
@@ -67,8 +67,9 @@ static void update_transform(ass_font_t*
 {
 	int i;
 	FT_Matrix m;
-	m.xx = double_to_d16(font->scale_x);
-	m.yy = double_to_d16(font->scale_y);
+	double size_scale = font->size / (int)font->size;
+	m.xx = double_to_d16(font->scale_x * size_scale);
+	m.yy = double_to_d16(font->scale_y * size_scale);
 	m.xy = m.yx = 0;
 	for (i = 0; i < font->n_faces; ++i)
 		FT_Set_Transform(font->faces[i], &m, &font->v);
@@ -132,7 +133,7 @@ ass_font_t* ass_font_new(ass_library_t* 
 
 	font.scale_x = font.scale_y = 1.;
 	font.v.x = font.v.y = 0;
-	font.size = 0;
+	font.size = 0.;
 
 #ifdef HAVE_FONTCONFIG
 	font.charset = FcCharSetCreate();
@@ -156,13 +157,14 @@ void ass_font_set_transform(ass_font_t* 
 /**
  * \brief Set font size
  **/
-void ass_font_set_size(ass_font_t* font, int size)
+void ass_font_set_size(ass_font_t* font, double size)
 {
 	int i;
 	if (font->size != size) {
 		font->size = size;
 		for (i = 0; i < font->n_faces; ++i)
-			FT_Set_Pixel_Sizes(font->faces[i], 0, size);
+			FT_Set_Pixel_Sizes(font->faces[i], 0, (int)size);
+		update_transform(font);
 	}
 }
 
@@ -199,7 +201,7 @@ static void ass_font_reselect(void* font
 
 	font->faces[font->n_faces++] = face;
 	update_transform(font);
-	FT_Set_Pixel_Sizes(face, 0, font->size);
+	FT_Set_Pixel_Sizes(face, 0, (int)font->size);
 }
 #endif
 

Modified: trunk/libass/ass_font.h
==============================================================================
--- trunk/libass/ass_font.h	(original)
+++ trunk/libass/ass_font.h	Mon May 14 22:41:14 2007
@@ -40,7 +40,7 @@ typedef struct ass_font_s {
 	int n_faces;
 	double scale_x, scale_y; // current transform
 	FT_Vector v; // current shift
-	int size;
+	double size;
 #ifdef HAVE_FONTCONFIG
 	FcCharSet* charset;
 #endif
@@ -48,7 +48,7 @@ typedef struct ass_font_s {
 
 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, double scale_x, double scale_y, FT_Vector* v);
-void ass_font_set_size(ass_font_t* font, int size);
+void ass_font_set_size(ass_font_t* font, double 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);
 FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2);

Modified: trunk/libass/ass_render.c
==============================================================================
--- trunk/libass/ass_render.c	(original)
+++ trunk/libass/ass_render.c	Mon May 14 22:41:14 2007
@@ -137,7 +137,7 @@ typedef struct render_context_s {
 	
 	ass_font_t* font;
 	char* font_path;
-	int font_size;
+	double font_size;
 	
 	FT_Stroker stroker;
 	int alignment; // alignment overrides go here; if zero, style value will be used
@@ -508,7 +508,7 @@ static inline int mystrcmp(char** p, con
 
 double ass_internal_font_size_coeff = 0.8;
 
-static void change_font_size(int sz)
+static void change_font_size(double sz)
 {
 	double size = sz * frame_context.font_scale;
 
@@ -696,8 +696,8 @@ static char* parse_tag(char* p, double p
 		else
 			render_context.hspacing = render_context.style->Spacing;
 	} else if (mystrcmp(&p, "fs")) {
-		int val;
-		if (mystrtoi(&p, 10, &val))
+		double val;
+		if (mystrtod(&p, &val))
 			val = render_context.font_size * ( 1 - pwr ) + val * pwr;
 		else
 			val = render_context.style->FontSize;

Modified: trunk/libass/ass_types.h
==============================================================================
--- trunk/libass/ass_types.h	(original)
+++ trunk/libass/ass_types.h	Mon May 14 22:41:14 2007
@@ -32,7 +32,7 @@
 typedef struct ass_style_s {
 	char* Name;
 	char* FontName;
-	int FontSize;
+	double FontSize;
 	uint32_t PrimaryColour;
 	uint32_t SecondaryColour;
 	uint32_t OutlineColour;



More information about the MPlayer-cvslog mailing list