# Would a question about choice of font size be allowed?

I am a programmer who saw this site "from" StackOverflow in hope to ask here for help with a specific problem. The reason I post this question here is because I fear that my question might not fit allowed topics for this site, so I want to check if it is valid before I post it.

I have a rectangle that should contain text in it. The problem is that I need to calculate font size, so the text can fit into rectangle. I need formula for this ( colleagues at StackOverflow could not help me with this ). In a nutshell, this is the most important information about the question I would ask.

Is this question suitable for this site ( and if it is, can you suggest me proper tags )?

Thank you.

• It could be tagged geometry. But one has to flesh out a math question from a practical problem. Variable width font or constant? Hyphenation allowed? (I hope not). What do you know about the font metrics?... – user147263 Jul 4 '14 at 14:05
• Also, this was brought up several times on SO, for example stackoverflow.com/q/687998. Text layout is an algorithm design problem. So is automatic font sizing. My point is, SO is still a better choice of a site. – user147263 Jul 4 '14 at 14:10
• @Thisismuchhealthier.: Unfortunately, I do not use JQuery/JS so they were unable to help. Since I need formula and not the code, I thought that well posed question on this site could solve the problem. Thanks anyway... – AlwaysLearningNewStuff Jul 4 '14 at 14:18
• You see, mathematical formulas need precise input. What would be the input in your case? Box dimensions, number of characters, length of every word, width of every character, hyphenation rules, kerning rules, line spacing. How all of this will be expressed mathematicaly? This looks more like a library function than a formula. – user147263 Jul 4 '14 at 14:24
• @Thisismuchhealthier.: Maybe you are right, this would be too much, when we look from that perspective... Best regards. – AlwaysLearningNewStuff Jul 4 '14 at 14:40
• Please don't take my comments as dismissal; I was trying to elucidate the nature of the question. My point is, to make this work in every case, you need a lot of conditional logic. But if you just need a rule of thumb that kind of works in most cases, then try $$\text{size} = C \sqrt{\frac{ab}{L}}$$ where $L$ is the number of characters, $a,b$ are dimensions of the box, and $C$ is a constant that hides all the layout complexity, and is found experimentally. That is, you pick a font and run tests using 100 sample texts of various kinds. Then reduce $C$ to have a safety margin. – user147263 Jul 4 '14 at 14:48
• I think that question could be answered if I put enough info, which your suggested "solution" proves. I didn't misunderstand you, I just couldn't decide if I should post the question or not. Seeing your comment, I believe I should give a try... Thank you for your time and help. – AlwaysLearningNewStuff Jul 4 '14 at 16:20
• If you can give us enough information that this becomes a purely mathematical question - that is, a question answerable by someone who knows nothing about programming - then I don't see why it would be off-topic. However, it does sound (to me) like that could be a bit difficult. – Alexander Gruber Jul 4 '14 at 16:27
• @AlexanderGruber: I think I can do this, but I need to formulate the question very precisely, and must find a way to present data in a manner that doesn't require programming knowledge in order to interpret them. Thank you for answering. – AlwaysLearningNewStuff Jul 4 '14 at 16:44
• IMHO, this is off topic for math.SE. To properly answer this question, one need to to know what components a glyph consists of, what sort of data is available in a font set more than the math involved. For this sort of typography related questions, I think tex.SE has more experts than here. However, I'm not sure whether this question is on topic for them or not. – achille hui Jul 6 '14 at 9:15
• I think this is off-topic because you would need to know all about the specific font, and how exactly the software converts the font-size (in points or ems or whatever) into the actual pixel-size. – Jack M Jul 6 '14 at 14:55
• For font point size vs pixel size, see graphic design – Justin Jul 12 '14 at 5:40