Lines 490-499
Link Here
|
490 |
GfxFontType fontType; |
490 |
GfxFontType fontType; |
491 |
SplashOutFontFileID *id; |
491 |
SplashOutFontFileID *id; |
492 |
SplashFontFile *fontFile; |
492 |
SplashFontFile *fontFile; |
|
|
493 |
SplashFontSrc *fontsrc; |
493 |
FoFiTrueType *ff; |
494 |
FoFiTrueType *ff; |
494 |
Ref embRef; |
495 |
Ref embRef; |
495 |
Object refObj, strObj; |
496 |
Object refObj, strObj; |
496 |
GString *tmpFileName, *fileName, *substName; |
497 |
GString *fileName, *substName; |
|
|
498 |
char *tmpBuf; |
499 |
int tmpBufLen; |
497 |
FILE *tmpFile; |
500 |
FILE *tmpFile; |
498 |
Gushort *codeToGID; |
501 |
Gushort *codeToGID; |
499 |
DisplayFontParam *dfp; |
502 |
DisplayFontParam *dfp; |
Lines 505-511
Link Here
|
505 |
|
508 |
|
506 |
needFontUpdate = gFalse; |
509 |
needFontUpdate = gFalse; |
507 |
font = NULL; |
510 |
font = NULL; |
508 |
tmpFileName = NULL; |
511 |
fileName = NULL; |
|
|
512 |
tmpBuf = NULL; |
509 |
substIdx = -1; |
513 |
substIdx = -1; |
510 |
|
514 |
|
511 |
if (!(gfxFont = state->getFont())) { |
515 |
if (!(gfxFont = state->getFont())) { |
Lines 525-546
Link Here
|
525 |
|
529 |
|
526 |
// if there is an embedded font, write it to disk |
530 |
// if there is an embedded font, write it to disk |
527 |
if (gfxFont->getEmbeddedFontID(&embRef)) { |
531 |
if (gfxFont->getEmbeddedFontID(&embRef)) { |
528 |
if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) { |
532 |
tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen); |
529 |
error(-1, "Couldn't create temporary font file"); |
533 |
if (! tmpBuf) |
530 |
goto err2; |
534 |
goto err2; |
531 |
} |
|
|
532 |
refObj.initRef(embRef.num, embRef.gen); |
533 |
refObj.fetch(xref, &strObj); |
534 |
refObj.free(); |
535 |
strObj.streamReset(); |
536 |
while ((c = strObj.streamGetChar()) != EOF) { |
537 |
fputc(c, tmpFile); |
538 |
} |
539 |
strObj.streamClose(); |
540 |
strObj.free(); |
541 |
fclose(tmpFile); |
542 |
fileName = tmpFileName; |
543 |
|
544 |
// if there is an external font file, use it |
535 |
// if there is an external font file, use it |
545 |
} else if (!(fileName = gfxFont->getExtFontFile())) { |
536 |
} else if (!(fileName = gfxFont->getExtFontFile())) { |
546 |
|
537 |
|
Lines 596-609
Link Here
|
596 |
} |
587 |
} |
597 |
} |
588 |
} |
598 |
|
589 |
|
|
|
590 |
fontsrc = new SplashFontSrc; |
591 |
if (fileName) |
592 |
fontsrc->setFile(fileName, gFalse); |
593 |
else |
594 |
fontsrc->setBuf(tmpBuf, tmpBufLen, gFalse); |
595 |
|
599 |
// load the font file |
596 |
// load the font file |
600 |
switch (fontType) { |
597 |
switch (fontType) { |
601 |
case fontType1: |
598 |
case fontType1: |
602 |
if (!(fontFile = fontEngine->loadType1Font( |
599 |
fontFile = fontEngine->loadType1Font(id, fontsrc, |
603 |
id, |
600 |
((Gfx8BitFont *)gfxFont)->getEncoding()); |
604 |
fileName->getCString(), |
601 |
if (! fontFile) { |
605 |
fileName == tmpFileName, |
|
|
606 |
((Gfx8BitFont *)gfxFont)->getEncoding()))) { |
607 |
error(-1, "Couldn't create a font for '%s'", |
602 |
error(-1, "Couldn't create a font for '%s'", |
608 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
603 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
609 |
: "(unnamed)"); |
604 |
: "(unnamed)"); |
Lines 611-621
Link Here
|
611 |
} |
606 |
} |
612 |
break; |
607 |
break; |
613 |
case fontType1C: |
608 |
case fontType1C: |
614 |
if (!(fontFile = fontEngine->loadType1CFont( |
609 |
fontFile = fontEngine->loadType1CFont(id, fontsrc, |
615 |
id, |
610 |
((Gfx8BitFont *)gfxFont)->getEncoding()); |
616 |
fileName->getCString(), |
611 |
if (! fontFile) { |
617 |
fileName == tmpFileName, |
|
|
618 |
((Gfx8BitFont *)gfxFont)->getEncoding()))) { |
619 |
error(-1, "Couldn't create a font for '%s'", |
612 |
error(-1, "Couldn't create a font for '%s'", |
620 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
613 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
621 |
: "(unnamed)"); |
614 |
: "(unnamed)"); |
Lines 623-638
Link Here
|
623 |
} |
616 |
} |
624 |
break; |
617 |
break; |
625 |
case fontTrueType: |
618 |
case fontTrueType: |
626 |
if (!(ff = FoFiTrueType::load(fileName->getCString()))) { |
619 |
if (fileName) |
|
|
620 |
ff = FoFiTrueType::load(fileName->getCString()); |
621 |
else |
622 |
ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse); |
623 |
if (! ff) |
627 |
goto err2; |
624 |
goto err2; |
628 |
} |
|
|
629 |
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); |
625 |
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); |
630 |
delete ff; |
626 |
delete ff; |
631 |
if (!(fontFile = fontEngine->loadTrueTypeFont( |
627 |
fontFile = fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, 256); |
632 |
id, |
628 |
if (! fontFile) { |
633 |
fileName->getCString(), |
|
|
634 |
fileName == tmpFileName, |
635 |
codeToGID, 256))) { |
636 |
error(-1, "Couldn't create a font for '%s'", |
629 |
error(-1, "Couldn't create a font for '%s'", |
637 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
630 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
638 |
: "(unnamed)"); |
631 |
: "(unnamed)"); |
Lines 641-650
Link Here
|
641 |
break; |
634 |
break; |
642 |
case fontCIDType0: |
635 |
case fontCIDType0: |
643 |
case fontCIDType0C: |
636 |
case fontCIDType0C: |
644 |
if (!(fontFile = fontEngine->loadCIDFont( |
637 |
fontFile = fontEngine->loadCIDFont(id, fontsrc); |
645 |
id, |
638 |
if (! fontFile) { |
646 |
fileName->getCString(), |
|
|
647 |
fileName == tmpFileName))) { |
648 |
error(-1, "Couldn't create a font for '%s'", |
639 |
error(-1, "Couldn't create a font for '%s'", |
649 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
640 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
650 |
: "(unnamed)"); |
641 |
: "(unnamed)"); |
Lines 658-675
Link Here
|
658 |
memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), |
649 |
memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), |
659 |
n * sizeof(Gushort)); |
650 |
n * sizeof(Gushort)); |
660 |
} else { |
651 |
} else { |
661 |
if (!(ff = FoFiTrueType::load(fileName->getCString()))) { |
652 |
if (fileName) |
662 |
fprintf(stderr, "failture loading cid2 %s\n", fileName->getCString()); |
653 |
ff = FoFiTrueType::load(fileName->getCString()); |
663 |
goto err2; |
654 |
else |
664 |
} |
655 |
ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse); |
665 |
codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); |
656 |
if (! ff) |
666 |
delete ff; |
657 |
goto err2; |
667 |
} |
658 |
codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); |
668 |
if (!(fontFile = fontEngine->loadTrueTypeFont( |
659 |
delete ff; |
669 |
id, |
660 |
} |
670 |
fileName->getCString(), |
661 |
fontFile = fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, n, faceIndex); |
671 |
fileName == tmpFileName, |
662 |
if (! fontFile) { |
672 |
codeToGID, n, faceIndex))) { |
|
|
673 |
error(-1, "Couldn't create a font for '%s'", |
663 |
error(-1, "Couldn't create a font for '%s'", |
674 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
664 |
gfxFont->getName() ? gfxFont->getName()->getCString() |
675 |
: "(unnamed)"); |
665 |
: "(unnamed)"); |
Lines 717-733
Link Here
|
717 |
mat[2] = m21; mat[3] = -m22; |
707 |
mat[2] = m21; mat[3] = -m22; |
718 |
font = fontEngine->getFont(fontFile, mat); |
708 |
font = fontEngine->getFont(fontFile, mat); |
719 |
|
709 |
|
720 |
if (tmpFileName) { |
|
|
721 |
delete tmpFileName; |
722 |
} |
723 |
return; |
710 |
return; |
724 |
|
711 |
|
725 |
err2: |
712 |
err2: |
726 |
delete id; |
713 |
delete id; |
727 |
err1: |
714 |
err1: |
728 |
if (tmpFileName) { |
|
|
729 |
delete tmpFileName; |
730 |
} |
731 |
return; |
715 |
return; |
732 |
} |
716 |
} |
733 |
|
717 |
|
Lines 1345-1352
Link Here
|
1345 |
if (dfp->kind != displayFontT1) { |
1329 |
if (dfp->kind != displayFontT1) { |
1346 |
return NULL; |
1330 |
return NULL; |
1347 |
} |
1331 |
} |
1348 |
fontFile = fontEngine->loadType1Font(id, dfp->t1.fileName->getCString(), |
1332 |
SplashFontSrc *fontsrc = new SplashFontSrc; |
1349 |
gFalse, winAnsiEncoding); |
1333 |
fontsrc->setFile(dfp->t1.fileName, gFalse); |
|
|
1334 |
fontFile = fontEngine->loadType1Font(id, fontsrc, winAnsiEncoding); |
1350 |
} |
1335 |
} |
1351 |
|
1336 |
|
1352 |
// create the scaled font |
1337 |
// create the scaled font |