From: <and...@us...> - 2013-10-04 21:43:15
|
Revision: 12577 http://sourceforge.net/p/plplot/code/12577 Author: andrewross Date: 2013-10-04 21:43:12 +0000 (Fri, 04 Oct 2013) Log Message: ----------- Implement support for underlining ("#-" escape code) in cairo driver, and warn that overline and backchar are not supported. Modified Paths: -------------- trunk/drivers/cairo.c trunk/include/plplot.h trunk/src/plcore.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2013-10-03 21:51:23 UTC (rev 12576) +++ trunk/drivers/cairo.c 2013-10-04 21:43:12 UTC (rev 12577) @@ -108,6 +108,7 @@ char *pangoMarkupString; short upDown; float fontSize; + short uline; // These are arguments for plP_script_scale which must be retained // in aStream for the alt_unicode approach. level has an @@ -648,6 +649,7 @@ aStream = (PLCairo *) pls->dev; aStream->upDown = 0; + aStream->uline = 0; aStream->level = 0; aStream->pangoMarkupString = (char *) malloc( sizeof ( char ) * MAX_MARKUP_LEN ); // Calculate the font size (in points since DPI = 72). @@ -742,6 +744,23 @@ } aStream->upDown--; break; + case PLTEXT_UNDERLINE: + if ( aStream->uline == 1 ) + { + strncat( aStream->pangoMarkupString, "</span>", MAX_MARKUP_LEN - 1 - strlen( aStream->pangoMarkupString ) ); + aStream->level++; + } + else + { + strncat( aStream->pangoMarkupString, "<span underline=\"single\">", MAX_MARKUP_LEN - 1 - strlen( aStream->pangoMarkupString ) ); + aStream->level++; + } + aStream->uline = !aStream->uline; + break; + case PLTEXT_BACKCHAR: + case PLTEXT_OVERLINE: + plwarn( "'-', and 'b/B' text escape sequences not processed." ); + break; } } @@ -970,7 +989,7 @@ // http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html //-------------------------------------------------------------------------- -char *ucs4_to_pango_markup_format( PLUNICODE *ucs4, int ucs4Len, float fontSize ) +char *ucs4_to_pango_markup_format( PLUNICODE *ucs4, int ucs4Len, float fontSize) { char plplotEsc; int i; @@ -979,7 +998,8 @@ char utf8[5]; char *pangoMarkupString; PLFLT old_sscale, sscale, old_soffset, soffset; - PLINT level = 0.; + PLINT level = 0; + short uline = 0; // Will this be big enough? We might have lots of markup. pangoMarkupString = (char *) malloc( sizeof ( char ) * MAX_MARKUP_LEN ); @@ -1071,6 +1091,21 @@ } upDown--; } + if ( ucs4[i] == (PLUNICODE) '-' ) // Superscript + { + if ( uline == 1 ) + { + strncat( pangoMarkupString, "</span>", MAX_MARKUP_LEN - 1 - strlen( pangoMarkupString ) ); + level++; + } + else + { + strncat( pangoMarkupString, + "<span underline=\"single\">", + MAX_MARKUP_LEN - 1 - strlen( pangoMarkupString ) ); + } + uline = uline; + } i++; } } Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2013-10-03 21:51:23 UTC (rev 12576) +++ trunk/include/plplot.h 2013-10-04 21:43:12 UTC (rev 12577) @@ -250,6 +250,9 @@ #define PLTEXT_FONTCHANGE 0 // font change in the text stream #define PLTEXT_SUPERSCRIPT 1 // superscript in the text stream #define PLTEXT_SUBSCRIPT 2 // subscript in the text stream +#define PLTEXT_BACKCHAR 3 // back-char in the text stream +#define PLTEXT_OVERLINE 4 // toggle overline in the text stream +#define PLTEXT_UNDERLINE 5 // toggle underline in the text stream // image operations #define ZEROW2B 1 Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2013-10-03 21:51:23 UTC (rev 12576) +++ trunk/src/plcore.c 2013-10-04 21:43:12 UTC (rev 12577) @@ -1070,6 +1070,24 @@ i += 1; skip = 1; break; + case 'b': + args.n_ctrl_char = PLTEXT_BACKCHAR; + plP_esc( PLESC_CONTROL_CHAR, &args ); + i += 1; + skip = 1; + break; + case '+': + args.n_ctrl_char = PLTEXT_OVERLINE; + plP_esc( PLESC_CONTROL_CHAR, &args ); + i += 1; + skip = 1; + break; + case '-': + args.n_ctrl_char = PLTEXT_UNDERLINE; + plP_esc( PLESC_CONTROL_CHAR, &args ); + i += 1; + skip = 1; + break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |