0

I am trying to decide how many spaces a Unicode character or a plain ASCII character takes in a powerpoint slide. I found that Unicode characters take more spaces than ASCII characters in general. However, to complicate the situation further, it seems that same character in different font may also take different spaces.

For example, for font arial, Unicode takes four spaces, but in font 新宋体, the same Unicode character only takes two spaces.

I am wondering is there any way to decide this systematically?

jdhao
  • 24,001
  • 18
  • 134
  • 273
  • Which OS? Which programming language? There are APIs for querying text metrics for given fonts. – Remy Lebeau Jan 07 '20 at 05:40
  • I want to use it mainly for Linux (I am generating powerpoint files using some Python package). The language should preferably in Python, but other programming languages are OK. – jdhao Jan 07 '20 at 06:04
  • 1
    Basically the only correct solution is to layout the text using the same code, fonts and settings that would do the actual printing and then get the length of that. If you need a **correct** solution for every case, there's basically no way around this. If "good enough for most of my use cases" suffices, then you can cut some corners. – Joachim Sauer Jan 07 '20 at 07:42
  • [This question](https://stackoverflow.com/questions/35771863/how-to-calculate-length-of-string-in-pixels-for-specific-font-and-size) has two possible solutions (one Windows-only, the other portable) that might be "good enough" for you. – Joachim Sauer Jan 07 '20 at 10:25
  • 1
    Does this answer your question? [How to calculate length of string in pixels for specific font and size?](https://stackoverflow.com/questions/35771863/how-to-calculate-length-of-string-in-pixels-for-specific-font-and-size) – Joachim Sauer Jan 07 '20 at 10:25
  • Thanks for pointing out. I will try the solution there and see if it works. – jdhao Jan 07 '20 at 10:57

0 Answers0