Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenftsynth.c
Go to the documentation of this file.
00001 /***************************************************************************/ 00002 /* */ 00003 /* ftsynth.c */ 00004 /* */ 00005 /* FreeType synthesizing code for emboldening and slanting (body). */ 00006 /* */ 00007 /* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2010 by */ 00008 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 00009 /* */ 00010 /* This file is part of the FreeType project, and may only be used, */ 00011 /* modified, and distributed under the terms of the FreeType project */ 00012 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 00013 /* this file you indicate that you have read the license and */ 00014 /* understand and accept it fully. */ 00015 /* */ 00016 /***************************************************************************/ 00017 00018 00019 #include <ft2build.h> 00020 #include FT_SYNTHESIS_H 00021 #include FT_INTERNAL_DEBUG_H 00022 #include FT_INTERNAL_OBJECTS_H 00023 #include FT_OUTLINE_H 00024 #include FT_BITMAP_H 00025 00026 00027 /*************************************************************************/ 00028 /* */ 00029 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ 00030 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ 00031 /* messages during execution. */ 00032 /* */ 00033 #undef FT_COMPONENT 00034 #define FT_COMPONENT trace_synth 00035 00036 /*************************************************************************/ 00037 /*************************************************************************/ 00038 /**** ****/ 00039 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/ 00040 /**** ****/ 00041 /*************************************************************************/ 00042 /*************************************************************************/ 00043 00044 /* documentation is in ftsynth.h */ 00045 00046 FT_EXPORT_DEF( void ) 00047 FT_GlyphSlot_Oblique( FT_GlyphSlot slot ) 00048 { 00049 FT_Matrix transform; 00050 FT_Outline* outline = &slot->outline; 00051 00052 00053 /* only oblique outline glyphs */ 00054 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) 00055 return; 00056 00057 /* we don't touch the advance width */ 00058 00059 /* For italic, simply apply a shear transform, with an angle */ 00060 /* of about 12 degrees. */ 00061 00062 transform.xx = 0x10000L; 00063 transform.yx = 0x00000L; 00064 00065 transform.xy = 0x06000L; 00066 transform.yy = 0x10000L; 00067 00068 FT_Outline_Transform( outline, &transform ); 00069 } 00070 00071 00072 /*************************************************************************/ 00073 /*************************************************************************/ 00074 /**** ****/ 00075 /**** EXPERIMENTAL EMBOLDENING/OUTLINING SUPPORT ****/ 00076 /**** ****/ 00077 /*************************************************************************/ 00078 /*************************************************************************/ 00079 00080 00081 /* documentation is in ftsynth.h */ 00082 00083 FT_EXPORT_DEF( void ) 00084 FT_GlyphSlot_Embolden( FT_GlyphSlot slot ) 00085 { 00086 FT_Library library = slot->library; 00087 FT_Face face = slot->face; 00088 FT_Error error; 00089 FT_Pos xstr, ystr; 00090 00091 00092 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE && 00093 slot->format != FT_GLYPH_FORMAT_BITMAP ) 00094 return; 00095 00096 /* some reasonable strength */ 00097 xstr = FT_MulFix( face->units_per_EM, 00098 face->size->metrics.y_scale ) / 24; 00099 ystr = xstr; 00100 00101 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) 00102 { 00103 /* ignore error */ 00104 (void)FT_Outline_Embolden( &slot->outline, xstr ); 00105 00106 /* this is more than enough for most glyphs; if you need accurate */ 00107 /* values, you have to call FT_Outline_Get_CBox */ 00108 xstr = xstr * 2; 00109 ystr = xstr; 00110 } 00111 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */ 00112 { 00113 /* round to full pixels */ 00114 xstr &= ~63; 00115 if ( xstr == 0 ) 00116 xstr = 1 << 6; 00117 ystr &= ~63; 00118 00119 /* 00120 * XXX: overflow check for 16-bit system, for compatibility 00121 * with FT_GlyphSlot_Embolden() since freetype-2.1.10. 00122 * unfortunately, this function return no informations 00123 * about the cause of error. 00124 */ 00125 if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN ) 00126 { 00127 FT_TRACE1(( "FT_GlyphSlot_Embolden:" )); 00128 FT_TRACE1(( "too strong embolding parameter ystr=%d\n", ystr )); 00129 return; 00130 } 00131 error = FT_GlyphSlot_Own_Bitmap( slot ); 00132 if ( error ) 00133 return; 00134 00135 error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr ); 00136 if ( error ) 00137 return; 00138 } 00139 00140 if ( slot->advance.x ) 00141 slot->advance.x += xstr; 00142 00143 if ( slot->advance.y ) 00144 slot->advance.y += ystr; 00145 00146 slot->metrics.width += xstr; 00147 slot->metrics.height += ystr; 00148 slot->metrics.horiBearingY += ystr; 00149 slot->metrics.horiAdvance += xstr; 00150 slot->metrics.vertBearingX -= xstr / 2; 00151 slot->metrics.vertBearingY += ystr; 00152 slot->metrics.vertAdvance += ystr; 00153 00154 /* XXX: 16-bit overflow case must be excluded before here */ 00155 if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) 00156 slot->bitmap_top += (FT_Int)( ystr >> 6 ); 00157 } 00158 00159 00160 /* END */ Generated on Sun May 27 2012 04:33:47 for ReactOS by
1.7.6.1
|