mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
Jeff's fixes to pdf rendering
This commit is contained in:
parent
13b7900ebf
commit
77015526fa
@ -159,7 +159,7 @@ CIDToGIDMap.
|
||||
|
||||
OK there is a small problem there, if I use GID 0 then Acrobat gets
|
||||
upset about it and complains it cannot extract the font. If I set the
|
||||
CIDToGIDMap so that all the entries are 1 instead, its happy. Totally
|
||||
CIDToGIDMap so that all the entries are 1 instead, it's happy. Totally
|
||||
mad......
|
||||
|
||||
*/
|
||||
@ -169,15 +169,15 @@ namespace tesseract {
|
||||
// Use for PDF object fragments. Must be large enough
|
||||
// to hold a colormap with 256 colors in the verbose
|
||||
// PDF representation.
|
||||
const int kBasicBufSize = 2048;
|
||||
static const int kBasicBufSize = 2048;
|
||||
|
||||
// If the font is 10 pts, nominal character width is 5 pts
|
||||
const int kCharWidth = 2;
|
||||
static const int kCharWidth = 2;
|
||||
|
||||
// Used for memory allocation. A codepoint must take no more than this
|
||||
// many bytes, when written in the PDF way. e.g. "<0063>" for the
|
||||
// letter 'c'
|
||||
const int kMaxBytesPerCodepoint = 20;
|
||||
static const int kMaxBytesPerCodepoint = 20;
|
||||
|
||||
/**********************************************************************
|
||||
* PDF Renderer interface implementation
|
||||
@ -309,18 +309,19 @@ void ClipBaseline(int ppi, int x1, int y1, int x2, int y2,
|
||||
*line_y1 = *line_y2 = (y1 + y2) / 2;
|
||||
}
|
||||
|
||||
bool CodepointToUtf16be(int code, char *utf16) {
|
||||
bool CodepointToUtf16be(int code, char utf16[kMaxBytesPerCodepoint]) {
|
||||
if ((code > 0xD7FF && code < 0xE000) || code > 0x10FFFF) {
|
||||
tprintf("Dropping invalid codepoint %d\n", code);
|
||||
return false;
|
||||
}
|
||||
if (code < 0x10000) {
|
||||
snprintf(utf16, sizeof(utf16), "%04X", code);
|
||||
snprintf(utf16, kMaxBytesPerCodepoint, "%04X", code);
|
||||
} else {
|
||||
int a = code - 0x010000;
|
||||
int high_surrogate = (0x03FF & (a >> 10)) + 0xD800;
|
||||
int low_surrogate = (0x03FF & a) + 0xDC00;
|
||||
snprintf(utf16, sizeof(utf16), "%04X%04X", high_surrogate, low_surrogate);
|
||||
snprintf(utf16, kMaxBytesPerCodepoint,
|
||||
"%04X%04X", high_surrogate, low_surrogate);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user