[gs-devel] Questions on text extraction
James Burton
james_evy at hotmail.com
Tue Oct 11 13:33:51 PDT 2005
Hello,
I'm working on a custom device that will produce a ping file, plus the
extracted text. After using the debugger to track what was happening in the
pdfwrite driver, I actually got it to work, but I have to following
questions:
1) In the text_begin() function, is this the correct way to get the Unicode?
Is there anything missing? The documentation doc/Drivers.htm in the
paragraph "Unicode support for high level devices" mentions using the
"current subfont". But I don't create a "a new instance of gs_text_enum_t"
because I just grab the text and fall throught to the default text_begin
function to do the real work. Is something going to break?
MyDevice_text_begin(gx_device * dev, gs_imager_state * pis,
const gs_text_params_t * text, gs_font * font,
gx_path * path, const gx_device_color * pdcolor,
const gx_clip_path * pcpath,
gs_memory_t * memory, gs_text_enum_t ** ppenum)
{
...
for ( i=0; i<text->size; i++ )
{
gs_char unicode;
gs_glyph glyph;
glyph = (*font->procs.encode_char)(font, (gs_char)text->data.bytes[i],
GLYPH_SPACE_NAME);
if (glyph != GS_NO_GLYPH)
{
unicode = font->procs.decode_glyph(font, glyph);
if (unicode==GS_NO_CHAR)
myText[i]=text->data.bytes[i];
else
myText[i]=unicode&0xFF;
} else
myText[i]=text->data.bytes[i];
...
}
code = gx_default_text_begin(dev, pis, text, font, path, pdcolor,
pcpath, memory, ppenum);
done:
return code;
}
2) Coupled with this, where changes in the lib/gs_pdfwr.ps file. Basically,
everthere there was a test to see if the device was "pdfwrite", I had to
also put a test to see if the device was "MyDevice". For example:
This:
currentdevice .devicename /pdfwrite eq {
Was changed to this:
currentdevice .devicename /pdfwrite eq
currentdevice .devicename /MyDevice eq or {
Also, this:
currentdevice .devicename /pdfwrite ne {
Was changed to this:
currentdevice .devicename /pdfwrite ne
currentdevice .devicename /MyDevice ne and {
I couldn't figure out how to create my own postscript file that would be
included. In fact, I tried my best, but couldn't find any source or
postscript calling gs_pdfwr.ps in the source. I knew it was being called,
because if I renamed it, ghostscript would error. What is the proceedure
for adding a device specific postscript file?
James Burton
_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee®
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
More information about the gs-devel
mailing list