のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

composite glyph

   1655     /* otherwise, load a composite! */
   1656     else if ( loader->n_contours == -1 )
   1657     {
   1658       FT_UInt   start_point;
   1659       FT_UInt   start_contour;
   1660       FT_ULong  ins_pos;  /* position of composite instructions, if any */
   1661 
   1662 
   1663       start_point   = (FT_UInt)gloader->base.outline.n_points;
   1664       start_contour = (FT_UInt)gloader->base.outline.n_contours;
   1665 
   1666       /* for each subglyph, read composite header */
   1667       error = face->read_composite_glyph( loader );
   1668       if ( error )
   1669         goto Exit;
   1670 
   1671       /* store the offset of instructions */
   1672       ins_pos = loader->ins_pos;
   1673 
   1674       /* all data we need are read */
   1675       face->forget_glyph_frame( loader );
   1676       opened_frame = 0;
   1677 
   1678 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
   1784 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
   1785 
   1786       /* scale phantom points, if necessary; */
   1787       /* they get rounded in `TT_Hint_Glyph' */
   1788       if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
   1789       {
   1790         loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
   1791         loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
   1792         /* pp1.y and pp2.y are always zero */
   1793 
   1794         loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
   1795         loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
   1796         loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
   1797         loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
   1798       }
   1799 
   1800       /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
   1801       /* `as is' in the glyph slot (the client application will be     */
   1802       /* responsible for interpreting these data)...                   */
   1803       if ( loader->load_flags & FT_LOAD_NO_RECURSE )
   1804       {
   1805         FT_GlyphLoader_Add( gloader );
   1806         loader->glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
   1807 
   1808         goto Exit;
   1809       }
   1810 
   1811       /*********************************************************************/
   1812       /*********************************************************************/
   1813       /*********************************************************************/
   1814 
   1815       {
   1816         FT_UInt      n, num_base_points;
   1817         FT_SubGlyph  subglyph       = NULL;
   1818 
   1819         FT_UInt      num_points     = start_point;
   1820         FT_UInt      num_subglyphs  = gloader->current.num_subglyphs;
   1821         FT_UInt      num_base_subgs = gloader->base.num_subglyphs;
   1822 
   1823         FT_Stream    old_stream     = loader->stream;
   1824         FT_Int       old_byte_len   = loader->byte_len;
   1825 
   1826 
   1827         FT_GlyphLoader_Add( gloader );
   1828 
   1829         /* read each subglyph independently */
   1830         for ( n = 0; n < num_subglyphs; n++ )
   1831         {
   1832           FT_Vector  pp[4];
   1833 
   1834 
   1835           /* Each time we call load_truetype_glyph in this loop, the   */
   1836           /* value of `gloader.base.subglyphs' can change due to table */
   1837           /* reallocations.  We thus need to recompute the subglyph    */
   1838           /* pointer on each iteration.                                */
   1839           subglyph = gloader->base.subglyphs + num_base_subgs + n;
   1840 
   1841           pp[0] = loader->pp1;
   1842           pp[1] = loader->pp2;
   1843           pp[2] = loader->pp3;
   1844           pp[3] = loader->pp4;
   1845 
   1846           num_base_points = (FT_UInt)gloader->base.outline.n_points;
   1847 
   1848           error = load_truetype_glyph( loader,
   1849                                        (FT_UInt)subglyph->index,
   1850                                        recurse_count + 1,
   1851                                        FALSE );
   1852           if ( error )
   1853             goto Exit;
   1854 
   1855           /* restore subglyph pointer */
   1856           subglyph = gloader->base.subglyphs + num_base_subgs + n;
   1857 
   1858           /* restore phantom points if necessary */
   1859           if ( !( subglyph->flags & USE_MY_METRICS ) )
   1860           {
   1861             loader->pp1 = pp[0];
   1862             loader->pp2 = pp[1];
   1863             loader->pp3 = pp[2];
   1864             loader->pp4 = pp[3];
   1865           }
   1866 
   1867           num_points = (FT_UInt)gloader->base.outline.n_points;
   1868 
   1869           if ( num_points == num_base_points )
   1870             continue;
   1871 
   1872           /* gloader->base.outline consists of three parts:               */
   1873           /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
   1874           /*                                                              */
   1875           /* (1): exists from the beginning                               */
   1876           /* (2): components that have been loaded so far                 */
   1877           /* (3): the newly loaded component                              */
   1878           error = TT_Process_Composite_Component( loader,
   1879                                                   subglyph,
   1880                                                   start_point,
   1881                                                   num_base_points );
   1882           if ( error )
   1883             goto Exit;
   1884         }
   1885 
   1886         loader->stream   = old_stream;
   1887         loader->byte_len = old_byte_len;
   1888 
   1889         /* process the glyph */
   1890         loader->ins_pos = ins_pos;
   1891         if ( IS_HINTED( loader->load_flags ) &&
   1892 #ifdef TT_USE_BYTECODE_INTERPRETER
   1893              subglyph->flags & WE_HAVE_INSTR &&
   1894 #endif
   1895              num_points > start_point )
   1896         {
   1897           error = TT_Process_Composite_Glyph( loader,
   1898                                               start_point,
   1899                                               start_contour );
   1900           if ( error )
   1901             goto Exit;
   1902         }
   1903       }
   1904     }
   1905     else
   1906     {
   1907       /* invalid composite count (negative but not -1) */
   1908       error = FT_THROW( Invalid_Outline );
   1909       goto Exit;
   1910     }
   1911 
   1912     /***********************************************************************/
   1913     /***********************************************************************/
   1914     /***********************************************************************/
   1915 
   1916   Exit:
   1917 
   1918     if ( opened_frame )
   1919       face->forget_glyph_frame( loader );
   1920 
   1921 #ifdef FT_CONFIG_OPTION_INCREMENTAL
   1922 
   1923     if ( glyph_data_loaded )
   1924       face->root.internal->incremental_interface->funcs->free_glyph_data(
   1925         face->root.internal->incremental_interface->object,
   1926         &glyph_data );
   1927 
   1928 #endif
   1929 
   1930     return error;
   1931   }
 
||<  
></blockquote><

*1453964722*[truetype]maxComponentDepth
maxComponentDepthの定義が、MSとAppleで違う。
>||
Microsoftの場合:
USHORT	maxComponentDepth	Maximum levels of recursion; 1 for simple components.
Appleの場合:
uint16	maxComponentDepth	levels of recursion, set to 0 if font has only simple glyphs

Freetypeのチェック

   1423     /* some fonts have an incorrect value of `maxComponentDepth', */
   1424     /* thus we allow depth 1 to catch the majority of them        */
   1425     if ( recurse_count > 1                                   &&
   1426          recurse_count > face->max_profile.maxComponentDepth )
   1427     {
   1428       error = FT_THROW( Invalid_Composite );
   1429       goto Exit;
   1430     }

maxp - Maximum Profile

Version 1.0
Type	Name	Description
Fixed	Table version number	0x00010000 for version 1.0.
USHORT	numGlyphs	The number of glyphs in the font.
USHORT	maxPoints	Maximum points in a non-composite glyph.
USHORT	maxContours	Maximum contours in a non-composite glyph.
USHORT	maxCompositePoints	Maximum points in a composite glyph.
USHORT	maxCompositeContours	Maximum contours in a composite glyph.
USHORT	maxZones	1 if instructions do not use the twilight zone (Z0), or 2 if instructions do use Z0; should be set to 2 in most cases.
USHORT	maxTwilightPoints	Maximum points used in Z0.
USHORT	maxStorage	Number of Storage Area locations.
USHORT	maxFunctionDefs	Number of FDEFs, equals to the highest function number + 1.
USHORT	maxInstructionDefs	Number of IDEFs.
USHORT	maxStackElements	Maximum stack depth2.
USHORT	maxSizeOfInstructions	Maximum byte count for glyph instructions.
USHORT	maxComponentElements	Maximum number of components referenced at ???top level??? for any composite glyph.
USHORT	maxComponentDepth	Maximum levels of recursion; 1 for simple components.
The maxp Table
Type
Name
Description
Fixed	version	0x00010000 (1.0)
uint16	numGlyphs	the number of glyphs in the font
uint16	maxPoints	points in non-compound glyph
uint16	maxContours	contours in non-compound glyph
uint16	maxComponentPoints	points in compound glyph
uint16	maxComponentContours	contours in compound glyph
uint16	maxZones	set to 2
uint16	maxTwilightPoints	points used in Twilight Zone (Z0)
uint16	maxStorage	number of Storage Area locations
uint16	maxFunctionDefs	number of FDEFs
uint16	maxInstructionDefs	number of IDEFs
uint16	maxStackElements	maximum stack depth
uint16	maxSizeOfInstructions	byte count for glyph instructions
uint16	maxComponentElements	number of glyphs referenced at top level
uint16	maxComponentDepth	levels of recursion, set to 0 if font has only simple glyphs