[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1551-g3ed82a4
[email protected] (Chris Liddell)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via 3ed82a40fd4b49728c79955319b6d67d1e092006 (commit)
via 1eb609f130c397144702097f4d987f3b956770f9 (commit)
from 788958decad94b7b3f7a478cfb57724323041bf5 (commit)
----------------------------------------------------------------------
commit 3ed82a40fd4b49728c79955319b6d67d1e092006
Author: Chris Liddell <[email protected]>
Date: Wed Jul 31 13:34:06 2019 +0100
Add a way to record the selected cmap
(for the pdfi branch)
diff --git a/base/fapi_ft.c b/base/fapi_ft.c
index c9fe9ff..60f69f6 100644
--- a/base/fapi_ft.c
+++ b/base/fapi_ft.c
@@ -1384,6 +1384,21 @@ gs_fapi_ft_get_scaled_font(gs_fapi_server * a_server, gs_fapi_font * a_font,
*/
(void)FT_Select_Charmap(face->ft_face, ft_encoding_unicode);
}
+ /* For PDF, we have to know which cmap table actually was selected */
+ if (face->ft_face->charmap != NULL) {
+ a_font->ttf_cmap_selected.platform_id = face->ft_face->charmap->platform_id;
+ a_font->ttf_cmap_selected.encoding_id = face->ft_face->charmap->encoding_id;
+ }
+ else {
+ /* Just in case */
+ a_font->ttf_cmap_selected.platform_id = -1;
+ a_font->ttf_cmap_selected.encoding_id = -1;
+ }
+ }
+ else {
+ /* Just in case */
+ a_font->ttf_cmap_selected.platform_id = -1;
+ a_font->ttf_cmap_selected.encoding_id = -1;
}
}
diff --git a/base/gxfapi.h b/base/gxfapi.h
index 9205282..687cd3e 100644
--- a/base/gxfapi.h
+++ b/base/gxfapi.h
@@ -172,6 +172,7 @@ struct gs_fapi_font_s
bool is_vertical;
bool metrics_only; /* can save the expense of loading entire glyph */
gs_fapi_ttf_cmap_request ttf_cmap_req[GS_FAPI_NUM_TTF_CMAP_REQ]; /* Lets client request a specific cmap to be set. Also, a couple of fallbacks */
+ gs_fapi_ttf_cmap_request ttf_cmap_selected; /* If the request contains multiple cmaps, this records which was actually selected */
void *client_ctx_p;
void *client_font_data;
void *client_font_data2;
diff --git a/pcl/pl/plfapi.c b/pcl/pl/plfapi.c
index bd62edb..dc1cf99 100644
--- a/pcl/pl/plfapi.c
+++ b/pcl/pl/plfapi.c
@@ -105,6 +105,7 @@ static const gs_fapi_font pl_ff_stub = {
false, /* is_vertical */
false, /* metrics_only */
{{3, 10}, {3, 1}, {-1, -1}, {-1, -1}, {-1, -1}}, /* ttf_cmap_req */
+ {-1 , -1}, /* ttf_cmap_selected */
0, /* client_ctx_p */
0, /* client_font_data */
0, /* client_font_data2 */
diff --git a/psi/zfapi.c b/psi/zfapi.c
index 1001b11..63dfa94 100644
--- a/psi/zfapi.c
+++ b/psi/zfapi.c
@@ -1802,6 +1802,7 @@ static const gs_fapi_font ps_ff_stub = {
false, /* is_vertical */
false, /* metrics_only */
{{-1, -1}}, /* ttf_cmap_req */
+ {-1, -1}, /* ttf_cmap_selected */
0, /* client_ctx_p */
0, /* client_font_data */
0, /* client_font_data2 */
diff --git a/xps/xpsfapi.c b/xps/xpsfapi.c
index 60f383a..80068ef 100644
--- a/xps/xpsfapi.c
+++ b/xps/xpsfapi.c
@@ -67,6 +67,7 @@ static const gs_fapi_font pl_ff_stub = {
{3,10}, {3,1},{3,5},{3,4},\
{3,3},{3,2},{3,0},{1,0},
{-1,-1}}, /* ttf_cmap_req */
+ {-1, -1}, /* ttf_cmap_selected */
0, /* client_ctx_p */
0, /* client_font_data */
0, /* client_font_data2 */
----------------------------------------------------------------------
commit 1eb609f130c397144702097f4d987f3b956770f9
Author: Chris Liddell <[email protected]>
Date: Thu Aug 1 08:55:31 2019 +0100
Add 'post' table name lookup to TTF in graphics lib
Make Mac Roman glyph ordering available to 'clients'
(in support of the pdfi branch)
diff --git a/base/gstype42.c b/base/gstype42.c
index 0764766..49052a5 100644
--- a/base/gstype42.c
+++ b/base/gstype42.c
@@ -206,6 +206,9 @@ gs_type42_font_init(gs_font_type42 * pfont, int subfontID)
if (!memcmp(tab, "cmap", 4))
pfont->data.cmap = offset;
+ else if (!memcmp(tab, "post", 4)) {
+ pfont->data.post_offset = offset;
+ }
else if (!memcmp(tab, "glyf", 4)) {
pfont->data.glyf = offset;
glyph_size = (uint)u32(tab + 12);
@@ -469,6 +472,342 @@ gs_gsub_release(void *data, void *event)
/* ---------------- Glyph level ---------------- */
+mac_glyph_ordering_t MacintoshOrdering[] =
+{
+ {0, ".notdef"},
+ {1, ".null"},
+ {2, "nonmarkingreturn"},
+ {3, "space"},
+ {4, "exclam"},
+ {5, "quotedbl"},
+ {6, "numbersign"},
+ {7, "dollar"},
+ {8, "percent"},
+ {9, "ampersand"},
+ {10, "quotesingle"},
+ {11, "parenleft"},
+ {12, "parenright"},
+ {13, "asterisk"},
+ {14, "plus"},
+ {15, "comma"},
+ {16, "hyphen"},
+ {17, "period"},
+ {18, "slash"},
+ {19, "zero"},
+ {20, "one"},
+ {21, "two"},
+ {22, "three"},
+ {23, "four"},
+ {24, "five"},
+ {25, "six"},
+ {26, "seven"},
+ {27, "eight"},
+ {28, "nine"},
+ {29, "colon"},
+ {30, "semicolon"},
+ {31, "less"},
+ {32, "equal"},
+ {33, "greater"},
+ {34, "question"},
+ {35, "at"},
+ {36, "A"},
+ {37, "B"},
+ {38, "C"},
+ {39, "D"},
+ {40, "E"},
+ {41, "F"},
+ {42, "G"},
+ {43, "H"},
+ {44, "I"},
+ {45, "J"},
+ {46, "K"},
+ {47, "L"},
+ {48, "M"},
+ {49, "N"},
+ {50, "O"},
+ {51, "P"},
+ {52, "Q"},
+ {53, "R"},
+ {54, "S"},
+ {55, "T"},
+ {56, "U"},
+ {57, "V"},
+ {58, "W"},
+ {59, "X"},
+ {60, "Y"},
+ {61, "Z"},
+ {62, "bracketleft"},
+ {63, "backslash"},
+ {64, "bracketright"},
+ {65, "asciicircum"},
+ {66, "underscore"},
+ {67, "grave"},
+ {68, "a"},
+ {69, "b"},
+ {70, "c"},
+ {71, "d"},
+ {72, "e"},
+ {73, "f"},
+ {74, "g"},
+ {75, "h"},
+ {76, "i"},
+ {77, "j"},
+ {78, "k"},
+ {79, "l"},
+ {80, "m"},
+ {81, "n"},
+ {82, "o"},
+ {83, "p"},
+ {84, "q"},
+ {85, "r"},
+ {86, "s"},
+ {87, "t"},
+ {88, "u"},
+ {89, "v"},
+ {90, "w"},
+ {91, "x"},
+ {92, "y"},
+ {93, "z"},
+ {94, "braceleft"},
+ {95, "bar"},
+ {96, "braceright"},
+ {97, "asciitilde"},
+ {98, "Adieresis"},
+ {99, "Aring"},
+ {100, "Ccedilla"},
+ {101, "Eacute"},
+ {102, "Ntilde"},
+ {103, "Odieresis"},
+ {104, "Udieresis"},
+ {105, "aacute"},
+ {106, "agrave"},
+ {107, "acircumflex"},
+ {108, "adieresis"},
+ {109, "atilde"},
+ {110, "aring"},
+ {111, "ccedilla"},
+ {112, "eacute"},
+ {113, "egrave"},
+ {114, "ecircumflex"},
+ {115, "edieresis"},
+ {116, "iacute"},
+ {117, "igrave"},
+ {118, "icircumflex"},
+ {119, "idieresis"},
+ {120, "ntilde"},
+ {121, "oacute"},
+ {122, "ograve"},
+ {123, "ocircumflex"},
+ {124, "odieresis"},
+ {125, "otilde"},
+ {126, "uacute"},
+ {127, "ugrave"},
+ {128, "ucircumflex"},
+ {129, "udieresis"},
+ {130, "dagger"},
+ {131, "degree"},
+ {132, "cent"},
+ {133, "sterling"},
+ {134, "section"},
+ {135, "bullet"},
+ {136, "paragraph"},
+ {137, "germandbls"},
+ {138, "registered"},
+ {139, "copyright"},
+ {140, "trademark"},
+ {141, "acute"},
+ {142, "dieresis"},
+ {143, "notequal"},
+ {144, "AE"},
+ {145, "Oslash"},
+ {146, "infinity"},
+ {147, "plusminus"},
+ {148, "lessequal"},
+ {149, "greaterequal"},
+ {150, "yen"},
+ {151, "mu"},
+ {152, "partialdiff"},
+ {153, "summation"},
+ {154, "product"},
+ {155, "pi"},
+ {156, "integral"},
+ {157, "ordfeminine"},
+ {158, "ordmasculine"},
+ {159, "Omega"},
+ {160, "ae"},
+ {161, "oslash"},
+ {162, "questiondown"},
+ {163, "exclamdown"},
+ {164, "logicalnot"},
+ {165, "radical"},
+ {166, "florin"},
+ {167, "approxequal"},
+ {168, "Delta"},
+ {169, "guillemotleft"},
+ {170, "guillemotright"},
+ {171, "ellipsis"},
+ {172, "nonbreakingspace"},
+ {173, "Agrave"},
+ {174, "Atilde"},
+ {175, "Otilde"},
+ {176, "OE"},
+ {177, "oe"},
+ {178, "endash"},
+ {179, "emdash"},
+ {180, "quotedblleft"},
+ {181, "quotedblright"},
+ {182, "quoteleft"},
+ {183, "quoteright"},
+ {184, "divide"},
+ {185, "lozenge"},
+ {186, "ydieresis"},
+ {187, "Ydieresis"},
+ {188, "fraction"},
+ {189, "currency"},
+ {190, "guilsinglleft"},
+ {191, "guilsinglright"},
+ {192, "fi"},
+ {193, "fl"},
+ {194, "daggerdbl"},
+ {195, "periodcentered"},
+ {196, "quotesinglbase"},
+ {197, "quotedblbase"},
+ {198, "perthousand"},
+ {199, "Acircumflex"},
+ {200, "Ecircumflex"},
+ {201, "Aacute"},
+ {202, "Edieresis"},
+ {203, "Egrave"},
+ {204, "Iacute"},
+ {205, "Icircumflex"},
+ {206, "Idieresis"},
+ {207, "Igrave"},
+ {208, "Oacute"},
+ {209, "Ocircumflex"},
+ {210, "apple"},
+ {211, "Ograve"},
+ {212, "Uacute"},
+ {213, "Ucircumflex"},
+ {214, "Ugrave"},
+ {215, "dotlessi"},
+ {216, "circumflex"},
+ {217, "tilde"},
+ {218, "macron"},
+ {219, "breve"},
+ {220, "dotaccent"},
+ {221, "ring"},
+ {222, "cedilla"},
+ {223, "hungarumlaut"},
+ {224, "ogonek"},
+ {225, "caron"},
+ {226, "Lslash"},
+ {227, "lslash"},
+ {228, "Scaron"},
+ {229, "scaron"},
+ {230, "Zcaron"},
+ {231, "zcaron"},
+ {232, "brokenbar"},
+ {233, "Eth"},
+ {234, "eth"},
+ {235, "Yacute"},
+ {236, "yacute"},
+ {237, "Thorn"},
+ {238, "thorn"},
+ {239, "minus"},
+ {240, "multiply"},
+ {241, "onesuperior"},
+ {242, "twosuperior"},
+ {243, "threesuperior"},
+ {244, "onehalf"},
+ {245, "onequarter"},
+ {246, "threequarters"},
+ {247, "franc"},
+ {248, "Gbreve"},
+ {249, "gbreve"},
+ {250, "Idotaccent"},
+ {251, "Scedilla"},
+ {252, "scedilla"},
+ {253, "Cacute"},
+ {254, "cacute"},
+ {255, "Ccaron"},
+ {256, "ccaron"},
+ {257, "dcroat"},
+ {-1, NULL}
+};
+
+/* Use the post table to find a glyph name */
+int
+gs_type42_find_post_name(gs_font_type42 * pfont, gs_glyph glyph, gs_string *gname)
+{
+ int code = 0;
+ if (pfont->FontType == ft_TrueType) {
+ if (pfont->data.post_offset != 0) {
+ byte ver[4];
+ byte const ver10[4] = {0x00, 0x01, 0x00, 0x00};
+ byte const ver20[4] = {0x00, 0x02, 0x00, 0x00};
+
+ READ_SFNTS(pfont, pfont->data.post_offset, 4, ver);
+ if (!memcmp(ver, ver10, 4)){
+ if (glyph > 257) glyph = 0;
+ gname->data = (byte *)MacintoshOrdering[glyph].name;
+ gname->size = strlen(MacintoshOrdering[glyph].name);
+ }
+ else if (!memcmp(ver, ver20, 4)) {
+ byte val[2];
+ unsigned short gind;
+ READ_SFNTS(pfont, pfont->data.post_offset + 34 + glyph * 2, 2, val);
+ gind = U16(val);
+ if (gind < 258) {
+ gname->data = (byte *)MacintoshOrdering[gind].name;
+ gname->size = strlen(MacintoshOrdering[gind].name);
+ }
+ else {
+ int i;
+ byte val[2];
+ short numglyphs;
+ uint offs;
+
+ READ_SFNTS(pfont, pfont->data.post_offset + 32, 2, val);
+ numglyphs = U16(val);
+ gind -= 258;
+ if (gind < numglyphs) {
+ offs = pfont->data.post_offset + 34 + numglyphs * 2;
+ for (i = 0; i < numglyphs; i++) {
+ byte len;
+ if (i == gind) {
+ READ_SFNTS(pfont, offs, 1, &len);
+ code = pfont->data.string_proc(pfont, offs + 1, len, (const byte **)&(gname->data));
+ if (code > 0)
+ gname->size = len;
+ break;
+ }
+ else {
+ READ_SFNTS(pfont, offs, 1, &len);
+ offs += len + 1;
+ }
+ }
+ }
+ else {
+ gname->data = (byte *)MacintoshOrdering[0].name;
+ gname->size = strlen(MacintoshOrdering[0].name);
+ }
+ }
+ }
+ else {
+ gname->data = (byte *)MacintoshOrdering[0].name;
+ gname->size = strlen(MacintoshOrdering[0].name);
+ }
+ }
+ else {
+ gname->data = (byte *)MacintoshOrdering[0].name;
+ gname->size = strlen(MacintoshOrdering[0].name);
+ }
+ }
+ else
+ code = gs_note_error(gs_error_invalidfont);
+ return code;
+}
+
/*
* Parse the definition of one component of a composite glyph. We don't
* bother to parse the component index, since the caller can do this so
diff --git a/base/gxfont42.h b/base/gxfont42.h
index 82608c7..a7cf09d 100644
--- a/base/gxfont42.h
+++ b/base/gxfont42.h
@@ -24,6 +24,12 @@
#include "gxmatrix.h"
#include "gxfcache.h"
+typedef struct
+{
+ const int ccode;
+ const char * const name;
+} mac_glyph_ordering_t;
+
/* This is the type-specific information for a Type 42 (TrueType) font. */
typedef struct gs_type42_data_s gs_type42_data;
@@ -77,6 +83,7 @@ struct gs_type42_data_s {
ulong loca; /* offset to loca table */
ulong name_offset; /* offset to name table */
ulong os2_offset; /* offset to OS/2 table */
+ ulong post_offset; /* Offset to the post table */
/*
* TrueType fonts specify the number of glyphs in two different ways:
* the size of the loca table, and an explicit value in maxp. Currently
@@ -129,6 +136,9 @@ int gs_type42_font_init(gs_font_type42 *pfont, int subfontid);
/* Read data from sfnts. */
int gs_type42_read_data(gs_font_type42 * pfont, ulong pos, uint length, byte *buf);
+/* Use the name table to find a glyph name */
+int gs_type42_find_post_name(gs_font_type42 * pfont, gs_glyph glyph, gs_string *gname);
+
/* Read data from sfnts. */
/* A temporary macro for simplifying the old code change. */
#define READ_SFNTS(pfont, pos, length, buf)\
Summary of changes:
base/fapi_ft.c | 15 +++
base/gstype42.c | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
base/gxfapi.h | 1 +
base/gxfont42.h | 10 ++
pcl/pl/plfapi.c | 1 +
psi/zfapi.c | 1 +
xps/xpsfapi.c | 1 +
7 files changed, 368 insertions(+)