changeset 22259:cb409839a110

Correct implementation of text spacing.
author eugeni
date Mon, 19 Feb 2007 18:01:49 +0000
parents 9c1160622400
children ae6fe8a910dd
files libass/ass.c libass/ass_render.c libass/ass_types.h
diffstat 3 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass.c	Mon Feb 19 17:44:29 2007 +0000
+++ b/libass/ass.c	Mon Feb 19 18:01:49 2007 +0000
@@ -352,7 +352,7 @@
 					INTVAL(Italic)
 					INTVAL(Underline)
 					INTVAL(StrikeOut)
-					INTVAL(Spacing)
+					FPVAL(Spacing)
 					INTVAL(Angle)
 					INTVAL(BorderStyle)
 					INTVAL(Alignment)
@@ -440,7 +440,7 @@
 			INTVAL(Italic)
 			INTVAL(Underline)
 			INTVAL(StrikeOut)
-			INTVAL(Spacing)
+			FPVAL(Spacing)
 			INTVAL(Angle)
 			INTVAL(BorderStyle)
 			INTVAL(Alignment)
--- a/libass/ass_render.c	Mon Feb 19 17:44:29 2007 +0000
+++ b/libass/ass_render.c	Mon Feb 19 18:01:49 2007 +0000
@@ -150,7 +150,7 @@
 	int org_x, org_y; // origin
 	char have_origin; // origin is explicitly defined; if 0, get_base_point() is used
 	double scale_x, scale_y;
-	int hspacing; // distance between letters, in pixels
+	double hspacing; // distance between letters, in pixels
 	double border; // outline width
 	uint32_t c[4]; // colors(Primary, Secondary, so on) in RGBA
 	int clip_x0, clip_y0, clip_x1, clip_y1;
@@ -713,11 +713,11 @@
 				render_context.scale_y = render_context.style->ScaleY;
 		}
 	} else if (mystrcmp(&p, "fsp")) {
-		int val;
-		if (mystrtoi(&p, 10, &val))
-			render_context.hspacing = val * pwr;
+		double val;
+		if (mystrtod(&p, &val))
+			render_context.hspacing = render_context.hspacing * ( 1 - pwr ) + val * pwr;
 		else
-			render_context.hspacing = 0;
+			render_context.hspacing = render_context.style->Spacing;
 	} else if (mystrcmp(&p, "fs")) {
 		int val;
 		if (mystrtoi(&p, 10, &val))
@@ -1158,7 +1158,7 @@
 	change_border(-1.);
 	render_context.scale_x = render_context.style->ScaleX;
 	render_context.scale_y = render_context.style->ScaleY;
-	render_context.hspacing = 0; // FIXME
+	render_context.hspacing = render_context.style->Spacing;
 	render_context.be = 0;
 	render_context.shadow = render_context.style->Shadow;
 	render_context.frx = render_context.fry = 0.;
@@ -1711,7 +1711,7 @@
 		text_info.glyphs[text_info.length].pos.y = d6_to_int(pen.y);
 		
 		pen.x += text_info.glyphs[text_info.length].advance.x;
-		pen.x += render_context.hspacing;
+		pen.x += double_to_d6(render_context.hspacing);
 		pen.y += text_info.glyphs[text_info.length].advance.y;
 		
 		// if it's an outline glyph, we still need to fill the bbox
--- a/libass/ass_types.h	Mon Feb 19 17:44:29 2007 +0000
+++ b/libass/ass_types.h	Mon Feb 19 18:01:49 2007 +0000
@@ -43,7 +43,7 @@
 	int StrikeOut;
 	double ScaleX;
 	double ScaleY;
-	int Spacing;
+	double Spacing;
 	int Angle;
 	int BorderStyle;
 	double Outline;