mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 20:59:36 +08:00
Merge pull request #3195 from stweil/pdf
Add const attribute for pdf_ttf
This commit is contained in:
commit
7f354ecca5
@ -20,9 +20,9 @@
|
||||
#ifndef pdf_ttf__H
|
||||
#define pdf_ttf__H
|
||||
|
||||
unsigned long pdf_ttf_length = 0x23c;
|
||||
#include <cstdint> // uint8_t
|
||||
|
||||
unsigned char pdf_ttf[] = {
|
||||
static const uint8_t pdf_ttf[] = {
|
||||
0x0, 0x1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x80, 0x0, 0x3, 0x0, 0x20,
|
||||
0x4f, 0x53, 0x2f, 0x32, 0x56, 0xde, 0xc8, 0x94, 0x0, 0x0, 0x1, 0x28,
|
||||
0x0, 0x0, 0x0, 0x60, 0x63, 0x6d, 0x61, 0x70, 0x0, 0xa, 0x0, 0x34,
|
||||
|
@ -20,17 +20,18 @@
|
||||
#include "config_auto.h"
|
||||
#endif
|
||||
|
||||
#include "pdf_ttf.h"
|
||||
#include "tprintf.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <fstream> // for std::ifstream
|
||||
#include <locale> // for std::locale::classic
|
||||
#include <memory> // std::unique_ptr
|
||||
#include <sstream> // for std::stringstream
|
||||
#include <fstream> // for std::ifstream
|
||||
#include "allheaders.h"
|
||||
#include <allheaders.h>
|
||||
#include <tesseract/baseapi.h>
|
||||
#include <cmath>
|
||||
#include <tesseract/renderer.h>
|
||||
#include <cstring>
|
||||
#include "tprintf.h"
|
||||
#include "pdf_ttf.h"
|
||||
|
||||
/*
|
||||
|
||||
@ -625,19 +626,19 @@ bool TessPDFRenderer::BeginDocumentHandler() {
|
||||
|
||||
stream.str("");
|
||||
stream << datadir_.c_str() << "/pdf.ttf";
|
||||
const char* font;
|
||||
const uint8_t* font;
|
||||
std::ifstream input(stream.str().c_str(), std::ios::in | std::ios::binary);
|
||||
std::vector<unsigned char> buffer(std::istreambuf_iterator<char>(input), {});
|
||||
auto size = buffer.size();
|
||||
if (size) {
|
||||
font = reinterpret_cast<char*>(buffer.data());
|
||||
font = buffer.data();
|
||||
} else {
|
||||
#if defined(DEBUG)
|
||||
tprintf("Cannot open file \"%s\"!\nUsing internal glyphless font.\n",
|
||||
stream.str().c_str());
|
||||
#endif
|
||||
font = reinterpret_cast<char*>(pdf_ttf);
|
||||
size = pdf_ttf_length;
|
||||
font = pdf_ttf;
|
||||
size = sizeof(pdf_ttf);
|
||||
}
|
||||
|
||||
// FONTFILE2
|
||||
@ -651,7 +652,7 @@ bool TessPDFRenderer::BeginDocumentHandler() {
|
||||
"stream\n";
|
||||
AppendString(stream.str().c_str());
|
||||
objsize = stream.str().size();
|
||||
AppendData(font, size);
|
||||
AppendData(reinterpret_cast<const char*>(font), size);
|
||||
objsize += size;
|
||||
AppendString(endstream_endobj);
|
||||
objsize += strlen(endstream_endobj);
|
||||
|
Loading…
Reference in New Issue
Block a user