From 9cd8a52b37ccd640131769e04bbefac21249339d Mon Sep 17 00:00:00 2001 From: David Mathog <> Date: Thu, 27 Sep 2012 08:50:36 +0200 Subject: initial changes to address problem of importing chunks of text into something editable (See also: bug #366744) (bzr r11668.1.17) --- src/libnrtype/Layout-TNG-Output.cpp | 66 +++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 48d18850e..1d293e360 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -44,24 +44,37 @@ using Inkscape::Extension::Internal::CairoGlyphInfo; namespace Inkscape { namespace Text { -// the dx array is smuggled through to the EMF (ignored by others) as: -// textN w1 w2 w3 ...wN -// where the widths are floats 7 characters wide, including the space -char *smuggle_adx_in(const char *string, int ndx, int size, float *adx){ +/* + dx array (character widths) and + ky (vertical kerning for entire span) + + are smuggled through to the EMF (ignored by others) as: + textN w1 w2 w3 ...wNy1 y2 y3 .. yN + where the widths and y kern values are floats 7 characters wide, including the space +*/ +char *smuggle_adxky_in(const char *string, int ndx, float *adx, float ky){ int slen=strlen(string); - // holds: string, fake terminator, Number of offsets, series of offsets, real (double) terminator. - int newsize=slen + 1 + 7 + 7*ndx + 2; - newsize = 8*((7 + newsize)/8); // suppress valgrind messages if it is a multiple of 8 bytes??? - char *smuggle=(char *)calloc(newsize,1); //initialize all bytes, inluding terminators - strcpy(smuggle,string); - char *cptr = smuggle + slen + 1; // immediately after the first terminator - sprintf(cptr,"%07d",ndx); + /* holds: string + fake terminator (one \0) + Number of widths (ndxy) + series of widths (ndxy entries) + fake terminator (one \0) + y kern value (one float) + real terminator (two \0) + */ + int newsize=slen + 1 + 7 + 7*ndx + 1 + 7 + 2; + newsize = 8*((7 + newsize)/8); // suppress valgrind messages if it is a multiple of 8 bytes??? + char *smuggle=(char *)calloc(newsize,1); // initialize all bytes, inluding terminators + strcpy(smuggle,string); // text to pass + char *cptr = smuggle + slen + 1; // immediately after the first fake terminator + sprintf(cptr,"%07d",ndx); // number of widths to pass cptr+=7; - for(int i=0; iw1 w2 w3 ...wn // where the widths are floats 7 characters wide, including the space - char *smuggle_string=smuggle_adx_in(span_string.c_str(),ndx,MAX_DX, &hold_dx[0]); + char *smuggle_string=smuggle_adxky_in(span_string.c_str(),ndx, &hold_dx[0], ky); // sp_print_text(ctx, span_string.c_str(), g_pos, text_source->style); sp_print_text(ctx, smuggle_string, g_pos, text_source->style); free(smuggle_string); -- cgit v1.2.3