1

Use of a vertical Spacer in justified text inside a graphic isn't working as required. The result in the green box looks right, but when this is placed in a graphic the spacing is messed up. Is there some way to fix it?

g1 = StringTake[ExampleData[{"Text", "BeowulfModern"}], {4740, 5200}];
g2 = StringTake[g1, 319] <> "\n";
g3 = StringDrop[g1, 319];
g4 = Row[{g2, Spacer[{0, 30}], g3}];

TextCell[g4, LineSpacing -> {0, 16}, TextJustification -> 1, 
 Background -> LightGreen]

Graphics[{
  LightBlue, Rectangle[{0, 0}, {500, 140}], Black,
  Inset[TextCell[g4, LineSpacing -> {0, 16}, TextJustification -> 1],
   {0, 0}, {Left, Bottom}, {500, Automatic}]},
 PlotRange -> {{0, 500}, {0, 140}}, ImageSize -> 500,
 BaseStyle -> {FontFamily -> "Courier New", FontSize -> 12}]

enter image description here

Chris Degnen
  • 30,927
  • 2
  • 54
  • 108
  • 1
    It works fine in version 9. I don't have a 7 so can not test it. A wild guess is something goes wrong with the baseline alignment.. Maybe try Column instead of Row in g4? – Silvia Jan 17 '13 at 18:01
  • Chris, I found this question deleted but I can duplicate both the problem and the solution so I undeleted it. If this is a problem I can delete it again but I am assuming you thought it was of no interest, yet it is. – Mr.Wizard Jan 21 '13 at 18:30
  • @Mr.Wizard - I thought I was going to need the Magnify trick again, but an option sufficed. http://mathematica.stackexchange.com/a/15766/363 – Chris Degnen Jan 22 '13 at 07:30

1 Answers1

2

Problem fixed with the TextCell option CellBaseline, i.e.:-

Graphics[{LightBlue, Rectangle[{0, 0}, {500, 140}], Black,
  Inset[TextCell[g4, LineSpacing -> {0, 16}, TextJustification -> 1,
    CellBaseline -> Bottom],
   {0, 0}, {Left, Bottom}, {500, Automatic}]},
 PlotRange -> {{0, 500}, {0, 140}}, ImageSize -> 500,
 BaseStyle -> {FontFamily -> "Courier New", FontSize -> 12}]

By the way, this method is handy to give a line separation less than "\n" would provide.

Chris Degnen
  • 30,927
  • 2
  • 54
  • 108