MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / psl_prepare_text

Function psl_prepare_text

src/postscriptlight.c:1552–1705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1550}
1551
1552char *psl_prepare_text (struct PSL_CTRL *PSL, char *text) {
1553
1554/* Adds escapes for misc parenthesis, brackets etc.
1555 Will also translate to some European characters such as the @a, @e
1556 etc escape sequences. Calling function must REMEMBER to free memory
1557 allocated by string */
1558 const char *psl_scandcodes[16][5] = { /* Short-hand conversion for some European characters in both Undefined [0], Standard [1], Standard+ [2], ISOLatin1 [3], and ISOLatin1+ [4] encoding */
1559 { "AA", "AA" , "\\375", "\\305", "\\305"}, /* Aring */
1560 { "AE", "\\341", "\\341", "\\306", "\\306"}, /* AE */
1561 { "OE", "\\351", "\\351", "\\330", "\\330"}, /* Oslash */
1562 { "aa", "aa" , "\\376", "\\345", "\\345"}, /* aring */
1563 { "ae", "\\361", "\\361", "\\346", "\\346"}, /* ae */
1564 { "oe", "\\371", "\\371", "\\370", "\\370"}, /* oslash */
1565 { "C" , "C" , "\\201", "\\307", "\\307"}, /* Ccedilla */
1566 { "N" , "N" , "\\204", "\\321", "\\321"}, /* Ntilde */
1567 { "U" , "UE" , "\\335", "\\334", "\\334"}, /* Udieresis */
1568 { "c" , "c" , "\\215", "\\347", "\\347"}, /* ccedilla */
1569 { "n" , "n" , "\\227", "\\361", "\\361"}, /* ntilde */
1570 { "ss", "\\373", "\\373", "\\337", "\\337"}, /* germandbls */
1571 { "u" , "ue" , "\\370", "\\374", "\\374"}, /* udieresis */
1572 { "i" , "i" , "\\354", "\\355", "\\355"}, /* iaccute */
1573 { "@" , "\\100", "\\100", "\\100", "\\100"}, /* atsign */
1574 { "*" , "\\312", "\\217", "\\260", "\\260"} /* degree */
1575 };
1576 char *string = NULL;
1577 int i = 0, j = 0, font;
1578 int he = 0; /* PSL Historical Encoding (if any) */
1579
1580 if (!text) return NULL;
1581
1582 psl_encodefont (PSL, PSL->current.font_no);
1583
1584 if (strcmp ("Standard+", PSL->init.encoding) == 0)
1585 he = 2;
1586 else if (strcmp ("Standard", PSL->init.encoding) == 0)
1587 he = 1;
1588 else if (strcmp ("ISOLatin1+", PSL->init.encoding) == 0)
1589 he = 4;
1590 else if (strcmp ("ISOLatin1", PSL->init.encoding) == 0)
1591 he = 3;
1592
1593 string = PSL_memory (PSL, NULL, 2 * PSL_BUFSIZ, char);
1594 while (text[i]) {
1595 if (he && text[i] == '@') {
1596 i++;
1597 switch (text[i]) {
1598 case 'A':
1599 strcat (string, psl_scandcodes[0][he]);
1600 j += (int)strlen(psl_scandcodes[0][he]); i++;
1601 break;
1602 case 'E':
1603 strcat (string, psl_scandcodes[1][he]);
1604 j += (int)strlen(psl_scandcodes[1][he]); i++;
1605 break;
1606 case 'O':
1607 strcat (string, psl_scandcodes[2][he]);
1608 j += (int)strlen(psl_scandcodes[2][he]); i++;
1609 break;

Callers 4

psl_set_txt_arrayFunction · 0.85
psl_paragraphprocessFunction · 0.85
PSL_deftextdimFunction · 0.85
PSL_plottextFunction · 0.85

Calls 3

psl_encodefontFunction · 0.85
psl_getfontFunction · 0.85
psl_fix_utf8Function · 0.85

Tested by

no test coverage detected