Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Consider this code:

fc = ImportString[ExportString[Style["Ma"], "PDF"], "PDF"][[1, 1, 2, 1, 1]];
lines = GeometricFunctions`DecodeFilledCurve[fc][[1]];
{lines // Length,Graphics[JoinedCurve[#]] & /@ lines}

will give what is expected:

enter image description here

but this code:

fc = ImportString[ExportString[Style["Ma", FontFamily -> "Times"], "PDF"], "PDF"][[1, 1, 2, 1, 1]];
lines = GeometricFunctions`DecodeFilledCurve[fc][[1]];
{lines // Length, Graphics[JoinedCurve[#]] & /@ lines}

gives four things, with the fourth element is just a point:

enter image description here

lines[[-1]]
(*{Line[{{10.5607,9.40406},{10.5607,9.40406}}]}*)

Why there is an extra point in the second case? I'm using version 9 on Mac.

Update

screenshots of the problem on version 8 and 9 on mac, and version 8 on windows 7, the results seems different:

enter image description here

enter image description here enter image description here

share|improve this question
    
I don't get the extra point. –  b.gatessucks May 10 '13 at 21:45
    
I don't get it either (Win7, v9.01) –  Sjoerd C. de Vries May 10 '13 at 23:17
    
BTW The first picture is not created by the first block of code. –  Sjoerd C. de Vries May 10 '13 at 23:42
    
@SjoerdC.deVries sorry, I corrected it. –  xslittlegrass May 11 '13 at 3:54
    
Ok, so it is OS dependent then. Unfortunately, I can't help with that as I don't have OSX. I assume that it is caused by its PDF exporter. There is a remote possibility that it may be a problem of the font itself. –  Sjoerd C. de Vries May 11 '13 at 6:29

1 Answer 1

up vote 3 down vote accepted

I've encountered this problem, coming from a slightly different direction. I think the compound paths contain an extra pair of coordinates that you're noticing when you split up the results of a FilledCurve.

Here's how I first came across this:

glyph[code_, font_, size_] := 
  First[First[
    ImportString[
     ExportString[
      Style[FromCharacterCode[code], FontSize -> size, 
       FontFamily -> font], "PDF"], "TextMode" -> "Outlines"]]]; 

a = glyph[97, "Times", 24] 
{Thickness[0.130073],
  {FilledCurve[
    {
      {{1,4,3},{1,3,3},{0,1,0},{1,3,3},{1,3,3},{1,3,3},{1,3,3}},
      {{1,4,3},{1,3,3},{0,1,0},{1,3,3},{1,3,3},{1,3,3}, ...
      {{0,2,0}}},
     {
      {{3.74836,5.265},{4.01063,5.265},{4.25426,5.35078}, ...
      {{0.405,5.96742},{0.405,6.74086},{0.77502,7.35469}, ...
      {{4.1175,12.4875},{4.1175,12.4875}}}]}}

The {{4.1175,12.4875},{4.1175,12.4875}} is a short zero-length line that I think might be causing the problems.

I noticed it when I selected the graphic. I could see that there was something odd there:

Graphics[{Gray, a}] 

the letter a selected

The short line registers oddly as a large dot.

Looking at all the letter forms, it appears that you definitely get this extra line for many letters, not just for "compound paths".

Length[#[[2, 1, 1, 2]]] & /@ (glyph[#, "Helvetica", 24] & /@ 
   ToCharacterCode /@ Characters["abcdefghijklmnopqrstuvwxyz"]);
BarChart[%, ChartLabels -> Characters["abcdefghijklmnopqrstuvwxyz"]]

chart

There's "a", "e", and "o" which have three elements in the relevant FilledCurve. "b" has two, like it should have, but "c" should only have one. "n", "s", and "u" also have more elements than they need. And so on.

You could probably fix this by adding a rule that makes zero-length lines get deleted from the FilledCurve, but that's proved beyond my expertise...

tl;dr I think it's a bug, but who knows whether in Mathematica or the Mac OS system.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.