summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@gnome.org>2003-12-11 10:31:38 +0000
committerDodji Seketeli <dodji@src.gnome.org>2003-12-11 10:31:38 +0000
commitbfc0cf3deb2be5ef8d44715afac960bbe61d0ba3 (patch)
tree1ef2eb909700b9e6b7df1fd124cb7acc1c8628d4
parent9cc84754c2f50204ae658d31a75d15f16e118be6 (diff)
downloadlibcroco-bfc0cf3deb2be5ef8d44715afac960bbe61d0ba3.tar.gz
updated version numbers for 0.4. added this so that the pango dependancy
2003-12-11 Dodji Seketeli <dodji@gnome.org> * configure.in: updated version numbers for 0.4. * src/layeng/cr-lay-eng.[ch]: (cr_lay_eng_style_to_pango_font_attribute): added this so that the pango dependancy comes into the layout engine. * src/parser/cr-parser.c,src/parser/cr-selector.h, src/parser/cr-stylesheet.h,src/parser/cr-term.[ch], src/parser/cr-utils.h: made sure libcroco headers files are C++ compilers friendly. * src/seleng/Makefile.am: remove pango dependancy from the selection engine. Put it in the layout engine. * src/seleng/cr-style.[ch]: (cr_style_to_pango_font_attributes): removed this function from here and put it in src/layeng/cr-lay-eng.[ch]. This way, we seleng doesn't depend on pango. Only layout engine does.
-rw-r--r--ChangeLog18
-rw-r--r--configure.in4
-rw-r--r--src/layeng/cr-lay-eng.c224
-rw-r--r--src/layeng/cr-lay-eng.h5
-rw-r--r--src/parser/cr-parser.c4
-rw-r--r--src/parser/cr-selector.h5
-rw-r--r--src/parser/cr-stylesheet.h4
-rw-r--r--src/parser/cr-term.c2
-rw-r--r--src/parser/cr-term.h4
-rw-r--r--src/parser/cr-utils.h2
-rw-r--r--src/seleng/Makefile.am2
-rw-r--r--src/seleng/cr-style.c214
-rw-r--r--src/seleng/cr-style.h6
13 files changed, 264 insertions, 230 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f6e0fe..07bb9ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2003-12-11 Dodji Seketeli <dodji@gnome.org>
+
+ * configure.in: updated version numbers for 0.4.
+ * src/layeng/cr-lay-eng.[ch]:
+ (cr_lay_eng_style_to_pango_font_attribute): added this so
+ that the pango dependancy comes into the layout engine.
+ * src/parser/cr-parser.c,src/parser/cr-selector.h,
+ src/parser/cr-stylesheet.h,src/parser/cr-term.[ch],
+ src/parser/cr-utils.h:
+ made sure libcroco headers files
+ are C++ compilers friendly.
+ * src/seleng/Makefile.am: remove pango dependancy from the
+ selection engine. Put it in the layout engine.
+ * src/seleng/cr-style.[ch]:
+ (cr_style_to_pango_font_attributes): removed this function
+ from here and put it in src/layeng/cr-lay-eng.[ch]. This way,
+ we seleng doesn't depend on pango. Only layout engine does.
+
2003-08-17 Gaël CHAMOULAUD <strider@gnome.org>
* src/layeng/cr-lay-eng.c: (layout_block_box):
diff --git a/configure.in b/configure.in
index 939c673..426c550 100644
--- a/configure.in
+++ b/configure.in
@@ -4,11 +4,11 @@ AC_INIT(src/parser/cr-input.c)
PACKAGE=libcroco
LIBCROCO_MAJOR_VERSION=0
-LIBCROCO_MINOR_VERSION=3
+LIBCROCO_MINOR_VERSION=4
LIBCROCO_MICRO_VERSION=0
LIBCROCO_CURRENT=1
-LIBCROCO_REVISION=0
+LIBCROCO_REVISION=1
LIBCROCO_AGE=0
#LIBCROCO_VERSION_INFO=`expr $LIBCROCO_MAJOR_VERSION + $LIBCROCO_MINOR_VERSION`:$LIBCROCO_MICRO_VERSION:$LIBCROCO_MINOR_VERSION
diff --git a/src/layeng/cr-lay-eng.c b/src/layeng/cr-lay-eng.c
index 161961d..9c217f7 100644
--- a/src/layeng/cr-lay-eng.c
+++ b/src/layeng/cr-lay-eng.c
@@ -34,6 +34,18 @@
#define PRIVATE(a_this) ((a_this)->priv)
+const gulong gv_predefined_abs_font_size_tab [NB_PREDEFINED_ABSOLUTE_FONT_SIZES]
+=
+{
+ 7, /*FONT_SIZE_XX_SMALL*/
+ 9,/*FONT_SIZE_X_SMALL*/
+ 11, /*FONT_SIZE_SMALL*/
+ 14, /*FONT_MEDIUM*/
+ 17, /*FONT_LARGE*/
+ 20, /*FONT_X_LARGE*/
+ 24 /*FONT_XX_LARGE*/
+} ;
+
/**
*@file
*The definition of the #CRLayEng class.
@@ -922,7 +934,7 @@ layout_text_in_box (CRLayEng *a_this, CRBox *a_text_box)
pango_attr_list_new () ;
g_return_val_if_fail (pgo_attr_list, CR_ERROR) ;
- status = cr_style_to_pango_font_attributes
+ status = cr_lay_eng_style_to_pango_font_attribute
(a_text_box->style, pgo_attr_list,
strlen (a_text_box->content->u.text)) ;
@@ -1595,6 +1607,216 @@ cr_lay_eng_layout_box_tree (CRLayEng *a_this,
/**
+ *@param a_style the style data structure to consider.
+ *@param a_pgo_attrs the output pango attributes list populated
+ *in case of successful completion
+ *@param a_text_len the length of the text the style is to be
+ *applied to. (in number of bytes, not number of characters)
+ *@return CR_OK upon successful completion, an error code otherwise.
+ */
+enum CRStatus
+cr_lay_eng_style_to_pango_font_attribute (CRStyle *a_style,
+ PangoAttrList *a_pgo_attrs,
+ gulong a_text_len)
+{
+ enum CRStatus status = CR_OK ;
+ PangoAttribute * pgo_attr = NULL ;
+ PangoFontDescription *pgo_font_desc = NULL ;
+ PangoStyle pgo_style = PANGO_STYLE_NORMAL ;
+ guchar *font_family = NULL ;
+ PangoWeight pgo_weight = PANGO_WEIGHT_NORMAL ;
+
+ g_return_val_if_fail (a_pgo_attrs
+ && a_style,
+ CR_BAD_PARAM_ERROR) ;
+
+ pgo_font_desc = pango_font_description_new () ;
+ if (!pgo_font_desc)
+ {
+ cr_utils_trace_info ("Could not instanciate "
+ "pango font description") ;
+ return CR_ERROR ;
+ }
+
+ if (a_style->font_size)
+ /*set font size*/
+ switch (a_style->font_size->type)
+ {
+ case PREDEFINED_ABSOLUTE_FONT_SIZE:
+ if ( !(a_style->font_size->value.predefined
+ < NB_PREDEFINED_ABSOLUTE_FONT_SIZES))
+ {
+ status = CR_OUT_OF_BOUNDS_ERROR ;
+ goto cleanup ;
+ }
+ pango_font_description_set_size
+ (pgo_font_desc,
+ gv_predefined_abs_font_size_tab
+ [a_style->font_size->value.predefined]
+ * PANGO_SCALE) ;
+ break ;
+
+ case ABSOLUTE_FONT_SIZE:
+ if (!a_style->font_size->value.absolute)
+ {
+ status = CR_BAD_PARAM_ERROR ;
+ goto cleanup ;
+ }
+ pango_font_description_set_size
+ (pgo_font_desc,
+ a_style->font_size->value.absolute->val
+ * PANGO_SCALE) ;
+ break ;
+
+ case RELATIVE_FONT_SIZE:
+ cr_utils_trace_info ("relative font size are not supported "
+ "yes") ;
+
+ break ;
+
+ case INHERITED_FONT_SIZE:
+ cr_utils_trace_info ("inherited font size are not supported "
+ "yes") ;
+ break ;
+ }
+
+
+ /*set font family*/
+ if (a_style->font_family)
+ font_family = cr_font_family_to_string (a_style->font_family,
+ TRUE) ;
+ if (font_family)
+ {
+ pango_font_description_set_family (pgo_font_desc,
+ font_family) ;
+ }
+
+ /*set style*/
+ switch (a_style->font_style)
+ {
+ case FONT_STYLE_NORMAL:
+ pgo_style = PANGO_STYLE_NORMAL ;
+ break ;
+
+ case FONT_STYLE_ITALIC:
+ pgo_style = PANGO_STYLE_ITALIC ;
+ break ;
+
+ case FONT_STYLE_OBLIQUE:
+ pgo_style = PANGO_STYLE_OBLIQUE ;
+ break ;
+
+ case FONT_STYLE_INHERIT:
+ cr_utils_trace_info ("font-style: inherit not supported yet") ;
+ break ;
+
+ default:
+ cr_utils_trace_info ("unknown font-sytle property value") ;
+ break ;
+ }
+
+ pango_font_description_set_style (pgo_font_desc,
+ pgo_style) ;
+
+ /*set font weight*/
+ switch (a_style->font_weight)
+ {
+ case FONT_WEIGHT_NORMAL:
+ pgo_weight = PANGO_WEIGHT_NORMAL ;
+ break ;
+
+ case FONT_WEIGHT_BOLD:
+ pgo_weight = PANGO_WEIGHT_BOLD;
+ break ;
+
+ case FONT_WEIGHT_BOLDER:
+ cr_utils_trace_info
+ ("font-weight: bolder is not supported yet");
+ break ;
+
+ case FONT_WEIGHT_LIGHTER:
+ cr_utils_trace_info
+ ("font-weight: lighter is not supported yet");
+ break ;
+
+ case FONT_WEIGHT_100:
+ pgo_weight = 100 ;
+ break ;
+
+ case FONT_WEIGHT_200:
+ pgo_weight = 200;
+ break ;
+
+ case FONT_WEIGHT_300:
+ pgo_weight = 300 ;
+ break ;
+
+ case FONT_WEIGHT_400:
+ pgo_weight = 400 ;
+ break ;
+
+ case FONT_WEIGHT_500:
+ pgo_weight = 500 ;
+ break ;
+
+ case FONT_WEIGHT_600:
+ pgo_weight = 600 ;
+ break ;
+
+ case FONT_WEIGHT_700:
+ pgo_weight = 700 ;
+ break ;
+
+ case FONT_WEIGHT_800:
+ pgo_weight = 800 ;
+ break ;
+
+ case FONT_WEIGHT_900:
+ pgo_weight = 900 ;
+ break ;
+
+ case FONT_WEIGHT_INHERIT:
+ cr_utils_trace_info
+ ("font-weight: inherit is not supported yet.") ;
+ break ;
+
+ default:
+ cr_utils_trace_info ("unknown property value") ;
+ break ;
+ }
+
+ pango_font_description_set_weight (pgo_font_desc,
+ pgo_weight) ;
+
+ pgo_attr = pango_attr_font_desc_new (pgo_font_desc) ;
+ if (!pgo_attr)
+ {
+ status = CR_INSTANCIATION_FAILED_ERROR ;
+ goto cleanup ;
+ }
+ pgo_attr->start_index = 0 ;
+ pgo_attr->end_index = a_text_len ;
+ pango_attr_list_change (a_pgo_attrs, pgo_attr) ;
+ pgo_attr = NULL ;
+
+
+ cleanup:
+
+ if (pgo_attr)
+ {
+ pango_attribute_destroy (pgo_attr) ;
+ pgo_attr = NULL ;
+ }
+ if (pgo_font_desc)
+ {
+ pango_font_description_free (pgo_font_desc) ;
+ pgo_font_desc = NULL ;
+ }
+
+ return status ;
+}
+
+/**
*Destuctor of #CRLayEng.
*@param a_this the current instance of #CRLayEng.
*/
diff --git a/src/layeng/cr-lay-eng.h b/src/layeng/cr-lay-eng.h
index 7cade4b..a77c0b7 100644
--- a/src/layeng/cr-lay-eng.h
+++ b/src/layeng/cr-lay-eng.h
@@ -26,6 +26,7 @@
#define __CR_LAY_ENG_H__
#include <libxml/tree.h>
+#include <pango/pango.h>
#include "cr-utils.h"
#include "cr-cascade.h"
#include "cr-box.h"
@@ -65,6 +66,10 @@ enum CRStatus
cr_lay_eng_layout_box_tree (CRLayEng *a_this,
CRBox *a_box_tree) ;
+enum CRStatus
+cr_lay_eng_style_to_pango_font_attribute (CRStyle *a_style,
+ PangoAttrList *a_pgo_attrs,
+ gulong a_text_len) ;
void
cr_lay_eng_destroy (CRLayEng *a_this) ;
diff --git a/src/parser/cr-parser.c b/src/parser/cr-parser.c
index 6f0015e..c95d75d 100644
--- a/src/parser/cr-parser.c
+++ b/src/parser/cr-parser.c
@@ -3714,10 +3714,10 @@ cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr)
switch (operator)
{
case '/':
- expr2->operator = DIVIDE ;
+ expr2->the_operator = DIVIDE ;
break ;
case ',':
- expr2->operator = COMMA ;
+ expr2->the_operator = COMMA ;
default:
break ;
diff --git a/src/parser/cr-selector.h b/src/parser/cr-selector.h
index 1003fc9..7c4a983 100644
--- a/src/parser/cr-selector.h
+++ b/src/parser/cr-selector.h
@@ -35,7 +35,8 @@
*The declaration file of the #CRSelector file.
*/
-#define G_BEGIN_DECLS
+G_BEGIN_DECLS
+
typedef struct _CRSelector CRSelector ;
/**
@@ -99,6 +100,6 @@ cr_selector_unref (CRSelector *a_this) ;
void
cr_selector_destroy (CRSelector *a_this) ;
-#define G_END_DECLS
+G_END_DECLS
#endif /*__CR_SELECTOR_H__*/
diff --git a/src/parser/cr-stylesheet.h b/src/parser/cr-stylesheet.h
index 238d3b8..c850e6e 100644
--- a/src/parser/cr-stylesheet.h
+++ b/src/parser/cr-stylesheet.h
@@ -30,6 +30,8 @@
#include "cr-utils.h"
#include "cr-statement.h"
+G_BEGIN_DECLS
+
/**
*@file
*The declaration of the #CRStyleSheet class.
@@ -98,4 +100,6 @@ cr_stylesheet_unref (CRStyleSheet *a_this) ;
void
cr_stylesheet_destroy (CRStyleSheet *a_this) ;
+G_END_DECLS
+
#endif /*__CR_STYLESHEET_H__*/
diff --git a/src/parser/cr-term.c b/src/parser/cr-term.c
index 59e2348..6f5ae9f 100644
--- a/src/parser/cr-term.c
+++ b/src/parser/cr-term.c
@@ -321,7 +321,7 @@ cr_term_to_string (CRTerm *a_this)
&& (cur->content.rgb == NULL))
continue ;
- switch (cur->operator)
+ switch (cur->the_operator)
{
case DIVIDE:
g_string_append_printf (str_buf, " / ") ;
diff --git a/src/parser/cr-term.h b/src/parser/cr-term.h
index 68f6cb4..94a9d14 100644
--- a/src/parser/cr-term.h
+++ b/src/parser/cr-term.h
@@ -33,7 +33,7 @@
#ifndef __CR_TERM_H__
#define __CR_TERM_H__
-G_END_DECLS
+G_BEGIN_DECLS
/**
*@file
@@ -97,7 +97,7 @@ struct _CRTerm
/**
*The operator associated to the current term.
*/
- enum Operator operator ;
+ enum Operator the_operator ;
/**
diff --git a/src/parser/cr-utils.h b/src/parser/cr-utils.h
index 91ca333..6fb654e 100644
--- a/src/parser/cr-utils.h
+++ b/src/parser/cr-utils.h
@@ -23,8 +23,8 @@
#ifndef __CR_DEFS_H__
#define __CR_DEFS_H__
-#include "libcroco-config.h"
#include <stdio.h>
+#include "libcroco-config.h"
#include <glib.h>
diff --git a/src/seleng/Makefile.am b/src/seleng/Makefile.am
index f7908fb..a122c07 100644
--- a/src/seleng/Makefile.am
+++ b/src/seleng/Makefile.am
@@ -10,7 +10,7 @@ endif
libcrseleng_la_SOURCES=$(SELENG_SRCS)
INCLUDES=-I$(top_srcdir) -I$(top_srcdir)/src/parser -I$(top_srcdir)/intl \
-@GLIB2_CFLAGS@ @LIBXML2_CFLAGS@ @PANGO_CFLAGS@
+@GLIB2_CFLAGS@ @LIBXML2_CFLAGS@
LDADD=$(top_srcdir)/src/parser/libcroco.la
diff --git a/src/seleng/cr-style.c b/src/seleng/cr-style.c
index 6cd75a0..8059bcd 100644
--- a/src/seleng/cr-style.c
+++ b/src/seleng/cr-style.c
@@ -143,17 +143,7 @@ static CRPropertyDesc gv_prop_table [] =
{NULL, 0}
} ;
-const gulong gv_predefined_abs_font_size_tab [NB_PREDEFINED_ABSOLUTE_FONT_SIZES]
-=
-{
- 7, /*FONT_SIZE_XX_SMALL*/
- 9,/*FONT_SIZE_X_SMALL*/
- 11, /*FONT_SIZE_SMALL*/
- 14, /*FONT_MEDIUM*/
- 17, /*FONT_LARGE*/
- 20, /*FONT_X_LARGE*/
- 24 /*FONT_XX_LARGE*/
-} ;
+
/**
*A the key/value pair of this hash table
@@ -2187,208 +2177,6 @@ cr_style_dup (CRStyle *a_this)
}
-enum CRStatus
-cr_style_to_pango_font_attributes (CRStyle *a_style,
- PangoAttrList *a_pgo_attrs,
- gulong a_text_len)
-{
- enum CRStatus status = CR_OK ;
- PangoAttribute * pgo_attr = NULL ;
- PangoFontDescription *pgo_font_desc = NULL ;
- PangoStyle pgo_style = PANGO_STYLE_NORMAL ;
- guchar *font_family = NULL ;
- PangoWeight pgo_weight = PANGO_WEIGHT_NORMAL ;
-
- g_return_val_if_fail (a_pgo_attrs
- && a_style,
- CR_BAD_PARAM_ERROR) ;
-
- pgo_font_desc = pango_font_description_new () ;
- if (!pgo_font_desc)
- {
- cr_utils_trace_info ("Could not instanciate "
- "pango font description") ;
- return CR_ERROR ;
- }
-
- if (a_style->font_size)
- /*set font size*/
- switch (a_style->font_size->type)
- {
- case PREDEFINED_ABSOLUTE_FONT_SIZE:
- if ( !(a_style->font_size->value.predefined
- < NB_PREDEFINED_ABSOLUTE_FONT_SIZES))
- {
- status = CR_OUT_OF_BOUNDS_ERROR ;
- goto cleanup ;
- }
- pango_font_description_set_size
- (pgo_font_desc,
- gv_predefined_abs_font_size_tab
- [a_style->font_size->value.predefined]
- * PANGO_SCALE) ;
- break ;
-
- case ABSOLUTE_FONT_SIZE:
- if (!a_style->font_size->value.absolute)
- {
- status = CR_BAD_PARAM_ERROR ;
- goto cleanup ;
- }
- pango_font_description_set_size
- (pgo_font_desc,
- a_style->font_size->value.absolute->val
- * PANGO_SCALE) ;
- break ;
-
- case RELATIVE_FONT_SIZE:
- cr_utils_trace_info ("relative font size are not supported "
- "yes") ;
-
- break ;
-
- case INHERITED_FONT_SIZE:
- cr_utils_trace_info ("inherited font size are not supported "
- "yes") ;
- break ;
- }
-
-
- /*set font family*/
- if (a_style->font_family)
- font_family = cr_font_family_to_string (a_style->font_family,
- TRUE) ;
- if (font_family)
- {
- pango_font_description_set_family (pgo_font_desc,
- font_family) ;
- }
-
- /*set style*/
- switch (a_style->font_style)
- {
- case FONT_STYLE_NORMAL:
- pgo_style = PANGO_STYLE_NORMAL ;
- break ;
-
- case FONT_STYLE_ITALIC:
- pgo_style = PANGO_STYLE_ITALIC ;
- break ;
-
- case FONT_STYLE_OBLIQUE:
- pgo_style = PANGO_STYLE_OBLIQUE ;
- break ;
-
- case FONT_STYLE_INHERIT:
- cr_utils_trace_info ("font-style: inherit not supported yet") ;
- break ;
-
- default:
- cr_utils_trace_info ("unknown font-sytle property value") ;
- break ;
- }
-
- pango_font_description_set_style (pgo_font_desc,
- pgo_style) ;
-
- /*set font weight*/
- switch (a_style->font_weight)
- {
- case FONT_WEIGHT_NORMAL:
- pgo_weight = PANGO_WEIGHT_NORMAL ;
- break ;
-
- case FONT_WEIGHT_BOLD:
- pgo_weight = PANGO_WEIGHT_BOLD;
- break ;
-
- case FONT_WEIGHT_BOLDER:
- cr_utils_trace_info
- ("font-weight: bolder is not supported yet");
- break ;
-
- case FONT_WEIGHT_LIGHTER:
- cr_utils_trace_info
- ("font-weight: lighter is not supported yet");
- break ;
-
- case FONT_WEIGHT_100:
- pgo_weight = 100 ;
- break ;
-
- case FONT_WEIGHT_200:
- pgo_weight = 200;
- break ;
-
- case FONT_WEIGHT_300:
- pgo_weight = 300 ;
- break ;
-
- case FONT_WEIGHT_400:
- pgo_weight = 400 ;
- break ;
-
- case FONT_WEIGHT_500:
- pgo_weight = 500 ;
- break ;
-
- case FONT_WEIGHT_600:
- pgo_weight = 600 ;
- break ;
-
- case FONT_WEIGHT_700:
- pgo_weight = 700 ;
- break ;
-
- case FONT_WEIGHT_800:
- pgo_weight = 800 ;
- break ;
-
- case FONT_WEIGHT_900:
- pgo_weight = 900 ;
- break ;
-
- case FONT_WEIGHT_INHERIT:
- cr_utils_trace_info
- ("font-weight: inherit is not supported yet.") ;
- break ;
-
- default:
- cr_utils_trace_info ("unknown property value") ;
- break ;
- }
-
- pango_font_description_set_weight (pgo_font_desc,
- pgo_weight) ;
-
- pgo_attr = pango_attr_font_desc_new (pgo_font_desc) ;
- if (!pgo_attr)
- {
- status = CR_INSTANCIATION_FAILED_ERROR ;
- goto cleanup ;
- }
- pgo_attr->start_index = 0 ;
- pgo_attr->end_index = a_text_len ;
- pango_attr_list_change (a_pgo_attrs, pgo_attr) ;
- pgo_attr = NULL ;
-
-
- cleanup:
-
- if (pgo_attr)
- {
- pango_attribute_destroy (pgo_attr) ;
- pgo_attr = NULL ;
- }
- if (pgo_font_desc)
- {
- pango_font_description_free (pgo_font_desc) ;
- pgo_font_desc = NULL ;
- }
-
- return status ;
-}
-
/**
*Destructor of the #CRStyle class.
*@param a_this the instance to destroy.
diff --git a/src/seleng/cr-style.h b/src/seleng/cr-style.h
index 20c7d28..2348c76 100644
--- a/src/seleng/cr-style.h
+++ b/src/seleng/cr-style.h
@@ -23,7 +23,6 @@
#ifndef __CR_STYLE_H__
#define __CR_STYLE_H__
-#include <pango/pango.h>
#include "cr-utils.h"
#include "cr-statement.h"
#include "cr-fonts.h"
@@ -267,10 +266,7 @@ cr_style_new (void) ;
enum CRStatus
cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl) ;
-enum CRStatus
-cr_style_to_pango_font_attributes (CRStyle *a_style,
- PangoAttrList *a_pgo_attrs,
- gulong text_len) ;
+
enum CRStatus
cr_style_ref (CRStyle *a_this) ;