@@ -160,8 +160,9 @@ void FT2Image::draw_rect(unsigned long x0, unsigned long y0, unsigned long x1, u
160
160
}
161
161
162
162
for (size_t j = y0 + 1 ; j < y1; ++j) {
163
- m_buffer[x0 + j * m_width] = 255 ;
164
- m_buffer[x1 + j * m_width] = 255 ;
163
+ size_t offset = j * m_width;
164
+ m_buffer[x0 + offset] = 255 ;
165
+ m_buffer[x1 + offset] = 255 ;
165
166
}
166
167
167
168
m_dirty = true ;
@@ -176,8 +177,9 @@ FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1,
176
177
y1 = std::min (y1 + 1 , m_height);
177
178
178
179
for (size_t j = y0; j < y1; j++) {
180
+ size_t offset = j * m_width;
179
181
for (size_t i = x0; i < x1; i++) {
180
- m_buffer[i + j * m_width ] = 255 ;
182
+ m_buffer[i + offset ] = 255 ;
181
183
}
182
184
}
183
185
@@ -236,8 +238,8 @@ ft_outline_move_to(FT_Vector const* to, void* user)
236
238
*(d->vertices ++) = 0 ;
237
239
*(d->codes ++) = CLOSEPOLY;
238
240
}
239
- *(d->vertices ++) = to->x / 64 .;
240
- *(d->vertices ++) = to->y / 64 .;
241
+ *(d->vertices ++) = to->x * ( 1 . / 64 .) ;
242
+ *(d->vertices ++) = to->y * ( 1 . / 64 .) ;
241
243
*(d->codes ++) = MOVETO;
242
244
}
243
245
d->index += d->index ? 2 : 1 ;
@@ -249,8 +251,8 @@ ft_outline_line_to(FT_Vector const* to, void* user)
249
251
{
250
252
ft_outline_decomposer* d = reinterpret_cast <ft_outline_decomposer*>(user);
251
253
if (d->codes ) {
252
- *(d->vertices ++) = to->x / 64 .;
253
- *(d->vertices ++) = to->y / 64 .;
254
+ *(d->vertices ++) = to->x * ( 1 . / 64 .) ;
255
+ *(d->vertices ++) = to->y * ( 1 . / 64 .) ;
254
256
*(d->codes ++) = LINETO;
255
257
}
256
258
d->index ++;
@@ -262,10 +264,10 @@ ft_outline_conic_to(FT_Vector const* control, FT_Vector const* to, void* user)
262
264
{
263
265
ft_outline_decomposer* d = reinterpret_cast <ft_outline_decomposer*>(user);
264
266
if (d->codes ) {
265
- *(d->vertices ++) = control->x / 64 .;
266
- *(d->vertices ++) = control->y / 64 .;
267
- *(d->vertices ++) = to->x / 64 .;
268
- *(d->vertices ++) = to->y / 64 .;
267
+ *(d->vertices ++) = control->x * ( 1 . / 64 .) ;
268
+ *(d->vertices ++) = control->y * ( 1 . / 64 .) ;
269
+ *(d->vertices ++) = to->x * ( 1 . / 64 .) ;
270
+ *(d->vertices ++) = to->y * ( 1 . / 64 .) ;
269
271
*(d->codes ++) = CURVE3;
270
272
*(d->codes ++) = CURVE3;
271
273
}
@@ -279,12 +281,12 @@ ft_outline_cubic_to(
279
281
{
280
282
ft_outline_decomposer* d = reinterpret_cast <ft_outline_decomposer*>(user);
281
283
if (d->codes ) {
282
- *(d->vertices ++) = c1->x / 64 .;
283
- *(d->vertices ++) = c1->y / 64 .;
284
- *(d->vertices ++) = c2->x / 64 .;
285
- *(d->vertices ++) = c2->y / 64 .;
286
- *(d->vertices ++) = to->x / 64 .;
287
- *(d->vertices ++) = to->y / 64 .;
284
+ *(d->vertices ++) = c1->x * ( 1 . / 64 .) ;
285
+ *(d->vertices ++) = c1->y * ( 1 . / 64 .) ;
286
+ *(d->vertices ++) = c2->x * ( 1 . / 64 .) ;
287
+ *(d->vertices ++) = c2->y * ( 1 . / 64 .) ;
288
+ *(d->vertices ++) = to->x * ( 1 . / 64 .) ;
289
+ *(d->vertices ++) = to->y * ( 1 . / 64 .) ;
288
290
*(d->codes ++) = CURVE4;
289
291
*(d->codes ++) = CURVE4;
290
292
*(d->codes ++) = CURVE4;
@@ -485,13 +487,16 @@ void FT2Font::set_text(
485
487
{
486
488
FT_Matrix matrix; /* transformation matrix */
487
489
488
- angle = angle / 360.0 * 2 * M_PI;
490
+ angle = angle * ( 2 * M_PI / 360.0 ) ;
489
491
490
492
// this computes width and height in subpixels so we have to multiply by 64
491
- matrix.xx = (FT_Fixed)(cos (angle) * 0x10000L );
492
- matrix.xy = (FT_Fixed)(-sin (angle) * 0x10000L );
493
- matrix.yx = (FT_Fixed)(sin (angle) * 0x10000L );
494
- matrix.yy = (FT_Fixed)(cos (angle) * 0x10000L );
493
+ FT_Fixed ftcosangle = (FT_Fixed)(cos (angle) * 64.0 );
494
+ double sinangle = sin (angle) * 64.0 ;
495
+
496
+ matrix.xx = ftcosangle;
497
+ matrix.xy = (FT_Fixed)(-sinangle);
498
+ matrix.yx = (FT_Fixed)(sinangle);
499
+ matrix.yy = ftcosangle;
495
500
496
501
clear ();
497
502
@@ -762,8 +767,8 @@ void FT2Font::draw_glyphs_to_bitmap(bool antialiased)
762
767
// now, draw to our target surface (convert position)
763
768
764
769
// bitmap left and top in pixel, string bbox in subpixel
765
- FT_Int x = (FT_Int)(bitmap->left - (bbox.xMin / 64 .));
766
- FT_Int y = (FT_Int)((bbox.yMax / 64 .) - bitmap->top + 1 );
770
+ FT_Int x = (FT_Int)(bitmap->left - (bbox.xMin * ( 1 . / 64 .) ));
771
+ FT_Int y = (FT_Int)((bbox.yMax * ( 1 . / 64 .) ) - bitmap->top + 1 );
767
772
768
773
image.draw_bitmap (&bitmap->bitmap , x, y);
769
774
}
@@ -782,8 +787,8 @@ void FT2Font::get_xys(bool antialiased, std::vector<double> &xys)
782
787
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyphs[n];
783
788
784
789
// bitmap left and top in pixel, string bbox in subpixel
785
- FT_Int x = (FT_Int)(bitmap->left - bbox.xMin / 64 .);
786
- FT_Int y = (FT_Int)(bbox.yMax / 64 . - bitmap->top + 1 );
790
+ FT_Int x = (FT_Int)(bitmap->left - bbox.xMin * ( 1 . / 64 .) );
791
+ FT_Int y = (FT_Int)(bbox.yMax * ( 1 . / 64 .) - bitmap->top + 1 );
787
792
// make sure the index is non-neg
788
793
x = x < 0 ? 0 : x;
789
794
y = y < 0 ? 0 : y;
0 commit comments