[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master afe6c9d: * src/ftview.c (Render_*): Improve rea
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master afe6c9d: * src/ftview.c (Render_*): Improve readability. |
Date: |
Fri, 24 Mar 2017 23:48:08 -0400 (EDT) |
branch: master
commit afe6c9d6351d5ab19072e179230cb95632fdd47f
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
* src/ftview.c (Render_*): Improve readability.
---
ChangeLog | 4 ++
src/ftview.c | 226 ++++++++++++++++++++++++++++++-----------------------------
2 files changed, 118 insertions(+), 112 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 25f58dd..514b97b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2017-03-24 Alexei Podtelezhnikov <address@hidden>
+ * src/ftview.c (Render_*): Improve readability.
+
+2017-03-24 Alexei Podtelezhnikov <address@hidden>
+
[ftview] Consolidate emboldening and slanting modes.
* src/ftview.c (Render_Slanted, Render_Embolden): Merged into...
diff --git a/src/ftview.c b/src/ftview.c
index 3d2f85d..9e5f7a0 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -227,20 +227,18 @@
error = FTDemo_Draw_Glyph( handle, display, glyph, &x, &y );
- if ( !error )
- {
- FT_Done_Glyph( glyph );
-
- if ( !have_topleft )
- {
- have_topleft = 1;
- status.topleft = i;
- }
- }
+ FT_Done_Glyph( glyph );
if ( error )
goto Next;
- else if ( X_TOO_LONG( x, size, display ) )
+
+ if ( !have_topleft )
+ {
+ have_topleft = 1;
+ status.topleft = i;
+ }
+
+ if ( X_TOO_LONG( x, size, display ) )
{
x = start_x;
y += step_y;
@@ -251,7 +249,7 @@
}
else
Next:
- status.num_fails++;
+ status.num_fails++;
}
return error;
@@ -260,7 +258,7 @@
static FT_Error
Render_Fancy( int num_indices,
- int offset )
+ int offset )
{
int start_x, start_y, step_y, x, y;
int i, have_topleft;
@@ -320,74 +318,75 @@
glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
error = FT_Load_Glyph( face, glyph_idx, handle->load_flags );
- if ( !error )
+ if ( error )
+ goto Next;
+
+ /* this is essentially the code of function */
+ /* `FT_GlyphSlot_Embolden' */
+
+ if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
- /* this is essentially the code of function */
- /* `FT_GlyphSlot_Embolden' */
+ FT_Outline_Transform( &slot->outline, &shear );
- if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
- {
- FT_Outline_Transform( &slot->outline, &shear );
+ error = FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
+ /* ignore error */
+ }
+ else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
+ {
+ /* round to full pixels */
+ xstr &= ~63;
+ ystr &= ~63;
- error = FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
- /* ignore error */
- }
- else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
- {
- /* round to full pixels */
- xstr &= ~63;
- ystr &= ~63;
-
- error = FT_GlyphSlot_Own_Bitmap( slot );
- if ( error )
- goto Next;
-
- error = FT_Bitmap_Embolden( slot->library, &slot->bitmap,
- xstr, ystr );
- if ( error )
- goto Next;
- } else
+ error = FT_GlyphSlot_Own_Bitmap( slot );
+ if ( error )
goto Next;
- if ( slot->advance.x )
- slot->advance.x += xstr;
+ error = FT_Bitmap_Embolden( slot->library, &slot->bitmap,
+ xstr, ystr );
+ if ( error )
+ goto Next;
+ }
+ else
+ goto Next;
+
+ if ( slot->advance.x )
+ slot->advance.x += xstr;
- if ( slot->advance.y )
- slot->advance.y += ystr;
+ if ( slot->advance.y )
+ slot->advance.y += ystr;
- slot->metrics.width += xstr;
- slot->metrics.height += ystr;
- slot->metrics.horiAdvance += xstr;
- slot->metrics.vertAdvance += ystr;
+ slot->metrics.width += xstr;
+ slot->metrics.height += ystr;
+ slot->metrics.horiAdvance += xstr;
+ slot->metrics.vertAdvance += ystr;
- if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
- slot->bitmap_top += ystr >> 6;
+ if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
+ slot->bitmap_top += ystr >> 6;
- error = FTDemo_Draw_Slot( handle, display, slot, &x, &y );
+ error = FTDemo_Draw_Slot( handle, display, slot, &x, &y );
- if ( !error )
- {
- if ( !have_topleft )
- {
- have_topleft = 1;
- status.topleft = i;
- }
- }
+ if ( error )
+ goto Next;
- if ( error )
- goto Next;
- else if ( X_TOO_LONG( x, size, display ) )
- {
- x = start_x;
- y += step_y;
+ if ( !have_topleft )
+ {
+ have_topleft = 1;
+ status.topleft = i;
+ }
- if ( Y_TOO_LONG( y, size, display ) )
- break;
- }
+ if ( X_TOO_LONG( x, size, display ) )
+ {
+ x = start_x;
+ y += step_y;
+
+ if ( Y_TOO_LONG( y, size, display ) )
+ break;
}
- else
+
+ continue;
+
Next:
- status.num_fails++;
+ status.num_fails++;
}
return error;
@@ -427,18 +426,16 @@
error = FTDemo_Draw_Index( handle, display, glyph_idx, &x, &y );
- if ( !error )
+ if ( error )
+ goto Next;
+
+ if ( !have_topleft )
{
- if ( !have_topleft )
- {
- have_topleft = 1;
- status.topleft = i;
- }
+ have_topleft = 1;
+ status.topleft = i;
}
- if ( error )
- status.num_fails++;
- else if ( X_TOO_LONG( x, size, display ) )
+ if ( X_TOO_LONG( x, size, display ) )
{
x = start_x;
y += step_y;
@@ -446,6 +443,11 @@
if ( Y_TOO_LONG( y, size, display ) )
break;
}
+
+ continue;
+
+ Next:
+ status.num_fails++;
}
return FT_Err_Ok;
@@ -509,31 +511,31 @@
error = FTDemo_Draw_Index( handle, display, glyph_idx, &x, &y );
- if ( !error )
+ if ( error )
+ goto Next;
+
+ if ( !have_topleft )
{
- if ( !have_topleft )
- {
- have_topleft = 1;
- status.topleft = ch;
- }
+ have_topleft = 1;
+ status.topleft = ch;
}
- if ( error )
- status.num_fails++;
- else
- {
- /* Draw_Index adds one pixel space */
- x--;
+ /* Draw_Index adds one pixel space */
+ x--;
- if ( X_TOO_LONG( x, size, display ) )
- {
- x = start_x;
- y += step_y;
+ if ( X_TOO_LONG( x, size, display ) )
+ {
+ x = start_x;
+ y += step_y;
- if ( Y_TOO_LONG( y, size, display ) )
- break;
- }
+ if ( Y_TOO_LONG( y, size, display ) )
+ break;
}
+
+ continue;
+
+ Next:
+ status.num_fails++;
}
return FT_Err_Ok;
@@ -643,26 +645,26 @@
error = FTDemo_Draw_Index( handle, display, glyph_idx, &x, &y );
- if ( !error )
+ if ( error )
+ goto Next;
+
+ /* `topleft' should be the first character after the size string */
+ if ( oldp - text == start && !have_topleft )
{
- /* `topleft' should be the first character after the size string */
- if ( oldp - text == start && !have_topleft )
- {
- have_topleft = 1;
- status.topleft = ch;
- }
+ have_topleft = 1;
+ status.topleft = ch;
}
- if ( error )
- status.num_fails++;
- else
- {
- /* Draw_Index adds one pixel space */
- x--;
+ /* Draw_Index adds one pixel space */
+ x--;
- if ( X_TOO_LONG( x, size, display ) )
- break;
- }
+ if ( X_TOO_LONG( x, size, display ) )
+ break;
+
+ continue;
+
+ Next:
+ status.num_fails++;
}
}
@@ -1993,7 +1995,7 @@
case RENDER_MODE_FANCY:
error = Render_Fancy( handle->current_font->num_indices,
- status.offset );
+ status.offset );
break;
case RENDER_MODE_STROKE:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master afe6c9d: * src/ftview.c (Render_*): Improve readability.,
Alexei Podtelezhnikov <=