src/java.desktop/share/native/libfreetype/src/base/ftstroke.c
changeset 54876 da3834261f0c
parent 49234 3375a8039fde
equal deleted inserted replaced
54875:bcfedddcf4ce 54876:da3834261f0c
     1 /***************************************************************************/
     1 /****************************************************************************
     2 /*                                                                         */
     2  *
     3 /*  ftstroke.c                                                             */
     3  * ftstroke.c
     4 /*                                                                         */
     4  *
     5 /*    FreeType path stroker (body).                                        */
     5  *   FreeType path stroker (body).
     6 /*                                                                         */
     6  *
     7 /*  Copyright 2002-2018 by                                                 */
     7  * Copyright (C) 2002-2019 by
     8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
     8  * David Turner, Robert Wilhelm, and Werner Lemberg.
     9 /*                                                                         */
     9  *
    10 /*  This file is part of the FreeType project, and may only be used,       */
    10  * This file is part of the FreeType project, and may only be used,
    11 /*  modified, and distributed under the terms of the FreeType project      */
    11  * modified, and distributed under the terms of the FreeType project
    12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
    12  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    13 /*  this file you indicate that you have read the license and              */
    13  * this file you indicate that you have read the license and
    14 /*  understand and accept it fully.                                        */
    14  * understand and accept it fully.
    15 /*                                                                         */
    15  *
    16 /***************************************************************************/
    16  */
    17 
    17 
    18 
    18 
    19 #include <ft2build.h>
    19 #include <ft2build.h>
    20 #include FT_STROKER_H
    20 #include FT_STROKER_H
    21 #include FT_TRIGONOMETRY_H
    21 #include FT_TRIGONOMETRY_H
    22 #include FT_OUTLINE_H
    22 #include FT_OUTLINE_H
    23 #include FT_INTERNAL_MEMORY_H
    23 #include FT_INTERNAL_MEMORY_H
    24 #include FT_INTERNAL_DEBUG_H
    24 #include FT_INTERNAL_DEBUG_H
    25 #include FT_INTERNAL_OBJECTS_H
    25 #include FT_INTERNAL_OBJECTS_H
    26 
    26 
    27 #include "basepic.h"
    27 
    28 
    28   /* declare an extern to access `ft_outline_glyph_class' globally */
    29 
    29   /* allocated  in `ftglyph.c'                                     */
    30   /* declare an extern to access `ft_outline_glyph_class' globally     */
       
    31   /* allocated  in `ftglyph.c', and use the FT_OUTLINE_GLYPH_CLASS_GET */
       
    32   /* macro to access it when FT_CONFIG_OPTION_PIC is defined           */
       
    33 #ifndef FT_CONFIG_OPTION_PIC
       
    34   FT_CALLBACK_TABLE const FT_Glyph_Class  ft_outline_glyph_class;
    30   FT_CALLBACK_TABLE const FT_Glyph_Class  ft_outline_glyph_class;
    35 #endif
       
    36 
    31 
    37 
    32 
    38   /* documentation is in ftstroke.h */
    33   /* documentation is in ftstroke.h */
    39 
    34 
    40   FT_EXPORT_DEF( FT_StrokerBorder )
    35   FT_EXPORT_DEF( FT_StrokerBorder )
   370     {
   365     {
   371       /* copy the last point to the start of this sub-path, since */
   366       /* copy the last point to the start of this sub-path, since */
   372       /* it contains the `adjusted' starting coordinates          */
   367       /* it contains the `adjusted' starting coordinates          */
   373       border->num_points    = --count;
   368       border->num_points    = --count;
   374       border->points[start] = border->points[count];
   369       border->points[start] = border->points[count];
       
   370       border->tags[start]   = border->tags[count];
   375 
   371 
   376       if ( reverse )
   372       if ( reverse )
   377       {
   373       {
   378         /* reverse the points */
   374         /* reverse the points */
   379         {
   375         {
   434       /* move last point */
   430       /* move last point */
   435       border->points[border->num_points - 1] = *to;
   431       border->points[border->num_points - 1] = *to;
   436     }
   432     }
   437     else
   433     else
   438     {
   434     {
   439       /* don't add zero-length lineto */
   435       /* don't add zero-length lineto, but always add moveto */
   440       if ( border->num_points > 0                                          &&
   436       if ( border->num_points > (FT_UInt)border->start                     &&
   441            FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) &&
   437            FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) &&
   442            FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) )
   438            FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) )
   443         return error;
   439         return error;
   444 
   440 
   445       /* add one point */
   441       /* add one point */
  2085 
  2081 
  2086 
  2082 
  2087   /* documentation is in ftstroke.h */
  2083   /* documentation is in ftstroke.h */
  2088 
  2084 
  2089   /*
  2085   /*
  2090    *  The following is very similar to FT_Outline_Decompose, except
  2086    * The following is very similar to FT_Outline_Decompose, except
  2091    *  that we do support opened paths, and do not scale the outline.
  2087    * that we do support opened paths, and do not scale the outline.
  2092    */
  2088    */
  2093   FT_EXPORT_DEF( FT_Error )
  2089   FT_EXPORT_DEF( FT_Error )
  2094   FT_Stroker_ParseOutline( FT_Stroker   stroker,
  2090   FT_Stroker_ParseOutline( FT_Stroker   stroker,
  2095                            FT_Outline*  outline,
  2091                            FT_Outline*  outline,
  2096                            FT_Bool      opened )
  2092                            FT_Bool      opened )
  2304                    FT_Bool      destroy )
  2300                    FT_Bool      destroy )
  2305   {
  2301   {
  2306     FT_Error  error = FT_ERR( Invalid_Argument );
  2302     FT_Error  error = FT_ERR( Invalid_Argument );
  2307     FT_Glyph  glyph = NULL;
  2303     FT_Glyph  glyph = NULL;
  2308 
  2304 
  2309     /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
       
  2310     FT_Library  library = stroker->library;
       
  2311 
       
  2312     FT_UNUSED( library );
       
  2313 
       
  2314 
  2305 
  2315     if ( !pglyph )
  2306     if ( !pglyph )
  2316       goto Exit;
  2307       goto Exit;
  2317 
  2308 
  2318     glyph = *pglyph;
  2309     glyph = *pglyph;
  2319     if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
  2310     if ( !glyph || glyph->clazz != &ft_outline_glyph_class )
  2320       goto Exit;
  2311       goto Exit;
  2321 
  2312 
  2322     {
  2313     {
  2323       FT_Glyph  copy;
  2314       FT_Glyph  copy;
  2324 
  2315 
  2384                          FT_Bool      destroy )
  2375                          FT_Bool      destroy )
  2385   {
  2376   {
  2386     FT_Error  error = FT_ERR( Invalid_Argument );
  2377     FT_Error  error = FT_ERR( Invalid_Argument );
  2387     FT_Glyph  glyph = NULL;
  2378     FT_Glyph  glyph = NULL;
  2388 
  2379 
  2389     /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
       
  2390     FT_Library  library = stroker->library;
       
  2391 
       
  2392     FT_UNUSED( library );
       
  2393 
       
  2394 
  2380 
  2395     if ( !pglyph )
  2381     if ( !pglyph )
  2396       goto Exit;
  2382       goto Exit;
  2397 
  2383 
  2398     glyph = *pglyph;
  2384     glyph = *pglyph;
  2399     if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
  2385     if ( !glyph || glyph->clazz != &ft_outline_glyph_class )
  2400       goto Exit;
  2386       goto Exit;
  2401 
  2387 
  2402     {
  2388     {
  2403       FT_Glyph  copy;
  2389       FT_Glyph  copy;
  2404 
  2390