[lasem] svg: start of vertical text support.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] svg: start of vertical text support.
- Date: Tue, 25 Sep 2012 21:18:12 +0000 (UTC)
commit 21add1e5fb6c67de6b6ba24aa6bbcf8cf79a9a29
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Tue Sep 25 23:17:51 2012 +0200
svg: start of vertical text support.
src/lsmsvgenums.c | 25 +++++++++++++++++++++++++
src/lsmsvgenums.h | 13 +++++++++++++
src/lsmsvgstyle.c | 2 +-
src/lsmsvgstyle.h | 7 ++++++-
src/lsmsvgtraits.c | 24 ++++++++++++++++++++++++
src/lsmsvgtraits.h | 1 +
src/lsmsvgview.c | 12 +++++++++++-
7 files changed, 81 insertions(+), 3 deletions(-)
---
diff --git a/src/lsmsvgenums.c b/src/lsmsvgenums.c
index 70fc58f..bedd9dc 100644
--- a/src/lsmsvgenums.c
+++ b/src/lsmsvgenums.c
@@ -442,3 +442,28 @@ lsm_svg_visibility_from_string (const char *string)
G_N_ELEMENTS (lsm_svg_visibility_strings));
}
+static const char *lsm_svg_writing_mode_strings[] = {
+ "lr-tb",
+ "rl-tb",
+ "tb-rl",
+ "lr",
+ "rl",
+ "tb"
+};
+
+const char *
+lsm_svg_writing_mode_to_string (LsmSvgWritingMode writing_mode)
+{
+ if (writing_mode < 0 || writing_mode > LSM_SVG_WRITING_MODE_TB)
+ return NULL;
+
+ return lsm_svg_writing_mode_strings[writing_mode];
+}
+
+LsmSvgWritingMode
+lsm_svg_writing_mode_from_string (const char *string)
+{
+ return lsm_enum_value_from_string (string, lsm_svg_writing_mode_strings,
+ G_N_ELEMENTS (lsm_svg_writing_mode_strings));
+}
+
diff --git a/src/lsmsvgenums.h b/src/lsmsvgenums.h
index 112eb92..c176b4c 100644
--- a/src/lsmsvgenums.h
+++ b/src/lsmsvgenums.h
@@ -301,6 +301,19 @@ typedef enum {
LSM_SVG_ELEMENT_CATEGORY_ANIMATION = 1 << 12
} LsmSvgElementCategory;
+typedef enum {
+ LSM_SVG_WRITING_MODE_ERROR = -1,
+ LSM_SVG_WRITING_MODE_LR_TB,
+ LSM_SVG_WRITING_MODE_RL_TB,
+ LSM_SVG_WRITING_MODE_TB_RL,
+ LSM_SVG_WRITING_MODE_LR,
+ LSM_SVG_WRITING_MODE_RL,
+ LSM_SVG_WRITING_MODE_TB
+} LsmSvgWritingMode;
+
+const char * lsm_svg_writing_mode_to_string (LsmSvgWritingMode writing_mode);
+LsmSvgWritingMode lsm_svg_writing_mode_from_string (const char *string);
+
G_END_DECLS
#endif
diff --git a/src/lsmsvgstyle.c b/src/lsmsvgstyle.c
index 0c691a1..f4914f5 100644
--- a/src/lsmsvgstyle.c
+++ b/src/lsmsvgstyle.c
@@ -393,7 +393,7 @@ static const LsmPropertyInfos lsm_svg_property_infos[] = {
{
.name = "writing-mode",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, writing_mode),
- .trait_class = &lsm_null_trait_class,
+ .trait_class = &lsm_svg_writing_mode_trait_class,
.trait_default = "lr-tb"
}
};
diff --git a/src/lsmsvgstyle.h b/src/lsmsvgstyle.h
index 2927364..fc424a5 100644
--- a/src/lsmsvgstyle.h
+++ b/src/lsmsvgstyle.h
@@ -104,6 +104,11 @@ typedef struct {
LsmSvgVisibility value;
} LsmSvgVisibilityProperty;
+typedef struct {
+ LsmProperty base;
+ LsmSvgWritingMode value;
+} LsmSvgWritingModeProperty;
+
struct _LsmSvgStyle {
/* Not inherited */
@@ -170,7 +175,7 @@ struct _LsmSvgStyle {
LsmProperty * text_rendering;
LsmSvgVisibilityProperty * visibility;
LsmProperty * word_spacing;
- LsmProperty * writing_mode;
+ LsmSvgWritingModeProperty * writing_mode;
};
void lsm_svg_property_bag_set_property (LsmPropertyBag *property_bag,
diff --git a/src/lsmsvgtraits.c b/src/lsmsvgtraits.c
index e11bbe6..3357f4d 100644
--- a/src/lsmsvgtraits.c
+++ b/src/lsmsvgtraits.c
@@ -965,3 +965,27 @@ const LsmTraitClass lsm_svg_one_or_two_double_trait_class = {
.to_string = lsm_svg_one_or_two_double_trait_to_string
};
+static gboolean
+lsm_svg_writing_mode_trait_from_string (LsmTrait *abstract_trait, char *string)
+{
+ LsmSvgDisplay *trait = (LsmSvgDisplay *) abstract_trait;
+
+ *trait = lsm_svg_writing_mode_from_string (string);
+
+ return *trait >= 0;
+}
+
+char *
+lsm_svg_writing_mode_trait_to_string (LsmTrait *abstract_trait)
+{
+ LsmSvgDisplay *trait = (LsmSvgDisplay *) abstract_trait;
+
+ return g_strdup (lsm_svg_writing_mode_to_string (*trait));
+}
+
+const LsmTraitClass lsm_svg_writing_mode_trait_class = {
+ .size = sizeof (LsmSvgWritingMode),
+ .from_string = lsm_svg_writing_mode_trait_from_string,
+ .to_string = lsm_svg_writing_mode_trait_to_string
+};
+
diff --git a/src/lsmsvgtraits.h b/src/lsmsvgtraits.h
index 2ea2f44..95f362c 100644
--- a/src/lsmsvgtraits.h
+++ b/src/lsmsvgtraits.h
@@ -92,6 +92,7 @@ extern const LsmTraitClass lsm_svg_preserve_aspect_ratio_trait_class;
extern const LsmTraitClass lsm_svg_spread_method_trait_class;
extern const LsmTraitClass lsm_svg_text_anchor_trait_class;
extern const LsmTraitClass lsm_svg_visibility_trait_class;
+extern const LsmTraitClass lsm_svg_writing_mode_trait_class;
G_END_DECLS
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index 09c2b44..b83cb44 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -1475,7 +1475,17 @@ lsm_svg_view_show_text (LsmSvgView *view, char const *string, double x, double y
path_infos.extents.y2 = y1 + pango_units_to_double (rectangle.height);
path_infos.pango_layout = pango_layout;
- process_path (view, &path_infos);
+ if (style->writing_mode->value == LSM_SVG_WRITING_MODE_TB ||
+ style->writing_mode->value == LSM_SVG_WRITING_MODE_TB_RL) {
+
+ cairo_save (view->dom_view.cairo);
+ cairo_rotate (view->dom_view.cairo, M_PI / 2.0);
+
+ process_path (view, &path_infos);
+
+ cairo_restore (view->dom_view.cairo);
+ } else
+ process_path (view, &path_infos);
if (pango_layout != view->pango_layout) {
lsm_debug_render ("[LsmSvgView::show_text] Free the child pango layout");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]