Pekka Lampila
2007-Oct-14 12:09 UTC
[Swfdec] 5 commits - libswfdec/swfdec_html_parser.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_xml.c libswfdec/swfdec_xml.h
libswfdec/swfdec_html_parser.c | 2 +- libswfdec/swfdec_text_field.c | 32 +++++++++++++++++++++----------- libswfdec/swfdec_text_field.h | 4 +++- libswfdec/swfdec_text_field_movie.c | 6 ++++-- libswfdec/swfdec_text_field_movie_as.c | 12 ++++++------ libswfdec/swfdec_xml.c | 18 +++++++++--------- libswfdec/swfdec_xml.h | 12 ++++++++---- 7 files changed, 52 insertions(+), 34 deletions(-) New commits: commit 5272df32bbe0ad08d920a5c3e4342aab8c4572e8 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Sun Oct 14 15:08:57 2007 +0300 Get only the name of the font from EditText tag, not SwfdecFont diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c index fabddb2..2f38d85 100644 --- a/libswfdec/swfdec_text_field.c +++ b/libswfdec/swfdec_text_field.c @@ -62,6 +62,8 @@ swfdec_text_field_dispose (GObject *object) text->text_input = NULL; g_free (text->variable); text->variable = NULL; + g_free (text->font); + text->font = NULL; G_OBJECT_CLASS (swfdec_text_field_parent_class)->dispose (object); } @@ -396,7 +398,7 @@ tag_func_define_edit_text (SwfdecSwfDecoder * s, guint tag) font = swfdec_swf_decoder_get_character (s, id); if (SWFDEC_IS_FONT (font)) { SWFDEC_LOG (" font = %u", id); - text->font = SWFDEC_FONT (font); + text->font = g_strdup (SWFDEC_FONT (font)->name); } else { SWFDEC_ERROR ("id %u does not specify a font", id); } diff --git a/libswfdec/swfdec_text_field.h b/libswfdec/swfdec_text_field.h index c565b2a..938dbfd 100644 --- a/libswfdec/swfdec_text_field.h +++ b/libswfdec/swfdec_text_field.h @@ -101,9 +101,9 @@ struct _SwfdecTextField gboolean background; /* only to be passed to the movie object */ - SwfdecFont * font; char * text_input; char * variable; + char * font; guint size; SwfdecColor color; SwfdecTextAlign align; diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c index 304e8e8..69a7a68 100644 --- a/libswfdec/swfdec_text_field_movie.c +++ b/libswfdec/swfdec_text_field_movie.c @@ -542,8 +542,10 @@ swfdec_text_field_movie_init_movie (SwfdecMovie *movie) swfdec_text_format_set_defaults (text->format_new); text->format_new->color = text->text->color; text->format_new->align = text->text->align; - if (text->text->font != NULL && text->text->font->name != NULL) - text->format_new->font = text->text->font->name; + if (text->text->font != NULL) { + text->format_new->font + swfdec_as_context_get_string (cx, text->text->font); + } text->format_new->size = text->text->size / 20; text->format_new->left_margin = text->text->left_margin / 20; text->format_new->right_margin = text->text->right_margin / 20; commit eecddf540e4e6cc66af293061e2f1d58fa9e0843 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Sun Oct 14 14:11:42 2007 +0300 Make swfdec_xml_unescape output different based on the version diff --git a/libswfdec/swfdec_html_parser.c b/libswfdec/swfdec_html_parser.c index 3c0ca04..cba7aa7 100644 --- a/libswfdec/swfdec_html_parser.c +++ b/libswfdec/swfdec_html_parser.c @@ -339,7 +339,7 @@ swfdec_text_field_movie_html_parse_text (ParserData *data, const char *p, end = p + strcspn (p, "<\n"); } - unescaped = swfdec_xml_unescape_len (p, end - p); + unescaped = swfdec_xml_unescape_len (data->cx, p, end - p); data->text = g_string_append (data->text, unescaped); g_free (unescaped); diff --git a/libswfdec/swfdec_xml.c b/libswfdec/swfdec_xml.c index a710f15..c3c2e44 100644 --- a/libswfdec/swfdec_xml.c +++ b/libswfdec/swfdec_xml.c @@ -116,7 +116,8 @@ swfdec_xml_escape (const char *orginal) } char * -swfdec_xml_unescape_len (const char *orginal, gssize length) +swfdec_xml_unescape_len (SwfdecAsContext *cx, const char *orginal, + gssize length) { int i; const char *p, *start; @@ -132,7 +133,7 @@ swfdec_xml_unescape_len (const char *orginal, gssize length) if (!g_ascii_strncasecmp (p, xml_entities[i].escaped, strlen (xml_entities[i].escaped))) { // FIXME: Do this cleaner - if (xml_entities[i].character == '\xa0') + if (cx->version > 5 && xml_entities[i].character == '\xa0') string = g_string_append_c (string, '\xc2'); string = g_string_append_c (string, xml_entities[i].character); p += strlen (xml_entities[i].escaped); @@ -152,9 +153,9 @@ swfdec_xml_unescape_len (const char *orginal, gssize length) } char * -swfdec_xml_unescape (const char *orginal) +swfdec_xml_unescape (SwfdecAsContext *cx, const char *orginal) { - return swfdec_xml_unescape_len (orginal, strlen (orginal)); + return swfdec_xml_unescape_len (cx, orginal, strlen (orginal)); } // this is never declared, only available as ASnative (100, 5) @@ -481,7 +482,7 @@ swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p) text = g_strndup (p, end - p); name = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context, - swfdec_xml_unescape (text)); + swfdec_xml_unescape (SWFDEC_AS_OBJECT (xml)->context, text)); g_free (text); p = end + strspn (end, " \r\n\t"); @@ -506,9 +507,8 @@ swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p) return strchr (p, '\0'); } - text = g_strndup (p + 1, end - (p + 1)); - unescaped = swfdec_xml_unescape (text); - g_free (text); + unescaped = swfdec_xml_unescape_len (SWFDEC_AS_OBJECT (xml)->context, p + 1, + end - (p + 1)); value = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context, unescaped); SWFDEC_AS_VALUE_SET_STRING (&val, value); @@ -638,7 +638,7 @@ swfdec_xml_parse_text (SwfdecXml *xml, SwfdecXmlNode *node, if (!xml->ignoreWhite || strspn (p, " \t\r\n") < (size_t)(end - p)) { text = g_strndup (p, end - p); - unescaped = swfdec_xml_unescape (text); + unescaped = swfdec_xml_unescape (SWFDEC_AS_OBJECT (xml)->context, text); g_free (text); child = swfdec_xml_node_new (SWFDEC_AS_OBJECT (node)->context, SWFDEC_XML_NODE_TEXT, unescaped); diff --git a/libswfdec/swfdec_xml.h b/libswfdec/swfdec_xml.h index 3b0396d..1faff6b 100644 --- a/libswfdec/swfdec_xml.h +++ b/libswfdec/swfdec_xml.h @@ -69,10 +69,14 @@ struct _SwfdecXmlClass { GType swfdec_xml_get_type (void); -char * swfdec_xml_escape (const char *orginal); -char * swfdec_xml_escape_len (const char *orginal, gssize length); -char * swfdec_xml_unescape (const char *orginal); -char * swfdec_xml_unescape_len (const char *orginal, gssize length); +char * swfdec_xml_escape (const char * orginal); +char * swfdec_xml_escape_len (const char * orginal, + gssize length); +char * swfdec_xml_unescape (SwfdecAsContext * cx, + const char * orginal); +char * swfdec_xml_unescape_len (SwfdecAsContext * cx, + const char * orginal, + gssize length); G_END_DECLS #endif commit 4a8fa887bc77eaa276b39e3196a804a75e959e32 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Sun Oct 14 14:03:41 2007 +0300 Use SWFDEC_GRAPHIC (x) not x.graphic diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c index 77c2652..e21183a 100644 --- a/libswfdec/swfdec_text_field_movie_as.c +++ b/libswfdec/swfdec_text_field_movie_as.c @@ -737,12 +737,12 @@ swfdec_text_field_movie_createTextField (SwfdecAsContext *cx, edittext->indent = 0; edittext->leading = 0; - edittext->graphic.extents.x0 = SWFDEC_DOUBLE_TO_TWIPS (x); - edittext->graphic.extents.x1 - edittext->graphic.extents.x0 + SWFDEC_DOUBLE_TO_TWIPS (width); - edittext->graphic.extents.y0 = SWFDEC_DOUBLE_TO_TWIPS (y); - edittext->graphic.extents.y1 - edittext->graphic.extents.y0 + SWFDEC_DOUBLE_TO_TWIPS (height); + SWFDEC_GRAPHIC (edittext)->extents.x0 = SWFDEC_DOUBLE_TO_TWIPS (x); + SWFDEC_GRAPHIC (edittext)->extents.x1 + SWFDEC_GRAPHIC (edittext)->extents.x0 + SWFDEC_DOUBLE_TO_TWIPS (width); + SWFDEC_GRAPHIC (edittext)->extents.y0 = SWFDEC_DOUBLE_TO_TWIPS (y); + SWFDEC_GRAPHIC (edittext)->extents.y1 + SWFDEC_GRAPHIC (edittext)->extents.y0 + SWFDEC_DOUBLE_TO_TWIPS (height); movie = swfdec_movie_find (parent, depth); if (movie) commit 75d1a8f000dbd98afd375f521cf8c0fff79ea9a1 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Sun Oct 14 13:38:04 2007 +0300 Don't allow negative indent in TextField that goes over the left edge diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c index b6a97a3..fabddb2 100644 --- a/libswfdec/swfdec_text_field.c +++ b/libswfdec/swfdec_text_field.c @@ -138,8 +138,11 @@ swfdec_text_field_generate_layouts (SwfdecTextField *text, cairo_t *cr, block->right_margin - block->block_indent; if (block->index_ == 0 && paragraphs[i].indent < 0) { - layout->render_offset_x += paragraphs[i].indent / PANGO_SCALE; - width += -paragraphs[i].indent / PANGO_SCALE; + // limit negative indent to not go over leftMargin + blockIndent + int indent = MAX (paragraphs[i].indent / PANGO_SCALE, + -(block->left_margin + block->block_indent)); + layout->render_offset_x += indent; + width += -indent; } if (text->word_wrap) { commit 3000a03cfb7eeea8c55b8975802a98ec6baa8265 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Sun Oct 14 12:53:50 2007 +0300 Add support for vertical scrolling to the rendering part of TextField diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c index 867b30d..b6a97a3 100644 --- a/libswfdec/swfdec_text_field.c +++ b/libswfdec/swfdec_text_field.c @@ -295,19 +295,21 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr, PangoLayoutIter *iter_line; PangoLayoutLine *line; PangoRectangle rect; + int skipped; iter_line = pango_layout_get_iter (layout->layout); + skipped = 0; do { - /*if (++linenum < text->text->scroll) { - cairo_rel_move_to (cr, 0, -rect.height); - y -= rect.height; + if (++linenum < text->scroll + 1) continue; - }*/ pango_layout_iter_get_line_extents (iter_line, NULL, &rect); pango_extents_to_pixels (NULL, &rect); + if (linenum == text->scroll + 1) + skipped = rect.y; + if (y + rect.y > limit.y1 || y + rect.y + rect.height > SWFDEC_GRAPHIC (text)->extents.y1) break; @@ -318,15 +320,18 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr, continue; cairo_rel_move_to (cr, layout->render_offset_x + rect.x, - pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE); + pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE - skipped); line = pango_layout_iter_get_line_readonly (iter_line); pango_cairo_show_layout_line (cr, line); cairo_rel_move_to (cr, -(layout->render_offset_x + rect.x), - -pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE); + -(pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE - skipped)); } while (pango_layout_iter_next_line (iter_line)); - cairo_rel_move_to (cr, 0, layout->height); - y += layout->height; + if (linenum >= text->scroll + 1) { + cairo_rel_move_to (cr, 0, layout->height - skipped); + y += layout->height - skipped; + skipped = 0; + } } for (iter = layouts; iter != NULL; iter = iter->next) diff --git a/libswfdec/swfdec_text_field.h b/libswfdec/swfdec_text_field.h index dda2787..c565b2a 100644 --- a/libswfdec/swfdec_text_field.h +++ b/libswfdec/swfdec_text_field.h @@ -95,6 +95,8 @@ struct _SwfdecTextField gboolean multiline; SwfdecAutoSize auto_size; + int scroll; + gboolean border; gboolean background;
Possibly Parallel Threads
- 10 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c
- 5 commits - libswfdec/swfdec_html_parser.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_xml.c test/trace
- libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h libswfdec/swfdec_text_field_movie.c
- 6 commits - libswfdec/Makefile.am libswfdec/swfdec_character.c libswfdec/swfdec_external_interface.c libswfdec/swfdec.h libswfdec/swfdec_movie_as_drawing.c libswfdec/swfdec_player.c libswfdec/swfdec_player.h libswfdec/swfdec_player_internal.h
- 6 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_codec_audio.c libswfdec/swfdec_codec_video.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c