Skip to content

Commit

Permalink
Add winansi glyph names
Browse files Browse the repository at this point in the history
for the PS backend and Type 1 subsetters to use with latin fonts.
  • Loading branch information
Adrian Johnson committed Oct 1, 2010
1 parent e62891c commit 01ee091
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/cairo-scaled-font-subsets-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t *truetype_subset,
cairo_private void
_cairo_truetype_subset_fini (cairo_truetype_subset_t *truetype_subset);


cairo_private const char *
_cairo_winansi_to_glyphname (int glyph);

typedef struct _cairo_type1_subset {
char *base_font;
Expand Down
7 changes: 6 additions & 1 deletion src/cairo-scaled-font-subsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,12 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
}

if (utf16_len == 1) {
snprintf (buf, sizeof (buf), "uni%04X", (int) utf16[0]);
int ch = _unicode_to_winansi (utf16[0]);
if (ch > 0)
strncpy (buf, _cairo_winansi_to_glyphname (ch), sizeof (buf));
else
snprintf (buf, sizeof (buf), "uni%04X", (int) utf16[0]);

_cairo_string_init_key (&key, buf);
entry = _cairo_hash_table_lookup (names, &key.base);
if (entry != NULL)
Expand Down
92 changes: 92 additions & 0 deletions src/cairo-type1-subset.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,98 @@ static const int16_t ps_standard_encoding_offset[256] = {

#define ps_standard_encoding(index) ((index) ? ps_standard_encoding_symbol+ps_standard_encoding_offset[(index)] : NULL)

/* TODO: Merge these names into ps_standard_encoding_symbol (with a
* separate winansi_encoding_offset table) as most of the names are
* the same. */
static const char *winansi_encoding[256] = {
/* 0 */
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
/* 16 */
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
/* 32 */
"space", "exclam", "quotedbl", "numbersign",
"dollar", "percent", "ampersand", "quoteright",
"parenleft", "parenright", "asterisk", "plus",
"comma", "hyphen", "period", "slash",
/* 48 */
"zero", "one", "two", "three",
"four", "five", "six", "seven",
"eight", "nine", "colon", "semicolon",
"less", "equal", "greater", "question",
/* 64 */
"at", "A", "B", "C",
"D", "E", "F", "G",
"H", "I", "J", "K",
"L", "M", "N", "O",
/* 80 */
"P", "Q", "R", "S",
"T", "U", "V", "W",
"X", "Y", "Z", "bracketleft",
"backslash", "bracketright", "asciicircum", "underscore",
/* 96 */
"quoteleft", "a", "b", "c",
"d", "e", "f", "g",
"h", "i", "j", "k",
"l", "m", "n", "o",
/* 112 */
"p", "q", "r", "s",
"t", "u", "v", "w",
"x", "y", "z", "braceleft",
"bar", "braceright", "asciitilde", NULL,
/* 128 */
"Euro", NULL, "quotesinglbase","florin",
"quotedblbase", "ellipsis", "dagger", "daggerdbl",
"circumflex", "perthousand", "Scaron", "guilsinglleft",
"OE", "bullet", "Zcaron", NULL,
/* 144 */
NULL, "quoteleft", "quoteright", "quotedblleft",
"quotedblright","bullet", "endash", "emdash",
"tilde", "trademark", "scaron", "guilsinglright",
"oe", "bullet", "zcaron", "Ydieresis",
/* 160 */
"space", "exclamdown", "cent", "sterling",
"currency", "yen", "brokenbar", "section",
"dieresis", "copyright", "ordfeminine", "guillemotleft",
"logicalnot", "hyphen", "registered", "macron",
/* 176 */
"degree", "plusminus", "twosuperior", "threesuperior",
"acute", "mu", "paragraph", "periodcentered",
"cedilla", "onesuperior", "ordmasculine", "guillemotright",
"onequarter", "onehalf", "threequarters","questiondown",
/* 192 */
"Agrave", "Aacute", "Acircumflex", "Atilde",
"Adieresis", "Aring", "AE", "Ccedilla",
"Egrave", "Eacute", "Ecircumflex", "Edieresis",
"Igrave", "Iacute", "Icircumflex", "Idieresis",
/* 208 */
"Eth", "Ntilde", "Ograve", "Oacute",
"Ocircumflex", "Otilde", "Odieresis", "multiply",
"Oslash", "Ugrave", "Uacute", "Ucircumflex",
"Udieresis", "Yacute", "Thorn", "germandbls",
/* 224 */
"agrave", "aacute", "acircumflex", "atilde",
"adieresis", "aring", "ae", "ccedilla",
"egrave", "eacute", "ecircumflex", "edieresis",
"igrave", "iacute", "icircumflex", "idieresis",
/* 240 */
"eth", "ntilde", "ograve", "oacute",
"ocircumflex", "otilde", "odieresis", "divide",
"oslash", "ugrave", "uacute", "ucircumflex",
"udieresis", "yacute", "thorn", "ydieresis"
};

const char *
_cairo_winansi_to_glyphname (int glyph)
{
return winansi_encoding[glyph];
}

static cairo_status_t
use_standard_encoding_glyph (cairo_type1_font_subset_t *font, int index)
{
Expand Down

0 comments on commit 01ee091

Please sign in to comment.