|
|
|
@ -1941,7 +1941,11 @@ static const int HersheyComplex[] = { |
|
|
|
|
2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2223, 2084, |
|
|
|
|
2224, 2247, 587, 2249, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, |
|
|
|
|
2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, |
|
|
|
|
2225, 2229, 2226, 2246 }; |
|
|
|
|
2225, 2229, 2226, 2246, 2801, 2802, 2803, 2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811, |
|
|
|
|
2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, |
|
|
|
|
2827, 2828, 2829, 2830, 2831, 2832, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, |
|
|
|
|
2910, 2911, 2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, |
|
|
|
|
2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932}; |
|
|
|
|
|
|
|
|
|
static const int HersheyComplexItalic[] = { |
|
|
|
|
(9 + 12*16) + FONT_ITALIC_ALPHA + FONT_ITALIC_DIGIT + FONT_ITALIC_PUNCT + |
|
|
|
@ -2033,6 +2037,50 @@ static const int* getFontData(int fontFace) |
|
|
|
|
return ascii; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline void readCheck(int &c, int &i, const String &text, int fontFace) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
int leftBoundary = ' ', rightBoundary = 127; |
|
|
|
|
|
|
|
|
|
if(c >= 0x80 && fontFace == FONT_HERSHEY_COMPLEX) |
|
|
|
|
{ |
|
|
|
|
if(c == 0xD0 && (uchar)text[i + 1] >= 0x90 && (uchar)text[i + 1] <= 0xBF) |
|
|
|
|
{ |
|
|
|
|
c = (uchar)text[++i] - 17; |
|
|
|
|
leftBoundary = 127; |
|
|
|
|
rightBoundary = 175; |
|
|
|
|
} |
|
|
|
|
else if(c == 0xD1 && (uchar)text[i + 1] >= 0x80 && (uchar)text[i + 1] <= 0x8F) |
|
|
|
|
{ |
|
|
|
|
c = (uchar)text[++i] + 47; |
|
|
|
|
leftBoundary = 175; |
|
|
|
|
rightBoundary = 191; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if(c >= 0xC0 && text[i+1] != 0) //2 bytes utf
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
|
|
if(c >= 0xE0 && text[i+1] != 0) //3 bytes utf
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
|
|
if(c >= 0xF0 && text[i+1] != 0) //4 bytes utf
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
|
|
if(c >= 0xF8 && text[i+1] != 0) //5 bytes utf
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
|
|
if(c >= 0xFC && text[i+1] != 0) //6 bytes utf
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
|
|
c = '?'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(c >= rightBoundary || c < leftBoundary) |
|
|
|
|
c = '?'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
extern const char* g_HersheyGlyphs[]; |
|
|
|
|
|
|
|
|
|
void putText( InputOutputArray _img, const String& text, Point org, |
|
|
|
@ -2066,8 +2114,7 @@ void putText( InputOutputArray _img, const String& text, Point org, |
|
|
|
|
int c = (uchar)text[i]; |
|
|
|
|
Point p; |
|
|
|
|
|
|
|
|
|
if( c >= 127 || c < ' ' ) |
|
|
|
|
c = '?'; |
|
|
|
|
readCheck(c, i, text, fontFace); |
|
|
|
|
|
|
|
|
|
const char* ptr = faces[ascii[(c-' ')+1]]; |
|
|
|
|
p.x = (uchar)ptr[0] - 'R'; |
|
|
|
@ -2114,8 +2161,7 @@ Size getTextSize( const String& text, int fontFace, double fontScale, int thickn |
|
|
|
|
int c = (uchar)text[i]; |
|
|
|
|
Point p; |
|
|
|
|
|
|
|
|
|
if( c >= 127 || c < ' ' ) |
|
|
|
|
c = '?'; |
|
|
|
|
readCheck(c, i, text, fontFace); |
|
|
|
|
|
|
|
|
|
const char* ptr = faces[ascii[(c-' ')+1]]; |
|
|
|
|
p.x = (uchar)ptr[0] - 'R'; |
|
|
|
|