From d887e66dc5497ac0af84d9e22af6b98f4cc5d99e Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Wed, 2 Mar 2005 21:56:35 +0000 Subject: Redo the handling of absolute sizes for PangoAttribute to work around 2005-03-02 Owen Taylor Redo the handling of absolute sizes for PangoAttribute to work around compatibility problems with GtkHTML which was counting on the details of the implementation of size attributes. (#163154) * pango/pango-attributes.[ch] docs/tmpl/text-attributes.sgml: Split PANGO_ATTR_SIZE into PANGO_ATTR_SIZE and PANGO_ATTR_ABSOLUTE_SIZE, and use that distinction rather than the boolean field in PangoAttrSize to distinguish between attributes created pango_attr_size_new_absolute() and pango_attr_size_new() --- ChangeLog | 15 +++++++++++++++ ChangeLog.pre-1-10 | 15 +++++++++++++++ docs/tmpl/text-attributes.sgml | 14 ++++++++++---- pango/pango-attributes.c | 35 ++++++++++++++++++++++++----------- pango/pango-attributes.h | 3 ++- 5 files changed, 66 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6901a843..922bf540 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-03-02 Owen Taylor + + Redo the handling of absolute sizes for PangoAttribute + to work around compatibility problems with GtkHTML which + was counting on the details of the implementation of + size attributes. (#163154) + + * pango/pango-attributes.[ch] docs/tmpl/text-attributes.sgml: + Split PANGO_ATTR_SIZE into PANGO_ATTR_SIZE and + PANGO_ATTR_ABSOLUTE_SIZE, and use that distinction + rather than the boolean field in PangoAttrSize to + distinguish between attributes created + pango_attr_size_new_absolute() and + pango_attr_size_new() + 2005-03-01 Owen Taylor * pango/pango-layout.c (process_item): Don't break diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 6901a843..922bf540 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,18 @@ +2005-03-02 Owen Taylor + + Redo the handling of absolute sizes for PangoAttribute + to work around compatibility problems with GtkHTML which + was counting on the details of the implementation of + size attributes. (#163154) + + * pango/pango-attributes.[ch] docs/tmpl/text-attributes.sgml: + Split PANGO_ATTR_SIZE into PANGO_ATTR_SIZE and + PANGO_ATTR_ABSOLUTE_SIZE, and use that distinction + rather than the boolean field in PangoAttrSize to + distinguish between attributes created + pango_attr_size_new_absolute() and + pango_attr_size_new() + 2005-03-01 Owen Taylor * pango/pango-layout.c (process_item): Don't break diff --git a/docs/tmpl/text-attributes.sgml b/docs/tmpl/text-attributes.sgml index ecbf7d9e..7c5fa9da 100644 --- a/docs/tmpl/text-attributes.sgml +++ b/docs/tmpl/text-attributes.sgml @@ -47,6 +47,7 @@ attribute is listed in parentheses after the description. @PANGO_ATTR_LETTER_SPACING: @PANGO_ATTR_UNDERLINE_COLOR: @PANGO_ATTR_STRIKETHROUGH_COLOR: +@PANGO_ATTR_ABSOLUTE_SIZE: @@ -151,12 +152,17 @@ impose shape restrictions. - +The #PangoAttrShape structure is used to represent attributes which +set font size. -@attr: -@size: -@absolute: +@attr: the common portion of the attribute +@size: size of font, in units of 1/PANGO_SCALE of a point (for + PANGO_ATTR_SIZE) or of a device uni (for PANGO_ATTR_ABSOLUTE_SIZE) +@absolute: whether the font size is in device units or points. + This field is only present for compatibility with Pango-1.8.0 + (PANGO_ATTR_ABSOLUTE_SIZE was added in 1.8.1); and always will + be %FALSE for PANGO_ATTR_SIZE and %TRUE for PANGO_ATTR_ABSOLUTE_SIZE. diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 3191c029..edf0d966 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -402,8 +402,11 @@ static PangoAttribute * pango_attr_size_copy (const PangoAttribute *attr) { const PangoAttrSize *size_attr = (PangoAttrSize *)attr; - - return pango_attr_size_new_internal (size_attr->size, size_attr->absolute); + + if (attr->klass->type == PANGO_ATTR_ABSOLUTE_SIZE) + return pango_attr_size_new_absolute (size_attr->size); + else + return pango_attr_size_new (size_attr->size); } static void @@ -419,8 +422,7 @@ pango_attr_size_equal (const PangoAttribute *attr1, const PangoAttrSize *size_attr1 = (const PangoAttrSize *)attr1; const PangoAttrSize *size_attr2 = (const PangoAttrSize *)attr2; - return (size_attr1->size == size_attr2->size && - size_attr1->absolute == size_attr2->absolute); + return size_attr1->size == size_attr2->size; } static PangoAttribute * @@ -428,15 +430,22 @@ pango_attr_size_new_internal (int size, gboolean absolute) { PangoAttrSize *result; + static const PangoAttrClass klass = { PANGO_ATTR_SIZE, pango_attr_size_copy, pango_attr_size_destroy, pango_attr_size_equal }; + static const PangoAttrClass absolute_klass = { + PANGO_ATTR_ABSOLUTE_SIZE, + pango_attr_size_copy, + pango_attr_size_destroy, + pango_attr_size_equal + }; result = g_new (PangoAttrSize, 1); - result->attr.klass = &klass; + result->attr.klass = absolute ? &absolute_klass : &klass; result->size = size; result->absolute = absolute; @@ -458,8 +467,8 @@ pango_attr_size_new (int size) } /** - * pango_attr_size_absolute_new: - * @size: the font size, in #PANGO_SCALEths of a device units. + * pango_attr_size_new_absolute: + * @size: the font size, in #PANGO_SCALEths of a device unit. * * Create a new font-size attribute in device units. * @@ -1676,10 +1685,14 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator, if (!(mask & PANGO_FONT_MASK_SIZE)) { mask |= PANGO_FONT_MASK_SIZE; - if (((PangoAttrSize *)attr)->absolute) - pango_font_description_set_absolute_size (desc, ((PangoAttrSize *)attr)->size); - else - pango_font_description_set_size (desc, ((PangoAttrSize *)attr)->size); + pango_font_description_set_size (desc, ((PangoAttrSize *)attr)->size); + } + break; + case PANGO_ATTR_ABSOLUTE_SIZE: + if (!(mask & PANGO_FONT_MASK_SIZE)) + { + mask |= PANGO_FONT_MASK_SIZE; + pango_font_description_set_absolute_size (desc, ((PangoAttrSize *)attr)->size); } break; case PANGO_ATTR_SCALE: diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h index a1877058..f26e178f 100644 --- a/pango/pango-attributes.h +++ b/pango/pango-attributes.h @@ -85,7 +85,8 @@ typedef enum PANGO_ATTR_FALLBACK, /* PangoAttrInt */ PANGO_ATTR_LETTER_SPACING, /* PangoAttrInt */ PANGO_ATTR_UNDERLINE_COLOR, /* PangoAttrColor */ - PANGO_ATTR_STRIKETHROUGH_COLOR /* PangoAttrColor */ + PANGO_ATTR_STRIKETHROUGH_COLOR, /* PangoAttrColor */ + PANGO_ATTR_ABSOLUTE_SIZE /* PangoAttrSize */ } PangoAttrType; typedef enum { -- cgit v1.2.1