Leave feedback
  • Character spacing in Story Teller

Write an Article
Wednesday 23 July, 2014
Enrik Beste Enrik Beste StreamServe Employee
3 likes 1994 views

Currently there is no parameter in StoryTeller available for character spacing. Here is a solution creating a corresponding Rich Text formatted sequence.

Sample

A text ZINSEN (Times New Romain, 13pt bold) with a spacing of 1.0 pt (ZINSEN) is in RichText Format defined as follows

//{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}
//{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang7\b\f0\fs26 Z\b0\fs16 \b\fs26 I\b0\fs16 \b\fs26 N\b0\fs16 \b\fs26 S\b0\fs16 \b\fs26 E\b0\fs16 \b\fs26 N\par}

Scripting

// © EB 20140704
// Read the field titel and convert to uppercases
$titel=toupper(stevalxpath("titel"));
// RTF initial sequences
$rich_titel="{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang7\b\f0\";
// Take first character
$rich_titel=$rich_titel+"fs26 "+$titel(1,1);
// Parameter for the loop
$str_length=strlen($titel);
$idx=2;
// This is the spacing parameter. A blank will be added with this character spacing
$spacing="12";
// Loop through all characters
while (num($idx) <=num($str_length))
{
$next_character=$titel($idx,1);
// Initially RTF was only 7-bit based, was then enhanced to 8-bit characters. UTF needs a workaround in the representation. A simple solution is a hardcoded list of characters
switch ($next_character)
{
case "Ä": $next_character="\'c4"; break;
case "Ü": $next_character="\'dc"; break;
case "Ö": $next_character="\'d6"; break;
case "ä": $next_character="\'e4"; break;
case "ü": $next_character="\'fc"; break;
case "ö": $next_character="\'f6"; break;
case "ß": $next_character="\'df"; break;
}
// Special effect: If the text should have no spacing (<spacing>0</spacing>) no blank is added. This can be also used for a data-driven spacing.
if (stevalxpath("spacing") !="0") $rich_titel= $rich_titel+ "\fs"+$spacing+" ";
$rich_titel= $rich_titel+ "\fs26 "+$next_character;
$idx++;
}
// Closing RTF sequence. Output variable is $dok_title_name which needs to be a substition of type Rich in StoryTeller
$dok_titel_name=$rich_titel+"}";

Comments (0)

   


Post comment