Save work.

This commit is contained in:
Michael R Sweet 2021-06-24 09:07:03 -04:00
parent a366697711
commit 90c7591190
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244
2 changed files with 18 additions and 8 deletions

View File

@ -1233,7 +1233,6 @@ pdfioFileCreateFontObjFromFile(
bool unicode) // I - Force Unicode bool unicode) // I - Force Unicode
{ {
ttf_t *font; // TrueType font ttf_t *font; // TrueType font
int ch; // Current character
ttf_rect_t bounds; // Font bounds ttf_rect_t bounds; // Font bounds
pdfio_dict_t *dict, // Font dictionary pdfio_dict_t *dict, // Font dictionary
*desc, // Font descriptor *desc, // Font descriptor
@ -1342,7 +1341,7 @@ pdfioFileCreateFontObjFromFile(
pdfioDictSetNumber(desc, "CapHeight", ttfGetCapHeight(font)); pdfioDictSetNumber(desc, "CapHeight", ttfGetCapHeight(font));
pdfioDictSetNumber(desc, "XHeight", ttfGetXHeight(font)); pdfioDictSetNumber(desc, "XHeight", ttfGetXHeight(font));
// Note: No TrueType value exists for this but PDF requires it, so we // Note: No TrueType value exists for this but PDF requires it, so we
// calculate a value from 50 to 250... // calculate a generic value from 50 to 250 based on the weight...
pdfioDictSetNumber(desc, "StemV", ttfGetWeight(font) / 4 + 25); pdfioDictSetNumber(desc, "StemV", ttfGetWeight(font) / 4 + 25);
if ((desc_obj = pdfioFileCreateObj(pdf, desc)) == NULL) if ((desc_obj = pdfioFileCreateObj(pdf, desc)) == NULL)
@ -1457,7 +1456,6 @@ pdfioFileCreateFontObjFromFile(
pdfioDictSetName(type2, "BaseFont", basefont); pdfioDictSetName(type2, "BaseFont", basefont);
pdfioDictSetDict(type2, "CIDSystemInfo", sidict); pdfioDictSetDict(type2, "CIDSystemInfo", sidict);
pdfioDictSetObj(type2, "CIDToGIDMap", cid2gid_obj); pdfioDictSetObj(type2, "CIDToGIDMap", cid2gid_obj);
// pdfioDictSetName(type2, "CIDToGIDMap", "Identity");
pdfioDictSetObj(type2, "FontDescriptor", desc_obj); pdfioDictSetObj(type2, "FontDescriptor", desc_obj);
if ((type2_obj = pdfioFileCreateObj(pdf, type2)) == NULL) if ((type2_obj = pdfioFileCreateObj(pdf, type2)) == NULL)
@ -1487,7 +1485,8 @@ pdfioFileCreateFontObjFromFile(
pdfioDictSetName(dict, "Subtype", "Type0"); pdfioDictSetName(dict, "Subtype", "Type0");
pdfioDictSetName(dict, "BaseFont", basefont); pdfioDictSetName(dict, "BaseFont", basefont);
pdfioDictSetArray(dict, "DescendantFonts", descendants); pdfioDictSetArray(dict, "DescendantFonts", descendants);
pdfioDictSetName(dict, "Encoding", "Identity-H"); // pdfioDictSetName(dict, "Encoding", "Identity-H");
pdfioDictSetName(dict, "Encoding", "UniCNS-UCS2-H");
if ((obj = pdfioFileCreateObj(pdf, dict)) == NULL) if ((obj = pdfioFileCreateObj(pdf, dict)) == NULL)
return (NULL); return (NULL);

View File

@ -1253,11 +1253,22 @@ write_font_test(pdfio_file_t *pdf, // I - PDF file
}; };
fputs("pdfioFileCreateFontObjFromFile(OpenSans-Regular.ttf): ", stdout); if (unicode)
if ((opensans = pdfioFileCreateFontObjFromFile(pdf, "testfiles/OpenSans-Regular.ttf", unicode)) != NULL) {
puts("PASS"); fputs("pdfioFileCreateFontObjFromFile(NotoSansJP-Regular.otf): ", stdout);
if ((opensans = pdfioFileCreateFontObjFromFile(pdf, "testfiles/NotoSansJP-Regular.otf", true)) != NULL)
puts("PASS");
else
return (1);
}
else else
return (1); {
fputs("pdfioFileCreateFontObjFromFile(OpenSans-Regular.ttf): ", stdout);
if ((opensans = pdfioFileCreateFontObjFromFile(pdf, "testfiles/OpenSans-Regular.ttf", false)) != NULL)
puts("PASS");
else
return (1);
}
fputs("pdfioDictCreate: ", stdout); fputs("pdfioDictCreate: ", stdout);
if ((dict = pdfioDictCreate(pdf)) != NULL) if ((dict = pdfioDictCreate(pdf)) != NULL)