D
D
D_E_S2017-01-18 16:52:53
JavaScript
D_E_S, 2017-01-18 16:52:53

How to calculate the height of the occupied text without rendering?

There is a block of a certain width. It is necessary to change its height depending on the occupied text. Everything is generated in a file. We know the font size and indents.
What am I doing:

var set_width = 20;
var font_size = 11;
var count_symbol = text.length;
var count_line = Math.round((count_symbol)/set_width )+1;
var set_height = (font_size *count_line)+((font_size /2)*count_line);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
catHD, 2017-01-18
@catHD

nodejs?

Виталий, 2017-01-18
@vitali1995

Действительно, причём здесь node.js? Какая ещё высота в консольной программе?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question