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.

I'm trying to find an explanation for the different sizes I'm seeing for fonts added to graphics in different ways, and haven't yet located an easy to understand explanation. Here's a minimal example:

Graphics[
 {LightGray,
  Rectangle[{0, 0}, {72, 72}],
  Red,
  Style[
   Text["Hig", {0, 0}, {-1, -1}], 72,
   FontFamily -> "Times New Roman"],
  Black,
  First[
   First[
    ImportString[
     ExportString[
      Style["Hig", 
       FontFamily -> "Times New Roman", 
       FontSize -> 72], "PDF"],
     "TextMode" -> "Outlines"]]]
  },
 PlotRange -> {{0, 100}, {0, 100}}, 
 Axes -> True, 
 Ticks -> {Table[x, {x, 0, 100, 10}], Table[x, {x, 0, 100, 10}]},
 Epilog -> {Text["72", {200, 75}], Line[{{0, 72}, {200, 72}}]}]

fonts

The red text doesn't change size when you resize the graphic, although everything else changes. The black text resizes along with everything else. But neither text seems to be the result of specifying 72.

Update

After changing the screen resolution to Automatic following @Sjoerd's suggestion, I can see how the red text is basically displaying at a fixed size that's independent of Mathematica. In this picture, the left image shows 72 dpi, the red font is using 70ish pixels of vertical space. The right image is at 'Automatic' (so presumably 133.51 for my machine, according to this site, and similarly uses up 70ish pixels.

resolutions

I'm still puzzled by the size of the black font, which doesn't seem to be related to the specified font size or to the screen resolution. Perhaps the PDF translation introduces another scaling factor.

share|improve this question
1  
Related, perhaps useful: Fontsize is too small. –  István Zachar Apr 17 '13 at 16:44
add comment

2 Answers

The FontSize refers to printers points, which by convention are 1/72 of an inch. So the red 'Hig' is fixed to an external font size and will not scale with the graphic. However, you are right to say that this font size doesn't seem to be strictly 72 points... If you try:

Export["hig.pdf", Style["Hig", FontFamily -> "Times New Roman", FontSize -> 72]]

a quick comparison with 72pt text generated in Illustrator shows that the fontsize is ~51 pts or ~30% too small (the Mathematica 72pt text is on the right):

illustrator 72pt vs mma 72pt

I have no clue as to why Mathematica text is too small....

Your second block of text is converted to a scalable graphic by the ImportString[ ExportString[Style[...], "PDF"],"TextMode" -> "Outlines"]]] transform. Enclosing this routine in FullForm demonstrates that the text has been converted into a FilledCurvecomprised of nested lists (i.e. is no longer treated as text but rather as a scalable graphic element). As a result, it is scaled with the units of the graphic.

FullForm[ImportString[
  ExportString[
   Style["Hig", FontFamily -> "Times New Roman", FontSize -> 72], 
   "PDF"], "TextMode" -> "Outlines"]]

List[Graphics[ List[Thickness[0.0128601], Style[List[ FilledCurve[ List[List[List[0, 2, 0], List[0, 1, 0], List[1, 3, 3], List[1, 3, 3], List[1, 3, 3], List[0, 1, 0], List[0, 1, 0], List[0, 1, 0], List[0, 1, 0], List[0, 1, 0], List[1, 3, 3], List[1, 3, 3], List[1, 3, 3],<<.......>>List[59.7569, 11.0567]]]]], Thickness[0.0128601]]], Rule[ImageSize, List[78., 56.]], Rule[PlotRange, List[List[0., 77.76], List[0., 56.]]], Rule[AspectRatio, Automatic]]]

with,

FullForm[Style["Hig", FontFamily -> "Times New Roman", FontSize -> 72]]

Style["Hig", Rule[FontFamily, "Times New Roman"], Rule[FontSize, 72]]

Interestingly, even when scaled, the size disparity persists, as can be seen if you resize your graphic such that the red and black text overlap, then the grey square is approximately one inch wide...

share|improve this answer
    
The black text could also be seen as being about 51 'units' high too. Kind of consistent, in a funny way. –  cormullion Apr 17 '13 at 14:57
    
@cormullion, yes, I think that is right. By the way, why are you using the First[first[ImportString[ExportString[..construct? where does it come from? –  geordie Apr 17 '13 at 15:10
    
@geordie It's from the FilledCurve documentation page. –  Sjoerd C. de Vries Apr 17 '13 at 15:11
    
@SjoerdC.deVries, Thanks, it looks like a handy hack! :] –  geordie Apr 17 '13 at 15:19
add comment

I will not duplicate geordie's explanation of the scaling-with-graphics-resize part of the question.

The reason the displayed font looks too small is the setting of the "ScreenResolution" option (part of FontProperties) to 72, which used to be the default for decades, but is incorrect for most screens nowadays.

If you set it to Automatic (or perhaps the value you know is correct for your display)

SetOptions[$FrontEnd, FontProperties -> {"ScreenResolution" -> Automatic}]

you'll get a better match. Compare the default setting

enter image description here

with the Automatic one on my display

enter image description here

share|improve this answer
    
hmmm, how does it compare when exported to say Illustrator or Acrobat etc.? Does the size issue persist? –  geordie Apr 17 '13 at 15:13
    
Your black text looks correct in both examples. I'll investigate that option now... –  cormullion Apr 17 '13 at 15:30
    
@cormullion Actually, the option should have impact on the red letters. –  Sjoerd C. de Vries Apr 17 '13 at 20:01
add comment

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.