[lasem] Add support for math equation baseline



commit e655530a129615986cc3a7dcedaf2334d180ec3f
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sat Jul 2 11:15:20 2011 +0200

    Add support for math equation baseline

 src/lsmdomview.c    |   12 ++++++++----
 src/lsmdomview.h    |    6 +++---
 src/lsmmathmlview.c |    8 +++++---
 src/lsmsvgview.c    |    4 +++-
 4 files changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/src/lsmdomview.c b/src/lsmdomview.c
index 2641849..63dd27f 100644
--- a/src/lsmdomview.c
+++ b/src/lsmdomview.c
@@ -33,7 +33,7 @@
 static GObjectClass *parent_class;
 
 void
-lsm_dom_view_get_size (LsmDomView *view, double *width, double *height)
+lsm_dom_view_get_size (LsmDomView *view, double *width, double *height, double *baseline)
 {
 	LsmDomViewClass *view_class;
 	double dummy_width = 0.0;
@@ -49,15 +49,16 @@ lsm_dom_view_get_size (LsmDomView *view, double *width, double *height)
 
 	view_class = LSM_DOM_VIEW_GET_CLASS (view);
 	if (view_class->measure != NULL)
-		view_class->measure (view, width, height);
+		view_class->measure (view, width, height, baseline);
 }
 
 void
-lsm_dom_view_get_size_pixels (LsmDomView *view, unsigned int *width, unsigned int *height)
+lsm_dom_view_get_size_pixels (LsmDomView *view, unsigned int *width, unsigned int *height, unsigned int *baseline)
 {
 	double resolution_ppi;
 	double width_pt;
 	double height_pt;
+	double baseline_pt;
 
 	g_return_if_fail (LSM_IS_DOM_VIEW (view));
 	g_return_if_fail (view->document != NULL);
@@ -67,13 +68,16 @@ lsm_dom_view_get_size_pixels (LsmDomView *view, unsigned int *width, unsigned in
 
 	width_pt =  width  != NULL ? *width  * 72.0 / resolution_ppi : 0.0;
 	height_pt = height != NULL ? *height * 72.0 / resolution_ppi : 0.0;
+	baseline_pt = baseline != NULL? *baseline * 72.0 /resolution_ppi : 0.0;
 
-	lsm_dom_view_get_size (view, &width_pt, &height_pt);
+	lsm_dom_view_get_size (view, &width_pt, &height_pt,&baseline_pt);
 
 	if (width != NULL)
 		*width =  (double) (0.5 + width_pt  * resolution_ppi / 72.0);
 	if (height != NULL)
 		*height = (double) (0.5 + height_pt * resolution_ppi / 72.0);
+	if (baseline != NULL)
+		*baseline = (double) (0.5 + baseline_pt * resolution_ppi / 72.0);
 }
 
 static void
diff --git a/src/lsmdomview.h b/src/lsmdomview.h
index abfd6b3..395f791 100644
--- a/src/lsmdomview.h
+++ b/src/lsmdomview.h
@@ -56,15 +56,15 @@ struct _LsmDomViewClass {
 
 	GType document_type;
 
-	void (*measure)	(LsmDomView *view, double *width, double *height);
+	void (*measure)	(LsmDomView *view, double *width, double *height, double *baseline);
 	void (*render)	(LsmDomView *view);
 };
 
 GType lsm_dom_view_get_type (void);
 
-void 			lsm_dom_view_render 		(LsmDomView *view, cairo_t *cairo, double x, double y);
+void 			lsm_dom_view_render 		(LsmDomView *view, cairo_t *cairo, double x, double y, double *baseline);
 void			lsm_dom_view_get_size		(LsmDomView *view, double *width, double *height);
-void 			lsm_dom_view_get_size_pixels 	(LsmDomView *view, unsigned int *width, unsigned int *height);
+void 			lsm_dom_view_get_size_pixels 	(LsmDomView *view, unsigned int *width, unsigned int *height, unsigned int *baseline);
 
 void 			lsm_dom_view_set_document 	(LsmDomView *view, LsmDomDocument *document);
 
diff --git a/src/lsmmathmlview.c b/src/lsmmathmlview.c
index ced3d9e..27c3a9c 100644
--- a/src/lsmmathmlview.c
+++ b/src/lsmmathmlview.c
@@ -933,7 +933,7 @@ lsm_mathml_view_show_fraction_line (LsmMathmlView *view,
 }
 
 static const LsmMathmlBbox *
-_view_measure (LsmMathmlView *view, double *width, double *height)
+_view_measure (LsmMathmlView *view, double *width, double *height, double *baseline)
 {
 	LsmMathmlMathElement *math_element;
 	const LsmMathmlBbox *bbox;
@@ -951,15 +951,17 @@ _view_measure (LsmMathmlView *view, double *width, double *height)
 			*width = bbox->width;
 		if (height != NULL)
 			*height = bbox->height + bbox->depth;
+		if (baseline != NULL)
+			*baseline = bbox->height;
 	}
 
 	return bbox;
 }
 
 static void
-lsm_mathml_view_measure (LsmDomView *dom_view, double *width, double *height)
+lsm_mathml_view_measure (LsmDomView *dom_view, double *width, double *height, double *baseline)
 {
-	_view_measure (LSM_MATHML_VIEW (dom_view), width, height);
+	_view_measure (LSM_MATHML_VIEW (dom_view), width, height, baseline);
 }
 
 static void
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index 7b071d2..364e6a0 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -2047,7 +2047,7 @@ lsm_svg_view_get_clip_extents (LsmSvgView *view)
 }
 
 static void
-lsm_svg_view_measure (LsmDomView *view, double *width, double *height)
+lsm_svg_view_measure (LsmDomView *view, double *width, double *height, double *baseline)
 {
 	LsmSvgSvgElement *svg_element;
 
@@ -2056,6 +2056,8 @@ lsm_svg_view_measure (LsmDomView *view, double *width, double *height)
 		return;
 
 	lsm_svg_svg_element_measure (svg_element, width, height);
+	if (baseline)
+		baseline = -1.; /* or anything else as nan or inf */
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]