freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype-demos][master] 2 commits: * src/ftmulti.c (main,


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] 2 commits: * src/ftmulti.c (main, Init_Display): Clean up GUI setup.
Date: Mon, 13 Feb 2023 05:49:34 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • cc30d687
    by Alexei Podtelezhnikov at 2023-02-12T23:34:27-05:00
    * src/ftmulti.c (main, Init_Display): Clean up GUI setup.
    
  • fac96edb
    by Alexei Podtelezhnikov at 2023-02-13T00:47:21-05:00
    * src/ftmulti.c: Clean up loading and scaling.
    

1 changed file:

Changes:

  • src/ftmulti.c
    ... ... @@ -82,27 +82,25 @@
    82 82
     
    
    83 83
       static FT_Error      error;        /* error returned by FreeType? */
    
    84 84
     
    
    85
    -  static grSurface*    surface;      /* current display surface     */
    
    86
    -  static grBitmap*     bit;          /* current display bitmap      */
    
    85
    +  static grSurface*  surface;        /* current display surface     */
    
    86
    +  static grBitmap*   bit;            /* current display bitmap      */
    
    87
    +  static grColor     fore_color;     /* foreground on black back    */
    
    87 88
     
    
    88 89
       static unsigned short  width  = DIM_X;     /* window width        */
    
    89 90
       static unsigned short  height = DIM_Y;     /* window height       */
    
    90 91
     
    
    91
    -  static int  num_glyphs;            /* number of glyphs            */
    
    92 92
       static int  ptsize;                /* current point size          */
    
    93
    +  static int  res       = 72;        /* resolution, dpi             */
    
    93 94
     
    
    94 95
       static int  hinted    = 1;         /* is glyph hinting active?    */
    
    95 96
       static int  grouping  = 1;         /* is axis grouping active?    */
    
    96 97
       static int  antialias = 1;         /* is anti-aliasing active?    */
    
    97 98
       static int  fillrule  = 0x0;       /* flip fill flags or not?     */
    
    98 99
       static int  overlaps  = 0x0;       /* flip overlap flags or not?  */
    
    99
    -  static int  Num;                   /* current first glyph index   */
    
    100
    -
    
    101
    -  static int  res       = 72;
    
    102 100
     
    
    103
    -  static grColor  fore_color;
    
    104
    -
    
    105
    -  static int  Fail;
    
    101
    +  static int  num_glyphs;            /* number of glyphs            */
    
    102
    +  static int  Num;                   /* current first glyph index   */
    
    103
    +  static int  Fail;                  /* number of failed glyphs     */
    
    106 104
     
    
    107 105
       static int  render_mode = 1;
    
    108 106
     
    
    ... ... @@ -305,6 +303,8 @@
    305 303
         bit = (grBitmap*)surface;
    
    306 304
     
    
    307 305
         fore_color = grFindColor( bit, 255, 255, 255, 255 );  /* white */
    
    306
    +
    
    307
    +    grSetTitle( surface, "FreeType Variations Viewer - press ? for help" );
    
    308 308
       }
    
    309 309
     
    
    310 310
     
    
    ... ... @@ -360,12 +360,12 @@
    360 360
       }
    
    361 361
     
    
    362 362
     
    
    363
    -  static void
    
    363
    +  static FT_Error
    
    364 364
       Reset_Scale( int  pointSize )
    
    365 365
       {
    
    366
    -    (void)FT_Set_Char_Size( face,
    
    367
    -                            pointSize << 6, pointSize << 6,
    
    368
    -                            (FT_UInt)res, (FT_UInt)res );
    
    366
    +    return FT_Set_Char_Size( face,
    
    367
    +                             pointSize << 6, pointSize << 6,
    
    368
    +                             (FT_UInt)res, (FT_UInt)res );
    
    369 369
       }
    
    370 370
     
    
    371 371
     
    
    ... ... @@ -848,6 +848,7 @@
    848 848
           ptsize = 1;
    
    849 849
         if ( ptsize > MAXPTSIZE )
    
    850 850
           ptsize = MAXPTSIZE;
    
    851
    +    Reset_Scale( ptsize );
    
    851 852
         return 1;
    
    852 853
     
    
    853 854
       Do_Glyph:
    
    ... ... @@ -902,9 +903,8 @@
    902 903
       main( int    argc,
    
    903 904
             char*  argv[] )
    
    904 905
       {
    
    905
    -    int    old_ptsize, orig_ptsize, file;
    
    906
    +    int    orig_ptsize, file;
    
    906 907
         int    first_glyph = 0;
    
    907
    -    int    XisSetup = 0;
    
    908 908
         int    option;
    
    909 909
         int    file_loaded;
    
    910 910
     
    
    ... ... @@ -1034,7 +1034,9 @@
    1034 1034
           goto Display_Font;
    
    1035 1035
         }
    
    1036 1036
     
    
    1037
    -    font_format = FT_Get_Font_Format( face );
    
    1037
    +    error = Reset_Scale( ptsize );
    
    1038
    +    if ( error )
    
    1039
    +      goto Display_Font;
    
    1038 1040
     
    
    1039 1041
         if ( encoding != FT_ENCODING_NONE )
    
    1040 1042
         {
    
    ... ... @@ -1098,26 +1100,19 @@
    1098 1100
         if ( error )
    
    1099 1101
           goto Display_Font;
    
    1100 1102
     
    
    1101
    -    file_loaded++;
    
    1102
    -
    
    1103
    -    Reset_Scale( ptsize );
    
    1103
    +    file_loaded = 1;
    
    1104 1104
     
    
    1105
    -    num_glyphs = face->num_glyphs;
    
    1106
    -    glyph      = face->glyph;
    
    1107
    -    size       = face->size;
    
    1105
    +    font_format = FT_Get_Font_Format( face );
    
    1106
    +    num_glyphs  = face->num_glyphs;
    
    1107
    +    glyph       = face->glyph;
    
    1108
    +    size        = face->size;
    
    1108 1109
     
    
    1109 1110
       Display_Font:
    
    1110 1111
         /* initialize graphics if needed */
    
    1111
    -    if ( !XisSetup )
    
    1112
    -    {
    
    1113
    -      XisSetup = 1;
    
    1112
    +    if ( !surface )
    
    1114 1113
           Init_Display();
    
    1115
    -    }
    
    1116
    -
    
    1117
    -    grSetTitle( surface, "FreeType Glyph Viewer - press ? for help" );
    
    1118
    -    old_ptsize = ptsize;
    
    1119 1114
     
    
    1120
    -    if ( file_loaded >= 1 )
    
    1115
    +    if ( file_loaded )
    
    1121 1116
         {
    
    1122 1117
           Fail = 0;
    
    1123 1118
           Num  = first_glyph;
    
    ... ... @@ -1140,7 +1135,7 @@
    1140 1135
           strbuf_init( header, Header, sizeof ( Header ) );
    
    1141 1136
           strbuf_reset( header );
    
    1142 1137
     
    
    1143
    -      if ( file_loaded >= 1 )
    
    1138
    +      if ( file_loaded )
    
    1144 1139
           {
    
    1145 1140
             switch ( render_mode )
    
    1146 1141
             {
    
    ... ... @@ -1236,7 +1231,7 @@
    1236 1231
     
    
    1237 1232
           if ( key == grKEY( '.' ) )
    
    1238 1233
           {
    
    1239
    -        if ( file_loaded >= 1 )
    
    1234
    +        if ( file_loaded )
    
    1240 1235
               FT_Done_Face( face );
    
    1241 1236
     
    
    1242 1237
             if ( file < argc - 1 )
    
    ... ... @@ -1247,7 +1242,7 @@
    1247 1242
     
    
    1248 1243
           if ( key == grKEY( ',' ) )
    
    1249 1244
           {
    
    1250
    -        if ( file_loaded >= 1 )
    
    1245
    +        if ( file_loaded )
    
    1251 1246
               FT_Done_Face( face );
    
    1252 1247
     
    
    1253 1248
             if ( file > 0 )
    
    ... ... @@ -1259,18 +1254,11 @@
    1259 1254
           if ( key == grKeyF6 )
    
    1260 1255
           {
    
    1261 1256
             /* enforce reloading */
    
    1262
    -        if ( file_loaded >= 1 )
    
    1257
    +        if ( file_loaded )
    
    1263 1258
               FT_Done_Face( face );
    
    1264 1259
     
    
    1265 1260
             goto NewFile;
    
    1266 1261
           }
    
    1267
    -
    
    1268
    -      if ( ptsize != old_ptsize )
    
    1269
    -      {
    
    1270
    -        Reset_Scale( ptsize );
    
    1271
    -
    
    1272
    -        old_ptsize = ptsize;
    
    1273
    -      }
    
    1274 1262
         }
    
    1275 1263
     
    
    1276 1264
       End:
    
    ... ... @@ -1283,6 +1271,7 @@
    1283 1271
     
    
    1284 1272
         printf( "Execution completed successfully.\n" );
    
    1285 1273
         printf( "Fails = %d\n", Fail );
    
    1274
    +    fflush( stdout );  /* clean mintty pipes */
    
    1286 1275
     
    
    1287 1276
         exit( 0 );      /* for safety reasons */
    
    1288 1277
         /* return 0; */ /* never reached */
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]