After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 114237 - Add squiggly-red underline type
Add squiggly-red underline type
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.2.x
Other Linux
: Normal normal
: 1.4 API freeze
Assigned To: pango-maint
pango-maint
Depends on:
Blocks: 132827
 
 
Reported: 2003-06-02 09:25 UTC by Jeroen Zwartepoorte
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Underlining using wavy lines. Introduces PANGO_UNDERLINE_ERROR. (5.45 KB, patch)
2003-11-17 11:01 UTC, Nicolas Setton
none Details | Review
Add handling in gdk/gtk and tests for PANGO_UNDERLINE_ERROR (4.25 KB, patch)
2003-11-17 11:03 UTC, Nicolas Setton
none Details | Review

Description Jeroen Zwartepoorte 2003-06-02 09:25:58 UTC
For gtksourceview/glimmer/gedit, we'd like to be able to display
programming/spelling etc. errors by displaying a "wavy line" below the text
(same as underline). Evolution 1.4 is probably also very interested in this
(afaics they regressed in this wrt to the 1.2 version because pango doesn't
support it). 

See http://www.xs4all.nl/~jeroen/screenshots/Screenshot-JBuilder.png how
it's done in Swing/Java.

Afaics, the only way to do this now is to hack pango to add a new text
attribute. Is this correct? If so, what would be the correct solution? I
can think of two things:
1. Add a new text attribute to pango itself and hope that covers all the
possible attributes.
2. Extend pango/GtkTextView somehow to support custom text attributes in a
usable manner.
Comment 1 Owen Taylor 2003-06-02 13:28:29 UTC
Pango already allows custom attributes ... but it doesn't
do you any good:

 A) GDK would have to know how to render the new attribute
 B) GtkTextView, as it turns out, actually uses a custom
    attribute when passing its style information through
    Pango rather than the standard ones
 C) Even if B) wasn't true, how would you *set* it within
    a GtkTextView?

I don't see a way that is going to magically allow GTK+
Pango and GDK to magically know all about new attribute
types.

I thought there was a squiggly-red-underline bug open,
but I can't find it, so I'll retitle this bug report.
Comment 2 David Malcolm 2003-10-31 02:21:50 UTC
(added Conglomerate's Bugzilla-tracking mailing list to the cc, as
this may be of use to us as well)
Comment 3 Nicolas Setton 2003-11-17 11:01:55 UTC
Created attachment 21527 [details] [review]
Underlining using wavy lines. Introduces PANGO_UNDERLINE_ERROR.
Comment 4 Nicolas Setton 2003-11-17 11:03:21 UTC
Created attachment 21528 [details] [review]
Add handling in gdk/gtk and tests for PANGO_UNDERLINE_ERROR
Comment 5 Nicolas Setton 2003-11-17 11:19:04 UTC
I have attached patches introducing a new pango underlining attribute,
PANGO_UNDERLINE_COLOR, that draws a wavy, red underline.

The main issue concerning this patch is the "red" color: right now it
is hard-coded in gtktextdisplay.c, but the right place for this color
would be in the style. Since this is not done yet, the only place
where I actually use the "red" color is in the drawing of the wavy
underline for the gtk_text_view. 

Some other points, which I think could be done incrementally, at later
stages:

 - we should draw the underline thicker for big fonts
 - we could use a pair of stippled lines to draw the wave, instead of
drawing point by point, for better efficiency.
Comment 6 Jeroen Zwartepoorte 2003-11-17 12:56:47 UTC
Looks good in testtext. Can we get this in gtk 2.3?
Comment 7 Owen Taylor 2003-11-18 04:24:07 UTC
The Pango patch looks basically OK - two comments about
the XDrawPoint() calls - the line break is wrong, and 
I'm not sure why you are using lines for the two other
backends and points here.
Comment 8 Nicolas Setton 2003-11-18 18:02:15 UTC
  Sorry about the line wrong breaks - I'm used to the Ada style :-/

  About the "points vs lines" issue, I first implemented with points, 
then realized lines would be a better way to go, especially when 
scaling up was involved. But then, I didn't really work to make these 
procedure exactly alike, since the final aspect is the same, and is 
probably subject to changes.

  After all, there wasn't any discussion on the graphical aspect of 
the lines (maybe I should have brought this up :-/)

  Right now the lines are drawn like this: (zoom on the pixels)

 OO  OO  OO  OO  OO  OO  OO  OO
   OO  OO  OO  OO  OO  OO  OO  OO

  I arbitrarily chose to render the wave this way, since it is what 
Evolution draws when activating the spell checker. But other 
applications (such as JBuilder) draw the lines like that:

  /\    /\    /\    /\   
 /  \  /  \  /  \  /  \  
     \/    \/    \/    \/

  Which is also pretty cool and "scales up" more nicely.
  
  What do you think ? As soon as there is consensus, I'll be happy to 
go back to the patch and implement the chosen solution.
Comment 9 Nicolas Setton 2003-11-18 18:37:49 UTC
Added myself to the CC
Comment 10 Owen Taylor 2004-02-29 20:45:48 UTC
Applied Pango patch with reordering of enum values to avoid
changing the numeric value of PANGO_UNDERLINE_LOW.

Also, changed the drawing routines not to overshoot by one
for odd underline widths.

Sun Feb 29 15:31:09 2004  Owen Taylor  <otaylor@redhat.com>
                                                                     
                                                               
        Patch from Nicolas Setton, #114237
                                                                     
                                                               
        * pango/pango-attributes.h pango/pango-markup.c: Add a
        new underline type, PANGO_UNDERLINE_ERROR.
                                                                     
                                                               
        * pango/pangowin32.c pango/pangox.c pango/pangoft2.c:
        Implement drawing of PANGO_UNDERLINE_ERROR.
                                                                     
                                                               
        * pango/pango-layout.c (pango_layout_run_get_extents):
        Handle PANGO_UNDERLINE_ERROR.

I think the more wavy wave would be nice, but for right now,
when we don't have modification of the underline thickness
with font size, keeping things small is probably good.
Comment 11 Owen Taylor 2004-02-29 21:39:30 UTC
Sun Feb 29 16:35:23 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkpango.c gtk/gtktextdisplay.c: Implement
        PANGO_UNDERLINE_ERROR (Based on a patch by
        Nicolas Setton, #114237)
 
        * gtk/gtktextview.c: Add a error-underline-color style
        property.