1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge pull request #10575 from ioxp:getFontScale

This commit is contained in:
Vadim Pisarevsky
2018-01-16 10:51:04 +00:00
2 changed files with 25 additions and 0 deletions
+11
View File
@@ -2364,6 +2364,17 @@ Size getTextSize( const String& text, int fontFace, double fontScale, int thickn
return size;
}
double getFontScaleFromHeight(const int fontFace, const int pixelHeight, const int thickness)
{
// By https://stackoverflow.com/a/27898487/1531708
const int* ascii = getFontData(fontFace);
int base_line = (ascii[0] & 15);
int cap_line = (ascii[0] >> 4) & 15;
return static_cast<double>(pixelHeight - static_cast<double>((thickness + 1)) / 2.0) / static_cast<double>(cap_line + base_line);
}
}