Skip to content

Commit

Permalink
fix font size
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Dec 12, 2023
1 parent f26ec72 commit 3d5c943
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions patches/opencv-2.4.13.7-drawing-mono-font.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ diff -Nuarp opencv-2.4.13.7.orig/modules/core/src/drawing.cpp opencv-2.4.13.7/mo
int thickness, int line_type, bool bottomLeftOrigin )

{
+ const int fontpixelsize = 8 * fontScale;
+ const int base_line = 4 * fontScale;
+ const int fontpixelsize = (fontFace == 1 ? 8 : (fontFace == 5 ? 12 : 20)) * fontScale;
+ const int base_line = 0;
+ const int yoffset = bottomLeftOrigin ? img.rows - org.y - fontpixelsize * 2 + base_line : org.y - fontpixelsize * 2 + base_line;
+
+ unsigned int _color = 0;
Expand Down Expand Up @@ -69,13 +69,13 @@ diff -Nuarp opencv-2.4.13.7.orig/modules/core/src/drawing.cpp opencv-2.4.13.7/mo

Size getTextSize( const string& text, int fontFace, double fontScale, int thickness, int* _base_line)
{
+ const int fontpixelsize = 8 * fontScale;
+ const int fontpixelsize = (fontFace == 1 ? 8 : (fontFace == 5 ? 12 : 20)) * fontScale;
+
+ int w;
+ int h;
+ get_text_drawing_size(text.c_str(), fontpixelsize, &w, &h);
+
+ *_base_line = 4 * fontScale;
+ *_base_line = 0;
+
+ return Size(w, h);
+#if 0
Expand Down
8 changes: 4 additions & 4 deletions patches/opencv-3.4.20-drawing-mono-font.patch
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ diff -Nuarp opencv-3.4.20.orig/modules/imgproc/src/drawing.cpp opencv-3.4.20/mod
}
Mat img = _img.getMat();
+
+ const int fontpixelsize = 8 * fontScale;
+ const int base_line = 4 * fontScale;
+ const int fontpixelsize = (fontFace == 1 ? 8 : (fontFace == 5 ? 12 : 20)) * fontScale;
+ const int base_line = 0;
+ const int yoffset = bottomLeftOrigin ? img.rows - org.y - fontpixelsize * 2 + base_line : org.y - fontpixelsize * 2 + base_line;
+
+ unsigned int _color = 0;
Expand Down Expand Up @@ -71,13 +71,13 @@ diff -Nuarp opencv-3.4.20.orig/modules/imgproc/src/drawing.cpp opencv-3.4.20/mod

Size getTextSize( const String& text, int fontFace, double fontScale, int thickness, int* _base_line)
{
+ const int fontpixelsize = 8 * fontScale;
+ const int fontpixelsize = (fontFace == 1 ? 8 : (fontFace == 5 ? 12 : 20)) * fontScale;
+
+ int w;
+ int h;
+ get_text_drawing_size(text.c_str(), fontpixelsize, &w, &h);
+
+ *_base_line = 4 * fontScale;
+ *_base_line = 0;
+
+ return Size(w, h);
+#if 0
Expand Down
8 changes: 4 additions & 4 deletions patches/opencv-4.8.1-drawing-mono-font.patch
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ diff -Nuarp opencv-4.8.1.orig/modules/imgproc/src/drawing.cpp opencv-4.8.1/modul
}
Mat img = _img.getMat();
+
+ const int fontpixelsize = 8 * fontScale;
+ const int base_line = 4 * fontScale;
+ const int fontpixelsize = (fontFace == 1 ? 8 : (fontFace == 5 ? 12 : 20)) * fontScale;
+ const int base_line = 0;
+ const int yoffset = bottomLeftOrigin ? img.rows - org.y - fontpixelsize * 2 + base_line : org.y - fontpixelsize * 2 + base_line;
+
+ unsigned int _color = 0;
Expand Down Expand Up @@ -71,13 +71,13 @@ diff -Nuarp opencv-4.8.1.orig/modules/imgproc/src/drawing.cpp opencv-4.8.1/modul

Size getTextSize( const String& text, int fontFace, double fontScale, int thickness, int* _base_line)
{
+ const int fontpixelsize = 8 * fontScale;
+ const int fontpixelsize = (fontFace == 1 ? 8 : (fontFace == 5 ? 12 : 20)) * fontScale;
+
+ int w;
+ int h;
+ get_text_drawing_size(text.c_str(), fontpixelsize, &w, &h);
+
+ *_base_line = 4 * fontScale;
+ *_base_line = 0;
+
+ return Size(w, h);
+#if 0
Expand Down

0 comments on commit 3d5c943

Please sign in to comment.