ReactOS 0.4.16-dev-338-g34e76ad
t1decode.h File Reference
#include <ft2build.h>
Include dependency graph for t1decode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 t1_lookup_glyph_by_stdcharcode_ps (PS_Decoder *decoder, FT_Int charcode)
 
 t1_decoder_parse_metrics (T1_Decoder decoder, FT_Byte *charstring_base, FT_UInt charstring_len)
 
 t1_decoder_init (T1_Decoder decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte **glyph_names, PS_Blend blend, FT_Bool hinting, FT_Render_Mode hint_mode, T1_Decoder_Callback parse_glyph)
 
 t1_decoder_done (T1_Decoder decoder)
 

Variables

FT_BEGIN_HEADER FT_CALLBACK_TABLE const T1_Decoder_FuncsRec t1_decoder_funcs
 

Function Documentation

◆ t1_decoder_done()

t1_decoder_done ( T1_Decoder  decoder)

Definition at line 1973 of file t1decode.c.

1974 {
1975 FT_Memory memory = decoder->builder.memory;
1976
1977
1978 t1_builder_done( &decoder->builder );
1979
1980 if ( decoder->cf2_instance.finalizer )
1981 {
1982 decoder->cf2_instance.finalizer( decoder->cf2_instance.data );
1983 FT_FREE( decoder->cf2_instance.data );
1984 }
1985 }
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static char memory[1024 *256]
Definition: process.c:116
t1_builder_done(T1_Builder builder)
Definition: psobjs.c:1589
FT_Generic_Finalizer finalizer
Definition: fttypes.h:462
void * data
Definition: fttypes.h:461
FT_Memory memory
Definition: psaux.h:782
T1_BuilderRec builder
Definition: psaux.h:895
FT_Generic cf2_instance
Definition: psaux.h:932

◆ t1_decoder_init()

t1_decoder_init ( T1_Decoder  decoder,
FT_Face  face,
FT_Size  size,
FT_GlyphSlot  slot,
FT_Byte **  glyph_names,
PS_Blend  blend,
FT_Bool  hinting,
FT_Render_Mode  hint_mode,
T1_Decoder_Callback  parse_glyph 
)

Definition at line 1925 of file t1decode.c.

1934 {
1935 FT_ZERO( decoder );
1936
1937 /* retrieve PSNames interface from list of current modules */
1938 {
1939 FT_Service_PsCMaps psnames;
1940
1941
1942 FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
1943 if ( !psnames )
1944 {
1945 FT_ERROR(( "t1_decoder_init:"
1946 " the `psnames' module is not available\n" ));
1947 return FT_THROW( Unimplemented_Feature );
1948 }
1949
1950 decoder->psnames = psnames;
1951 }
1952
1953 t1_builder_init( &decoder->builder, face, size, slot, hinting );
1954
1955 /* decoder->buildchar and decoder->len_buildchar have to be */
1956 /* initialized by the caller since we cannot know the length */
1957 /* of the BuildCharArray */
1958
1959 decoder->num_glyphs = (FT_UInt)face->num_glyphs;
1960 decoder->glyph_names = glyph_names;
1961 decoder->hint_mode = hint_mode;
1962 decoder->blend = blend;
1963 decoder->parse_callback = parse_callback;
1964
1965 decoder->funcs = t1_decoder_funcs;
1966
1967 return FT_Err_Ok;
1968 }
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_ZERO(p)
Definition: ftmemory.h:237
#define FT_FACE_FIND_GLOBAL_SERVICE(face, ptr, id)
Definition: ftserv.h:125
unsigned int FT_UInt
Definition: fttypes.h:231
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
FT_CALLBACK_TABLE_DEF const T1_Decoder_FuncsRec t1_decoder_funcs
Definition: psauxmod.c:88
t1_builder_init(T1_Builder builder, FT_Face face, FT_Size size, FT_GlyphSlot glyph, FT_Bool hinting)
Definition: psobjs.c:1533
PS_Blend blend
Definition: psaux.h:920
FT_UInt num_glyphs
Definition: psaux.h:904
FT_Render_Mode hint_mode
Definition: psaux.h:922
T1_Decoder_FuncsRec funcs
Definition: psaux.h:925
T1_Decoder_Callback parse_callback
Definition: psaux.h:924
FT_Service_PsCMaps psnames
Definition: psaux.h:903
FT_Byte ** glyph_names
Definition: psaux.h:905
Definition: vfat.h:185

◆ t1_decoder_parse_metrics()

t1_decoder_parse_metrics ( T1_Decoder  decoder,
FT_Byte charstring_base,
FT_UInt  charstring_len 
)

Definition at line 1662 of file t1decode.c.

1665 {
1667 FT_Byte* ip;
1668 FT_Byte* limit;
1669 T1_Builder builder = &decoder->builder;
1670
1671#ifdef FT_DEBUG_LEVEL_TRACE
1672 FT_Bool bol = TRUE;
1673#endif
1674
1675
1676 /* First of all, initialize the decoder */
1677 decoder->top = decoder->stack;
1678 decoder->zone = decoder->zones;
1679 zone = decoder->zones;
1680
1681 builder->parse_state = T1_Parse_Start;
1682
1683 FT_TRACE4(( "\n"
1684 "Start charstring: get width\n" ));
1685
1686 zone->base = charstring_base;
1687 limit = zone->limit = charstring_base + charstring_len;
1688 ip = zone->cursor = zone->base;
1689
1690 /* now, execute loop */
1691 while ( ip < limit )
1692 {
1693 FT_Long* top = decoder->top;
1695 FT_Int32 value = 0;
1696
1697
1698#ifdef FT_DEBUG_LEVEL_TRACE
1699 if ( bol )
1700 {
1701 FT_TRACE5(( " (%d)", decoder->top - decoder->stack ));
1702 bol = FALSE;
1703 }
1704#endif
1705
1706 /*********************************************************************/
1707 /* */
1708 /* Decode operator or operand */
1709 /* */
1710 /* */
1711
1712 /* first of all, decompress operator or value */
1713 switch ( *ip++ )
1714 {
1715 case 1:
1716 case 3:
1717 case 4:
1718 case 5:
1719 case 6:
1720 case 7:
1721 case 8:
1722 case 9:
1723 case 10:
1724 case 11:
1725 case 14:
1726 case 15:
1727 case 21:
1728 case 22:
1729 case 30:
1730 case 31:
1731 goto No_Width;
1732
1733 case 13:
1734 op = op_hsbw;
1735 break;
1736
1737 case 12:
1738 if ( ip >= limit )
1739 {
1740 FT_ERROR(( "t1_decoder_parse_metrics:"
1741 " invalid escape (12+EOF)\n" ));
1742 goto Syntax_Error;
1743 }
1744
1745 switch ( *ip++ )
1746 {
1747 case 7:
1748 op = op_sbw;
1749 break;
1750
1751 default:
1752 goto No_Width;
1753 }
1754 break;
1755
1756 case 255: /* four bytes integer */
1757 if ( ip + 4 > limit )
1758 {
1759 FT_ERROR(( "t1_decoder_parse_metrics:"
1760 " unexpected EOF in integer\n" ));
1761 goto Syntax_Error;
1762 }
1763
1764 value = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) |
1765 ( (FT_UInt32)ip[1] << 16 ) |
1766 ( (FT_UInt32)ip[2] << 8 ) |
1767 (FT_UInt32)ip[3] );
1768 ip += 4;
1769
1770 /* According to the specification, values > 32000 or < -32000 must */
1771 /* be followed by a `div' operator to make the result be in the */
1772 /* range [-32000;32000]. We expect that the second argument of */
1773 /* `div' is not a large number. Additionally, we don't handle */
1774 /* stuff like `<large1> <large2> <num> div <num> div' or */
1775 /* <large1> <large2> <num> div div'. This is probably not allowed */
1776 /* anyway. */
1777 if ( value > 32000 || value < -32000 )
1778 {
1779 FT_ERROR(( "t1_decoder_parse_metrics:"
1780 " large integer found for width\n" ));
1781 goto Syntax_Error;
1782 }
1783 else
1784 {
1785 value = (FT_Int32)( (FT_UInt32)value << 16 );
1786 }
1787
1788 break;
1789
1790 default:
1791 if ( ip[-1] >= 32 )
1792 {
1793 if ( ip[-1] < 247 )
1794 value = (FT_Int32)ip[-1] - 139;
1795 else
1796 {
1797 if ( ++ip > limit )
1798 {
1799 FT_ERROR(( "t1_decoder_parse_metrics:"
1800 " unexpected EOF in integer\n" ));
1801 goto Syntax_Error;
1802 }
1803
1804 if ( ip[-2] < 251 )
1805 value = ( ( ip[-2] - 247 ) * 256 ) + ip[-1] + 108;
1806 else
1807 value = -( ( ( ip[-2] - 251 ) * 256 ) + ip[-1] + 108 );
1808 }
1809
1810 value = (FT_Int32)( (FT_UInt32)value << 16 );
1811 }
1812 else
1813 {
1814 FT_ERROR(( "t1_decoder_parse_metrics:"
1815 " invalid byte (%d)\n", ip[-1] ));
1816 goto Syntax_Error;
1817 }
1818 }
1819
1820 /*********************************************************************/
1821 /* */
1822 /* Push value on stack, or process operator */
1823 /* */
1824 /* */
1825 if ( op == op_none )
1826 {
1827 if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )
1828 {
1829 FT_ERROR(( "t1_decoder_parse_metrics: stack overflow\n" ));
1830 goto Syntax_Error;
1831 }
1832
1833#ifdef FT_DEBUG_LEVEL_TRACE
1834 FT_TRACE4(( " %d", value / 65536 ));
1835#endif
1836
1837 *top++ = value;
1838 decoder->top = top;
1839 }
1840 else /* general operator */
1841 {
1842 FT_Int num_args = t1_args_count[op];
1843
1844
1845 FT_ASSERT( num_args >= 0 );
1846
1847 if ( top - decoder->stack < num_args )
1848 goto Stack_Underflow;
1849
1850#ifdef FT_DEBUG_LEVEL_TRACE
1851
1852 if ( top - decoder->stack != num_args )
1853 FT_TRACE0(( "t1_decoder_parse_metrics:"
1854 " too much operands on the stack"
1855 " (seen %d, expected %d)\n",
1856 top - decoder->stack, num_args ));
1857
1858#endif /* FT_DEBUG_LEVEL_TRACE */
1859
1860 top -= num_args;
1861
1862 switch ( op )
1863 {
1864 case op_hsbw:
1865 FT_TRACE4(( " hsbw" ));
1866
1868
1869 builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
1870 top[0] );
1871
1872 builder->advance.x = top[1];
1873 builder->advance.y = 0;
1874
1875 /* we only want to compute the glyph's metrics */
1876 /* (lsb + advance width), not load the rest of */
1877 /* it; so exit immediately */
1878 return FT_Err_Ok;
1879
1880 case op_sbw:
1881 FT_TRACE4(( " sbw" ));
1882
1884
1885 builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
1886 top[0] );
1887 builder->left_bearing.y = ADD_LONG( builder->left_bearing.y,
1888 top[1] );
1889
1890 builder->advance.x = top[2];
1891 builder->advance.y = top[3];
1892
1893 /* we only want to compute the glyph's metrics */
1894 /* (lsb + advance width), not load the rest of */
1895 /* it; so exit immediately */
1896 return FT_Err_Ok;
1897
1898 default:
1899 FT_ERROR(( "t1_decoder_parse_metrics:"
1900 " unhandled opcode %d\n", op ));
1901 goto Syntax_Error;
1902 }
1903
1904 } /* general operator processing */
1905
1906 } /* while ip < limit */
1907
1908 FT_TRACE4(( "..end..\n\n" ));
1909
1910 No_Width:
1911 FT_ERROR(( "t1_decoder_parse_metrics:"
1912 " no width, found op %d instead\n",
1913 ip[-1] ));
1914 Syntax_Error:
1915 return FT_THROW( Syntax_Error );
1916
1917 Stack_Underflow:
1918 return FT_THROW( Stack_Underflow );
1919 }
#define T1_MAX_CHARSTRINGS_OPERANDS
Definition: ftoption.h:725
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT op
Definition: effect.c:236
#define ADD_LONG(a, b)
Definition: ftcalc.h:420
#define FT_ASSERT(condition)
Definition: ftdebug.h:211
#define FT_TRACE0(varformat)
Definition: ftdebug.h:157
#define FT_TRACE5(varformat)
Definition: ftdebug.h:162
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
unsigned char FT_Byte
Definition: fttypes.h:154
signed long FT_Long
Definition: fttypes.h:242
signed int FT_Int
Definition: fttypes.h:220
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint limit
Definition: glext.h:10326
DWORD zone
Definition: sec_mgr.c:1754
@ T1_Parse_Have_Width
Definition: psaux.h:725
@ T1_Parse_Start
Definition: psaux.h:724
FT_Pos x
Definition: ftimage.h:76
FT_Pos y
Definition: ftimage.h:77
FT_Vector advance
Definition: psaux.h:793
FT_Vector left_bearing
Definition: psaux.h:792
T1_ParseState parse_state
Definition: psaux.h:796
T1_Decoder_ZoneRec zones[T1_MAX_SUBRS_CALLS+1]
Definition: psaux.h:900
FT_Long * top
Definition: psaux.h:898
T1_Decoder_Zone zone
Definition: psaux.h:901
FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS]
Definition: psaux.h:897
Definition: dhcpd.h:62
static const FT_Int t1_args_count[op_max]
Definition: t1decode.c:80
enum T1_Operator_ T1_Operator
@ op_hsbw
Definition: t1decode.c:48
@ op_sbw
Definition: t1decode.c:50
@ op_none
Definition: t1decode.c:46
Definition: pdh_main.c:94

◆ t1_lookup_glyph_by_stdcharcode_ps()

t1_lookup_glyph_by_stdcharcode_ps ( PS_Decoder decoder,
FT_Int  charcode 
)

Definition at line 131 of file t1decode.c.

133 {
134 FT_UInt n;
135 const FT_String* glyph_name;
136 FT_Service_PsCMaps psnames = decoder->psnames;
137
138
139 /* check range of standard char code */
140 if ( charcode < 0 || charcode > 255 )
141 return -1;
142
143 glyph_name = psnames->adobe_std_strings(
144 psnames->adobe_std_encoding[charcode]);
145
146 for ( n = 0; n < decoder->num_glyphs; n++ )
147 {
148 FT_String* name = (FT_String*)decoder->glyph_names[n];
149
150
151 if ( name &&
152 name[0] == glyph_name[0] &&
153 ft_strcmp( name, glyph_name ) == 0 )
154 return (FT_Int)n;
155 }
156
157 return -1;
158 }
#define ft_strcmp
Definition: ftstdlib.h:86
char FT_String
Definition: fttypes.h:187
GLdouble n
Definition: glext.h:7729
if(dx< 0)
Definition: linetemp.h:194
FT_Byte ** glyph_names
Definition: psaux.h:630
FT_UInt num_glyphs
Definition: psaux.h:631
FT_Service_PsCMaps psnames
Definition: psaux.h:641
Definition: name.c:39

Referenced by cf2_interpT2CharString().

Variable Documentation

◆ t1_decoder_funcs

Definition at line 32 of file t1decode.h.