Skip to main content
added 82 characters in body; edited tags
Source Link
Alexey Popkov
  • 62.5k
  • 7
  • 163
  • 405

Bug introduced in 8 or earlier and persisting through 11.2.0


I'm using Linux-x86-64 as operating system. Can someone explain this behaviour and maybe give a hint how to resolve it? Here are two lines of exact the same number of letters of a monospaced font:

Style["ZZZZZZZZZZ\n__________", 20, FontFamily -> "Courier"] 

As output I get (here with 30 Z and 30 _)

monospaced

But what I expect from a monospaced font like Courier is to have the same size for every letter (and why is the line dashed anyway?). @Oleksandr was so kind to give me mental support and tried the things on his Windows machine. There the output seems ok:

monospaced win

More detailed question

What I really want is an image of arbitrary resolution of every letter. I thought when I use a combination of Style and Rasterize I can get equally sized images of them in exact the same form as they appear in text.

But there is (at least here) a clear difference between an assembled image from rasterized letters and a rasterized version of the string

ImageAssemble[ Rasterize[Style[#, 30, FontFamily -> "Courier"], "Image"] & /@ CharacterRange["A", "Z"]] Rasterize[ Style[StringJoin[CharacterRange["A", "Z"]], 30, FontFamily -> "Courier"], "Image"] 

Mathematica graphics Mathematica graphics

What I noticed is that the height of the letters is always the same, only the width varies. Looking at how many letters have which width gives here

Sort@Tally@First@ Transpose[ ImageDimensions[ Rasterize[Style[#, 30, FontFamily -> "Courier"], "Image"]] & /@ CharacterRange["A", "z"]] (* Out[138]= {{18, 25}, {19, 16}, {20, 8}, {21, 8}, {24, 1}} *) 

This is a mess. Any ideas about this issue would be very welcome.

I'm using Linux-x86-64 as operating system. Can someone explain this behaviour and maybe give a hint how to resolve it? Here are two lines of exact the same number of letters of a monospaced font:

Style["ZZZZZZZZZZ\n__________", 20, FontFamily -> "Courier"] 

As output I get (here with 30 Z and 30 _)

monospaced

But what I expect from a monospaced font like Courier is to have the same size for every letter (and why is the line dashed anyway?). @Oleksandr was so kind to give me mental support and tried the things on his Windows machine. There the output seems ok:

monospaced win

More detailed question

What I really want is an image of arbitrary resolution of every letter. I thought when I use a combination of Style and Rasterize I can get equally sized images of them in exact the same form as they appear in text.

But there is (at least here) a clear difference between an assembled image from rasterized letters and a rasterized version of the string

ImageAssemble[ Rasterize[Style[#, 30, FontFamily -> "Courier"], "Image"] & /@ CharacterRange["A", "Z"]] Rasterize[ Style[StringJoin[CharacterRange["A", "Z"]], 30, FontFamily -> "Courier"], "Image"] 

Mathematica graphics Mathematica graphics

What I noticed is that the height of the letters is always the same, only the width varies. Looking at how many letters have which width gives here

Sort@Tally@First@ Transpose[ ImageDimensions[ Rasterize[Style[#, 30, FontFamily -> "Courier"], "Image"]] & /@ CharacterRange["A", "z"]] (* Out[138]= {{18, 25}, {19, 16}, {20, 8}, {21, 8}, {24, 1}} *) 

This is a mess. Any ideas about this issue would be very welcome.

Bug introduced in 8 or earlier and persisting through 11.2.0


I'm using Linux-x86-64 as operating system. Can someone explain this behaviour and maybe give a hint how to resolve it? Here are two lines of exact the same number of letters of a monospaced font:

Style["ZZZZZZZZZZ\n__________", 20, FontFamily -> "Courier"] 

As output I get (here with 30 Z and 30 _)

monospaced

But what I expect from a monospaced font like Courier is to have the same size for every letter (and why is the line dashed anyway?). @Oleksandr was so kind to give me mental support and tried the things on his Windows machine. There the output seems ok:

monospaced win

More detailed question

What I really want is an image of arbitrary resolution of every letter. I thought when I use a combination of Style and Rasterize I can get equally sized images of them in exact the same form as they appear in text.

But there is (at least here) a clear difference between an assembled image from rasterized letters and a rasterized version of the string

ImageAssemble[ Rasterize[Style[#, 30, FontFamily -> "Courier"], "Image"] & /@ CharacterRange["A", "Z"]] Rasterize[ Style[StringJoin[CharacterRange["A", "Z"]], 30, FontFamily -> "Courier"], "Image"] 

Mathematica graphics Mathematica graphics

What I noticed is that the height of the letters is always the same, only the width varies. Looking at how many letters have which width gives here

Sort@Tally@First@ Transpose[ ImageDimensions[ Rasterize[Style[#, 30, FontFamily -> "Courier"], "Image"]] & /@ CharacterRange["A", "z"]] (* Out[138]= {{18, 25}, {19, 16}, {20, 8}, {21, 8}, {24, 1}} *) 

This is a mess. Any ideas about this issue would be very welcome.

edited title
Link
István Zachar
  • 47.2k
  • 20
  • 147
  • 307

Display of Monospaced fonts are not monospaced font in Linux

Tweeted twitter.com/#!/StackMma/status/248663555858132992
Source Link
halirutan
  • 113.9k
  • 7
  • 269
  • 488

Display of monospaced font in Linux

I'm using Linux-x86-64 as operating system. Can someone explain this behaviour and maybe give a hint how to resolve it? Here are two lines of exact the same number of letters of a monospaced font:

Style["ZZZZZZZZZZ\n__________", 20, FontFamily -> "Courier"] 

As output I get (here with 30 Z and 30 _)

monospaced

But what I expect from a monospaced font like Courier is to have the same size for every letter (and why is the line dashed anyway?). @Oleksandr was so kind to give me mental support and tried the things on his Windows machine. There the output seems ok:

monospaced win

More detailed question

What I really want is an image of arbitrary resolution of every letter. I thought when I use a combination of Style and Rasterize I can get equally sized images of them in exact the same form as they appear in text.

But there is (at least here) a clear difference between an assembled image from rasterized letters and a rasterized version of the string

ImageAssemble[ Rasterize[Style[#, 30, FontFamily -> "Courier"], "Image"] & /@ CharacterRange["A", "Z"]] Rasterize[ Style[StringJoin[CharacterRange["A", "Z"]], 30, FontFamily -> "Courier"], "Image"] 

Mathematica graphics Mathematica graphics

What I noticed is that the height of the letters is always the same, only the width varies. Looking at how many letters have which width gives here

Sort@Tally@First@ Transpose[ ImageDimensions[ Rasterize[Style[#, 30, FontFamily -> "Courier"], "Image"]] & /@ CharacterRange["A", "z"]] (* Out[138]= {{18, 25}, {19, 16}, {20, 8}, {21, 8}, {24, 1}} *) 

This is a mess. Any ideas about this issue would be very welcome.