w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ftadvanc.c
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * ftadvanc.c
4  *
5  * Quick computation of advance widths (body).
6  *
7  * Copyright (C) 2008-2020 by
8  * David Turner, Robert Wilhelm, and Werner Lemberg.
9  *
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
12  * license, LICENSE.TXT. By continuing to use, modify, or distribute
13  * this file you indicate that you have read the license and
14  * understand and accept it fully.
15  *
16  */
17 
18 
19 #include <freetype/internal/ftdebug.h>
20 
21 #include <freetype/ftadvanc.h>
22 #include <freetype/internal/ftobjs.h>
23 
24 
25  static FT_Error
27  FT_Fixed* advances,
28  FT_UInt count,
29  FT_Int32 flags )
30  {
32  FT_UInt nn;
33 
34 
35  if ( flags & FT_LOAD_NO_SCALE )
36  return FT_Err_Ok;
37 
38  if ( !face->size )
39  return FT_THROW( Invalid_Size_Handle );
40 
43  else
45 
46  /* this must be the same scaling as to get linear{Hori,Vert}Advance */
47  /* (see `FT_Load_Glyph' implementation in src/base/ftobjs.c) */
48 
49  for ( nn = 0; nn < count; nn++ )
50  advances[nn] = FT_MulDiv( advances[nn], scale, 64 );
51 
52  return FT_Err_Ok;
53  }
54 
55 
56  /* at the moment, we can perform fast advance retrieval only in */
57  /* the following cases: */
58  /* */
59  /* - unscaled load */
60  /* - unhinted load */
61  /* - light-hinted load */
62  /* - if a variations font, it must have an `HVAR' or `VVAR' */
63  /* table (thus the old MM or GX fonts don't qualify; this */
64  /* gets checked by the driver-specific functions) */
65 
66 #define LOAD_ADVANCE_FAST_CHECK( face, flags ) \
67  ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \
68  FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT )
69 
70 
71  /* documentation is in ftadvanc.h */
72 
75  FT_UInt gindex,
76  FT_Int32 flags,
77  FT_Fixed *padvance )
78  {
80 
81 
82  if ( !face )
83  return FT_THROW( Invalid_Face_Handle );
84 
85  if ( !padvance )
86  return FT_THROW( Invalid_Argument );
87 
88  if ( gindex >= (FT_UInt)face->num_glyphs )
89  return FT_THROW( Invalid_Glyph_Index );
90 
93  {
95 
96 
97  error = func( face, gindex, 1, flags, padvance );
98  if ( !error )
99  return _ft_face_scale_advances( face, padvance, 1, flags );
100 
101  if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
102  return error;
103  }
104 
105  return FT_Get_Advances( face, gindex, 1, flags, padvance );
106  }
107 
108 
109  /* documentation is in ftadvanc.h */
110 
113  FT_UInt start,
114  FT_UInt count,
115  FT_Int32 flags,
116  FT_Fixed *padvances )
117  {
119 
121 
122  FT_UInt num, end, nn;
123  FT_Int factor;
124 
125 
126  if ( !face )
127  return FT_THROW( Invalid_Face_Handle );
128 
129  if ( !padvances )
130  return FT_THROW( Invalid_Argument );
131 
133  end = start + count;
134  if ( start >= num || end < start || end > num )
135  return FT_THROW( Invalid_Glyph_Index );
136 
137  if ( count == 0 )
138  return FT_Err_Ok;
139 
141  if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
142  {
143  error = func( face, start, count, flags, padvances );
144  if ( !error )
145  return _ft_face_scale_advances( face, padvances, count, flags );
146 
147  if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
148  return error;
149  }
150 
151  error = FT_Err_Ok;
152 
154  return FT_THROW( Unimplemented_Feature );
155 
156  flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
157  factor = ( flags & FT_LOAD_NO_SCALE ) ? 1 : 1024;
158  for ( nn = 0; nn < count; nn++ )
159  {
161  if ( error )
162  break;
163 
164  /* scale from 26.6 to 16.16, unless NO_SCALE was requested */
165  padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
166  ? face->glyph->advance.y * factor
167  : face->glyph->advance.x * factor;
168  }
169 
170  return error;
171  }
172 
173 
174 /* END */
#define count(a)
Definition: aptex-macros.h:781
#define error(a)
Definition: dviinfo.c:48
#define FT_EXPORT_DEF(x)
Definition: ftconfig.h:32
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:796
#define FT_LOAD_VERTICAL_LAYOUT
Definition: freetype.h:3026
#define FT_LOAD_NO_SCALE
Definition: freetype.h:3022
#define FT_LOAD_ADVANCE_ONLY
Definition: freetype.h:3044
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:415
#define FT_ADVANCE_FLAG_FAST_ONLY
Definition: ftadvanc.h:77
signed long FT_Fixed
Definition: fttypes.h:287
int FT_Error
Definition: fttypes.h:299
#define FT_ERR_NEQ(x, e)
Definition: fttypes.h:606
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
#define FT_THROW(e)
Definition: ftdebug.h:243
FT_Error(* FT_Face_GetAdvancesFunc)(FT_Face face, FT_UInt first, FT_UInt count, FT_Int32 flags, FT_Fixed *advances)
Definition: ftdrv.h:83
FT_Get_Advance(FT_Face face, FT_UInt gindex, FT_Int32 flags, FT_Fixed *padvance)
Definition: ftadvanc.c:74
FT_Get_Advances(FT_Face face, FT_UInt start, FT_UInt count, FT_Int32 flags, FT_Fixed *padvances)
Definition: ftadvanc.c:112
return FT_Err_Ok
Definition: ftbbox.c:526
FT_Face face
Definition: cffdrivr.c:659
float factor
Definition: dimen.c:22
int num
Definition: disdvi.c:621
static luaL_Reg func[]
Definition: except.c:32
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
integer nn[24]
Definition: pmxab.c:90
double scale
Definition: pnmhistmap.c:38
static FT_Error _ft_face_scale_advances(FT_Face face, FT_Fixed *advances, FT_UInt count, FT_Int32 flags)
Definition: ftadvanc.c:26
#define LOAD_ADVANCE_FAST_CHECK(face, flags)
Definition: ftadvanc.c:66
#define flags
FT_Driver_Class clazz
Definition: ftobjs.h:802
FT_Face_GetAdvancesFunc get_advances
Definition: ftdrv.h:185
FT_Driver driver
Definition: freetype.h:1071
FT_Size size
Definition: freetype.h:1066
FT_Long num_glyphs
Definition: freetype.h:1036
FT_GlyphSlot glyph
Definition: freetype.h:1065
FT_Vector advance
Definition: freetype.h:1882
FT_Size_Metrics metrics
Definition: freetype.h:1636
FT_Fixed y_scale
Definition: freetype.h:1601
FT_Fixed x_scale
Definition: freetype.h:1600
FT_Pos x
Definition: ftimage.h:77
FT_Pos y
Definition: ftimage.h:78
@ start
Definition: preamble.c:52
#define end(cp)
Definition: zic.c:71