changeset 23300:04dbd42b3962

Support fractional font sizes.
author eugeni
date Mon, 14 May 2007 20:41:14 +0000
parents 0ee56ec36a40
children 98e5fbff12c8
files libass/ass.c libass/ass_cache.h libass/ass_font.c libass/ass_font.h libass/ass_render.c libass/ass_types.h
diffstat 6 files changed, 19 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass.c	Mon May 14 20:24:53 2007 +0000
+++ b/libass/ass.c	Mon May 14 20:41:14 2007 +0000
@@ -347,7 +347,7 @@
 					COLORVAL(SecondaryColour)
 					COLORVAL(OutlineColour)
 					COLORVAL(BackColour)
-					INTVAL(FontSize)
+					FPVAL(FontSize)
 					INTVAL(Bold)
 					INTVAL(Italic)
 					INTVAL(Underline)
@@ -435,7 +435,7 @@
 				// 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)
--- a/libass/ass_cache.h	Mon May 14 20:24:53 2007 +0000
+++ b/libass/ass_cache.h	Mon May 14 20:41:14 2007 +0000
@@ -31,7 +31,7 @@
 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 @@
 // 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
--- a/libass/ass_font.c	Mon May 14 20:24:53 2007 +0000
+++ b/libass/ass_font.c	Mon May 14 20:41:14 2007 +0000
@@ -67,8 +67,9 @@
 {
 	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 @@
 
 	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 @@
 /**
  * \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 @@
 
 	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
 
--- a/libass/ass_font.h	Mon May 14 20:24:53 2007 +0000
+++ b/libass/ass_font.h	Mon May 14 20:41:14 2007 +0000
@@ -40,7 +40,7 @@
 	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 @@
 
 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);
--- a/libass/ass_render.c	Mon May 14 20:24:53 2007 +0000
+++ b/libass/ass_render.c	Mon May 14 20:41:14 2007 +0000
@@ -137,7 +137,7 @@
 	
 	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 @@
 
 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 @@
 		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;
--- a/libass/ass_types.h	Mon May 14 20:24:53 2007 +0000
+++ b/libass/ass_types.h	Mon May 14 20:41:14 2007 +0000
@@ -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;