4 * Copyright 2014-2017 Nikolay Sivov for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include <sys/types.h>
30 #ifdef HAVE_FT2BUILD_H
33 #include FT_FREETYPE_H
35 #include FT_TRUETYPE_TABLES_H
37 #endif /* HAVE_FT2BUILD_H */
40 #define WIN32_NO_STATUS
42 #include "wine/debug.h"
45 #include "dwrite_private.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(dwrite
);
51 static void *ft_handle
= NULL
;
52 static FT_Library library
= 0;
60 #define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
61 MAKE_FUNCPTR(FT_Activate_Size
);
62 MAKE_FUNCPTR(FT_Done_Face
);
63 MAKE_FUNCPTR(FT_Done_FreeType
);
64 MAKE_FUNCPTR(FT_Done_Glyph
);
65 MAKE_FUNCPTR(FT_Done_Size
);
66 MAKE_FUNCPTR(FT_Get_First_Char
);
67 MAKE_FUNCPTR(FT_Get_Glyph
);
68 MAKE_FUNCPTR(FT_Get_Kerning
);
69 MAKE_FUNCPTR(FT_Get_Sfnt_Table
);
70 MAKE_FUNCPTR(FT_Glyph_Copy
);
71 MAKE_FUNCPTR(FT_Glyph_Get_CBox
);
72 MAKE_FUNCPTR(FT_Glyph_Transform
);
73 MAKE_FUNCPTR(FT_Init_FreeType
);
74 MAKE_FUNCPTR(FT_Library_Version
);
75 MAKE_FUNCPTR(FT_Load_Glyph
);
76 MAKE_FUNCPTR(FT_Matrix_Multiply
);
77 MAKE_FUNCPTR(FT_MulDiv
);
78 MAKE_FUNCPTR(FT_New_Memory_Face
);
79 MAKE_FUNCPTR(FT_New_Size
);
80 MAKE_FUNCPTR(FT_Outline_Copy
);
81 MAKE_FUNCPTR(FT_Outline_Decompose
);
82 MAKE_FUNCPTR(FT_Outline_Done
);
83 MAKE_FUNCPTR(FT_Outline_Embolden
);
84 MAKE_FUNCPTR(FT_Outline_Get_Bitmap
);
85 MAKE_FUNCPTR(FT_Outline_New
);
86 MAKE_FUNCPTR(FT_Outline_Transform
);
87 MAKE_FUNCPTR(FT_Outline_Translate
);
88 MAKE_FUNCPTR(FT_Set_Pixel_Sizes
);
90 static FT_Error (*pFT_Outline_EmboldenXY
)(FT_Outline
*, FT_Pos
, FT_Pos
);
92 #define FaceFromObject(o) ((FT_Face)(ULONG_PTR)(o))
94 static FT_Size
freetype_set_face_size(FT_Face face
, FT_UInt emsize
)
98 if (pFT_New_Size(face
, &size
)) return NULL
;
100 pFT_Activate_Size(size
);
102 if (pFT_Set_Pixel_Sizes(face
, emsize
, emsize
))
111 static BOOL
freetype_glyph_has_contours(FT_Face face
)
113 return face
->glyph
->format
== FT_GLYPH_FORMAT_OUTLINE
&& face
->glyph
->outline
.n_contours
;
116 static NTSTATUS
process_attach(void *args
)
118 FT_Version_t FT_Version
;
120 ft_handle
= dlopen(SONAME_LIBFREETYPE
, RTLD_NOW
);
123 WINE_MESSAGE("Wine cannot find the FreeType font library.\n");
124 return STATUS_DLL_NOT_FOUND
;
127 #define LOAD_FUNCPTR(f) if((p##f = dlsym(ft_handle, #f)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;}
128 LOAD_FUNCPTR(FT_Activate_Size
)
129 LOAD_FUNCPTR(FT_Done_Face
)
130 LOAD_FUNCPTR(FT_Done_FreeType
)
131 LOAD_FUNCPTR(FT_Done_Glyph
)
132 LOAD_FUNCPTR(FT_Done_Size
)
133 LOAD_FUNCPTR(FT_Get_First_Char
)
134 LOAD_FUNCPTR(FT_Get_Glyph
)
135 LOAD_FUNCPTR(FT_Get_Kerning
)
136 LOAD_FUNCPTR(FT_Get_Sfnt_Table
)
137 LOAD_FUNCPTR(FT_Glyph_Copy
)
138 LOAD_FUNCPTR(FT_Glyph_Get_CBox
)
139 LOAD_FUNCPTR(FT_Glyph_Transform
)
140 LOAD_FUNCPTR(FT_Init_FreeType
)
141 LOAD_FUNCPTR(FT_Library_Version
)
142 LOAD_FUNCPTR(FT_Load_Glyph
)
143 LOAD_FUNCPTR(FT_Matrix_Multiply
)
144 LOAD_FUNCPTR(FT_MulDiv
)
145 LOAD_FUNCPTR(FT_New_Memory_Face
)
146 LOAD_FUNCPTR(FT_New_Size
)
147 LOAD_FUNCPTR(FT_Outline_Copy
)
148 LOAD_FUNCPTR(FT_Outline_Decompose
)
149 LOAD_FUNCPTR(FT_Outline_Done
)
150 LOAD_FUNCPTR(FT_Outline_Embolden
)
151 LOAD_FUNCPTR(FT_Outline_Get_Bitmap
)
152 LOAD_FUNCPTR(FT_Outline_New
)
153 LOAD_FUNCPTR(FT_Outline_Transform
)
154 LOAD_FUNCPTR(FT_Outline_Translate
)
155 LOAD_FUNCPTR(FT_Set_Pixel_Sizes
)
157 pFT_Outline_EmboldenXY
= dlsym(ft_handle
, "FT_Outline_EmboldenXY");
159 if (pFT_Init_FreeType(&library
) != 0)
161 ERR("Can't init FreeType library\n");
164 return STATUS_UNSUCCESSFUL
;
166 pFT_Library_Version(library
, &FT_Version
.major
, &FT_Version
.minor
, &FT_Version
.patch
);
168 TRACE("FreeType version is %d.%d.%d\n", FT_Version
.major
, FT_Version
.minor
, FT_Version
.patch
);
169 return STATUS_SUCCESS
;
172 WINE_MESSAGE("Wine cannot find certain functions that it needs from FreeType library.\n");
175 return STATUS_UNSUCCESSFUL
;
178 static NTSTATUS
process_detach(void *args
)
180 pFT_Done_FreeType(library
);
181 return STATUS_SUCCESS
;
184 static NTSTATUS
create_font_object(void *args
)
186 struct create_font_object_params
*params
= args
;
190 fterror
= pFT_New_Memory_Face(library
, params
->data
, params
->size
, params
->index
, &face
);
191 if (fterror
!= FT_Err_Ok
)
193 WARN("Failed to create a face object, error %d.\n", fterror
);
194 return STATUS_UNSUCCESSFUL
;
197 *params
->object
= (ULONG_PTR
)face
;
199 return STATUS_SUCCESS
;
202 static NTSTATUS
release_font_object(void *args
)
204 struct release_font_object_params
*params
= args
;
205 pFT_Done_Face(FaceFromObject(params
->object
));
206 return STATUS_SUCCESS
;
209 static NTSTATUS
get_design_glyph_metrics(void *args
)
211 struct get_design_glyph_metrics_params
*params
= args
;
212 FT_Face face
= FaceFromObject(params
->object
);
215 if (!(size
= freetype_set_face_size(face
, params
->upem
)))
216 return STATUS_UNSUCCESSFUL
;
218 if (!pFT_Load_Glyph(face
, params
->glyph
, FT_LOAD_NO_SCALE
))
220 FT_Glyph_Metrics
*metrics
= &face
->glyph
->metrics
;
222 params
->metrics
->leftSideBearing
= metrics
->horiBearingX
;
223 params
->metrics
->advanceWidth
= metrics
->horiAdvance
;
224 params
->metrics
->rightSideBearing
= metrics
->horiAdvance
- metrics
->horiBearingX
- metrics
->width
;
226 params
->metrics
->advanceHeight
= metrics
->vertAdvance
;
227 params
->metrics
->verticalOriginY
= params
->ascent
;
228 params
->metrics
->topSideBearing
= params
->ascent
- metrics
->horiBearingY
;
229 params
->metrics
->bottomSideBearing
= metrics
->vertAdvance
- metrics
->height
- params
->metrics
->topSideBearing
;
231 /* Adjust in case of bold simulation, glyphs without contours are ignored. */
232 if (params
->simulations
& DWRITE_FONT_SIMULATIONS_BOLD
&& freetype_glyph_has_contours(face
))
234 if (params
->metrics
->advanceWidth
)
235 params
->metrics
->advanceWidth
+= (params
->upem
+ 49) / 50;
241 return STATUS_SUCCESS
;
244 struct decompose_context
246 struct dwrite_outline
*outline
;
248 BOOL move_to
; /* last call was 'move_to' */
249 FT_Vector origin
; /* 'pen' position from last call */
252 static inline void ft_vector_to_d2d_point(const FT_Vector
*v
, D2D1_POINT_2F
*p
)
258 static int dwrite_outline_push_tag(struct dwrite_outline
*outline
, unsigned char tag
)
260 if (outline
->tags
.size
< outline
->tags
.count
+ 1)
263 outline
->tags
.values
[outline
->tags
.count
++] = tag
;
268 static int dwrite_outline_push_points(struct dwrite_outline
*outline
, const D2D1_POINT_2F
*points
, unsigned int count
)
270 if (outline
->points
.size
< outline
->points
.count
+ count
)
273 memcpy(&outline
->points
.values
[outline
->points
.count
], points
, sizeof(*points
) * count
);
274 outline
->points
.count
+= count
;
279 static int decompose_beginfigure(struct decompose_context
*ctxt
)
287 ft_vector_to_d2d_point(&ctxt
->origin
, &point
);
288 if ((ret
= dwrite_outline_push_tag(ctxt
->outline
, OUTLINE_BEGIN_FIGURE
))) return ret
;
289 if ((ret
= dwrite_outline_push_points(ctxt
->outline
, &point
, 1))) return ret
;
291 ctxt
->figure_started
= TRUE
;
292 ctxt
->move_to
= FALSE
;
297 static int decompose_move_to(const FT_Vector
*to
, void *user
)
299 struct decompose_context
*ctxt
= (struct decompose_context
*)user
;
302 if (ctxt
->figure_started
)
304 if ((ret
= dwrite_outline_push_tag(ctxt
->outline
, OUTLINE_END_FIGURE
))) return ret
;
305 ctxt
->figure_started
= FALSE
;
308 ctxt
->move_to
= TRUE
;
313 static int decompose_line_to(const FT_Vector
*to
, void *user
)
315 struct decompose_context
*ctxt
= (struct decompose_context
*)user
;
319 /* Special case for empty contours, in a way freetype returns them. */
320 if (ctxt
->move_to
&& !memcmp(to
, &ctxt
->origin
, sizeof(*to
)))
323 ft_vector_to_d2d_point(to
, &point
);
325 if ((ret
= decompose_beginfigure(ctxt
))) return ret
;
326 if ((ret
= dwrite_outline_push_points(ctxt
->outline
, &point
, 1))) return ret
;
327 if ((ret
= dwrite_outline_push_tag(ctxt
->outline
, OUTLINE_LINE
))) return ret
;
333 static int decompose_conic_to(const FT_Vector
*control
, const FT_Vector
*to
, void *user
)
335 struct decompose_context
*ctxt
= (struct decompose_context
*)user
;
336 D2D1_POINT_2F points
[3];
340 if ((ret
= decompose_beginfigure(ctxt
)))
343 /* convert from quadratic to cubic */
346 The parametric eqn for a cubic Bezier is, from PLRM:
347 r(t) = at^3 + bt^2 + ct + r0
348 with the control points:
353 A quadratic Bezier has the form:
354 p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
356 So equating powers of t leads to:
359 and of course r0 = p0, r3 = p2
362 /* r1 = 1/3 p0 + 2/3 p1
363 r2 = 1/3 p2 + 2/3 p1 */
364 cubic
[0].x
= (2 * control
->x
+ 1) / 3;
365 cubic
[0].y
= (2 * control
->y
+ 1) / 3;
367 cubic
[0].x
+= (ctxt
->origin
.x
+ 1) / 3;
368 cubic
[0].y
+= (ctxt
->origin
.y
+ 1) / 3;
369 cubic
[1].x
+= (to
->x
+ 1) / 3;
370 cubic
[1].y
+= (to
->y
+ 1) / 3;
373 ft_vector_to_d2d_point(cubic
, points
);
374 ft_vector_to_d2d_point(cubic
+ 1, points
+ 1);
375 ft_vector_to_d2d_point(cubic
+ 2, points
+ 2);
376 if ((ret
= dwrite_outline_push_points(ctxt
->outline
, points
, 3))) return ret
;
377 if ((ret
= dwrite_outline_push_tag(ctxt
->outline
, OUTLINE_BEZIER
))) return ret
;
382 static int decompose_cubic_to(const FT_Vector
*control1
, const FT_Vector
*control2
,
383 const FT_Vector
*to
, void *user
)
385 struct decompose_context
*ctxt
= (struct decompose_context
*)user
;
386 D2D1_POINT_2F points
[3];
389 if ((ret
= decompose_beginfigure(ctxt
)))
392 ft_vector_to_d2d_point(control1
, points
);
393 ft_vector_to_d2d_point(control2
, points
+ 1);
394 ft_vector_to_d2d_point(to
, points
+ 2);
397 if ((ret
= dwrite_outline_push_points(ctxt
->outline
, points
, 3))) return ret
;
398 if ((ret
= dwrite_outline_push_tag(ctxt
->outline
, OUTLINE_BEZIER
))) return ret
;
403 static int decompose_outline(FT_Outline
*ft_outline
, struct dwrite_outline
*outline
)
405 static const FT_Outline_Funcs decompose_funcs
=
414 struct decompose_context context
= { 0 };
417 context
.outline
= outline
;
419 ret
= pFT_Outline_Decompose(ft_outline
, &decompose_funcs
, &context
);
421 if (!ret
&& context
.figure_started
)
422 ret
= dwrite_outline_push_tag(outline
, OUTLINE_END_FIGURE
);
427 static void embolden_glyph_outline(FT_Outline
*outline
, FLOAT emsize
)
431 strength
= pFT_MulDiv(emsize
, 1 << 6, 24);
432 if (pFT_Outline_EmboldenXY
)
433 pFT_Outline_EmboldenXY(outline
, strength
, 0);
435 pFT_Outline_Embolden(outline
, strength
);
438 static void embolden_glyph(FT_Glyph glyph
, FLOAT emsize
)
440 FT_OutlineGlyph outline_glyph
= (FT_OutlineGlyph
)glyph
;
442 if (glyph
->format
!= FT_GLYPH_FORMAT_OUTLINE
)
445 embolden_glyph_outline(&outline_glyph
->outline
, emsize
);
448 static NTSTATUS
get_glyph_outline(void *args
)
450 struct get_glyph_outline_params
*params
= args
;
451 FT_Face face
= FaceFromObject(params
->object
);
454 if (!(size
= freetype_set_face_size(face
, params
->emsize
)))
455 return STATUS_UNSUCCESSFUL
;
457 if (!pFT_Load_Glyph(face
, params
->glyph
, FT_LOAD_NO_BITMAP
))
459 FT_Outline
*ft_outline
= &face
->glyph
->outline
;
462 if (params
->outline
->points
.values
)
464 if (params
->simulations
& DWRITE_FONT_SIMULATIONS_BOLD
)
465 embolden_glyph_outline(ft_outline
, params
->emsize
);
468 m
.xy
= params
->simulations
& DWRITE_FONT_SIMULATIONS_OBLIQUE
? (1 << 16) / 3 : 0;
470 m
.yy
= -(1 << 16); /* flip Y axis */
472 pFT_Outline_Transform(ft_outline
, &m
);
474 decompose_outline(ft_outline
, params
->outline
);
478 /* Intentionally overestimate numbers to keep it simple. */
479 params
->outline
->points
.count
= ft_outline
->n_points
* 3;
480 params
->outline
->tags
.count
= ft_outline
->n_points
+ ft_outline
->n_contours
* 2;
486 return STATUS_SUCCESS
;
489 static NTSTATUS
get_glyph_count(void *args
)
491 struct get_glyph_count_params
*params
= args
;
492 FT_Face face
= FaceFromObject(params
->object
);
494 *params
->count
= face
? face
->num_glyphs
: 0;
496 return STATUS_SUCCESS
;
499 static inline void ft_matrix_from_dwrite_matrix(const DWRITE_MATRIX
*m
, FT_Matrix
*ft_matrix
)
501 ft_matrix
->xx
= m
->m11
* 0x10000;
502 ft_matrix
->xy
= -m
->m21
* 0x10000;
503 ft_matrix
->yx
= -m
->m12
* 0x10000;
504 ft_matrix
->yy
= m
->m22
* 0x10000;
507 static BOOL
get_glyph_transform(unsigned int simulations
, const DWRITE_MATRIX
*m
, FT_Matrix
*ret
)
516 /* Some fonts provide mostly bitmaps and very few outlines, for example for .notdef.
517 Disable transform if that's the case. */
518 if (!memcmp(m
, &identity
, sizeof(*m
)) && !simulations
)
521 if (simulations
& DWRITE_FONT_SIMULATIONS_OBLIQUE
)
524 ftm
.xy
= (1 << 16) / 3;
527 pFT_Matrix_Multiply(&ftm
, ret
);
530 ft_matrix_from_dwrite_matrix(m
, &ftm
);
531 pFT_Matrix_Multiply(&ftm
, ret
);
536 static NTSTATUS
get_glyph_bbox(void *args
)
538 struct get_glyph_bbox_params
*params
= args
;
539 FT_Face face
= FaceFromObject(params
->object
);
540 FT_Glyph glyph
= NULL
;
541 FT_BBox bbox
= { 0 };
542 BOOL needs_transform
;
546 SetRectEmpty(params
->bbox
);
548 if (!(size
= freetype_set_face_size(face
, params
->emsize
)))
549 return STATUS_UNSUCCESSFUL
;
551 needs_transform
= FT_IS_SCALABLE(face
) && get_glyph_transform(params
->simulations
, ¶ms
->m
, &m
);
553 if (pFT_Load_Glyph(face
, params
->glyph
, needs_transform
? FT_LOAD_NO_BITMAP
: 0))
555 WARN("Failed to load glyph %u.\n", params
->glyph
);
557 return STATUS_UNSUCCESSFUL
;
560 pFT_Get_Glyph(face
->glyph
, &glyph
);
563 if (params
->simulations
& DWRITE_FONT_SIMULATIONS_BOLD
)
564 embolden_glyph(glyph
, params
->emsize
);
566 /* Includes oblique and user transform. */
567 pFT_Glyph_Transform(glyph
, &m
, NULL
);
570 pFT_Glyph_Get_CBox(glyph
, FT_GLYPH_BBOX_PIXELS
, &bbox
);
571 pFT_Done_Glyph(glyph
);
575 SetRect(params
->bbox
, bbox
.xMin
, -bbox
.yMax
, bbox
.xMax
, -bbox
.yMin
);
577 return STATUS_SUCCESS
;
580 static NTSTATUS
freetype_get_aliased_glyph_bitmap(struct get_glyph_bitmap_params
*params
, FT_Glyph glyph
)
582 const RECT
*bbox
= ¶ms
->bbox
;
583 int width
= bbox
->right
- bbox
->left
;
584 int height
= bbox
->bottom
- bbox
->top
;
586 *params
->is_1bpp
= 1;
588 if (glyph
->format
== FT_GLYPH_FORMAT_OUTLINE
) {
589 FT_OutlineGlyph outline
= (FT_OutlineGlyph
)glyph
;
590 const FT_Outline
*src
= &outline
->outline
;
594 ft_bitmap
.width
= width
;
595 ft_bitmap
.rows
= height
;
596 ft_bitmap
.pitch
= params
->pitch
;
597 ft_bitmap
.pixel_mode
= FT_PIXEL_MODE_MONO
;
598 ft_bitmap
.buffer
= params
->bitmap
;
600 /* Note: FreeType will only set 'black' bits for us. */
601 if (pFT_Outline_New(library
, src
->n_points
, src
->n_contours
, ©
) == 0) {
602 pFT_Outline_Copy(src
, ©
);
603 pFT_Outline_Translate(©
, -bbox
->left
<< 6, bbox
->bottom
<< 6);
604 pFT_Outline_Get_Bitmap(library
, ©
, &ft_bitmap
);
605 pFT_Outline_Done(library
, ©
);
608 else if (glyph
->format
== FT_GLYPH_FORMAT_BITMAP
) {
609 FT_Bitmap
*ft_bitmap
= &((FT_BitmapGlyph
)glyph
)->bitmap
;
610 BYTE
*src
= ft_bitmap
->buffer
, *dst
= params
->bitmap
;
611 int w
= min(params
->pitch
, (ft_bitmap
->width
+ 7) >> 3);
612 int h
= min(height
, ft_bitmap
->rows
);
616 src
+= ft_bitmap
->pitch
;
617 dst
+= params
->pitch
;
621 FIXME("format %x not handled\n", glyph
->format
);
623 return STATUS_SUCCESS
;
626 static NTSTATUS
freetype_get_aa_glyph_bitmap(struct get_glyph_bitmap_params
*params
, FT_Glyph glyph
)
628 const RECT
*bbox
= ¶ms
->bbox
;
629 int width
= bbox
->right
- bbox
->left
;
630 int height
= bbox
->bottom
- bbox
->top
;
632 *params
->is_1bpp
= 0;
634 if (glyph
->format
== FT_GLYPH_FORMAT_OUTLINE
) {
635 FT_OutlineGlyph outline
= (FT_OutlineGlyph
)glyph
;
636 const FT_Outline
*src
= &outline
->outline
;
640 ft_bitmap
.width
= width
;
641 ft_bitmap
.rows
= height
;
642 ft_bitmap
.pitch
= params
->pitch
;
643 ft_bitmap
.pixel_mode
= FT_PIXEL_MODE_GRAY
;
644 ft_bitmap
.buffer
= params
->bitmap
;
646 /* Note: FreeType will only set 'black' bits for us. */
647 if (pFT_Outline_New(library
, src
->n_points
, src
->n_contours
, ©
) == 0) {
648 pFT_Outline_Copy(src
, ©
);
649 pFT_Outline_Translate(©
, -bbox
->left
<< 6, bbox
->bottom
<< 6);
650 pFT_Outline_Get_Bitmap(library
, ©
, &ft_bitmap
);
651 pFT_Outline_Done(library
, ©
);
654 else if (glyph
->format
== FT_GLYPH_FORMAT_BITMAP
) {
655 FT_Bitmap
*ft_bitmap
= &((FT_BitmapGlyph
)glyph
)->bitmap
;
656 BYTE
*src
= ft_bitmap
->buffer
, *dst
= params
->bitmap
;
657 int w
= min(params
->pitch
, (ft_bitmap
->width
+ 7) >> 3);
658 int h
= min(height
, ft_bitmap
->rows
);
662 src
+= ft_bitmap
->pitch
;
663 dst
+= params
->pitch
;
666 *params
->is_1bpp
= 1;
670 FIXME("format %x not handled\n", glyph
->format
);
671 return STATUS_NOT_IMPLEMENTED
;
674 return STATUS_SUCCESS
;
677 static NTSTATUS
get_glyph_bitmap(void *args
)
679 struct get_glyph_bitmap_params
*params
= args
;
680 FT_Face face
= FaceFromObject(params
->object
);
681 BOOL needs_transform
;
687 *params
->is_1bpp
= 0;
689 if (!(size
= freetype_set_face_size(face
, params
->emsize
)))
690 return STATUS_UNSUCCESSFUL
;
692 needs_transform
= FT_IS_SCALABLE(face
) && get_glyph_transform(params
->simulations
, ¶ms
->m
, &m
);
694 if (!pFT_Load_Glyph(face
, params
->glyph
, needs_transform
? FT_LOAD_NO_BITMAP
: 0))
696 pFT_Get_Glyph(face
->glyph
, &glyph
);
700 if (params
->simulations
& DWRITE_FONT_SIMULATIONS_BOLD
)
701 embolden_glyph(glyph
, params
->emsize
);
703 /* Includes oblique and user transform. */
704 pFT_Glyph_Transform(glyph
, &m
, NULL
);
707 if (params
->mode
== DWRITE_RENDERING_MODE1_ALIASED
)
708 ret
= freetype_get_aliased_glyph_bitmap(params
, glyph
);
710 ret
= freetype_get_aa_glyph_bitmap(params
, glyph
);
712 pFT_Done_Glyph(glyph
);
720 static NTSTATUS
get_glyph_advance(void *args
)
722 struct get_glyph_advance_params
*params
= args
;
723 FT_Face face
= FaceFromObject(params
->object
);
726 *params
->advance
= 0;
727 *params
->has_contours
= FALSE
;
729 if (!(size
= freetype_set_face_size(face
, params
->emsize
)))
730 return STATUS_UNSUCCESSFUL
;
732 if (!pFT_Load_Glyph(face
, params
->glyph
, params
->mode
== DWRITE_MEASURING_MODE_NATURAL
? FT_LOAD_NO_HINTING
: 0))
734 *params
->advance
= face
->glyph
->advance
.x
>> 6;
735 *params
->has_contours
= freetype_glyph_has_contours(face
);
740 return STATUS_SUCCESS
;
743 #else /* HAVE_FREETYPE */
745 static NTSTATUS
process_attach(void *args
)
747 return STATUS_NOT_IMPLEMENTED
;
750 static NTSTATUS
process_detach(void *args
)
752 return STATUS_NOT_IMPLEMENTED
;
755 static NTSTATUS
create_font_object(void *args
)
757 return STATUS_NOT_IMPLEMENTED
;
760 static NTSTATUS
release_font_object(void *args
)
762 return STATUS_NOT_IMPLEMENTED
;
765 static NTSTATUS
get_glyph_outline(void *args
)
767 return STATUS_NOT_IMPLEMENTED
;
770 static NTSTATUS
get_glyph_count(void *args
)
772 return STATUS_NOT_IMPLEMENTED
;
775 static NTSTATUS
get_glyph_advance(void *args
)
777 struct get_glyph_advance_params
*params
= args
;
779 *params
->has_contours
= 0;
780 *params
->advance
= 0;
782 return STATUS_NOT_IMPLEMENTED
;
785 static NTSTATUS
get_glyph_bbox(void *args
)
787 struct get_glyph_bbox_params
*params
= args
;
788 SetRectEmpty(params
->bbox
);
789 return STATUS_NOT_IMPLEMENTED
;
792 static NTSTATUS
get_glyph_bitmap(void *args
)
794 return STATUS_NOT_IMPLEMENTED
;
797 static NTSTATUS
get_design_glyph_metrics(void *args
)
799 return STATUS_NOT_IMPLEMENTED
;
802 #endif /* HAVE_FREETYPE */
804 const unixlib_entry_t __wine_unix_call_funcs
[] =
815 get_design_glyph_metrics
,
822 static NTSTATUS
wow64_create_font_object(void *args
)
830 } const *params32
= args
;
831 struct create_font_object_params params
=
833 ULongToPtr(params32
->data
),
836 ULongToPtr(params32
->object
),
839 return create_font_object(¶ms
);
842 static NTSTATUS
wow64_release_font_object(void *args
)
847 } const *params32
= args
;
848 struct release_font_object_params params
=
853 return release_font_object(¶ms
);
856 struct dwrite_outline32
873 static NTSTATUS
wow64_get_glyph_outline(void *args
)
882 } const *params32
= args
;
883 struct dwrite_outline32
*outline32
= ULongToPtr(params32
->outline
);
884 struct dwrite_outline outline
=
886 .tags
.values
= ULongToPtr(outline32
->tags
.values
),
887 .tags
.count
= outline32
->tags
.count
,
888 .tags
.size
= outline32
->tags
.size
,
889 .points
.values
= ULongToPtr(outline32
->points
.values
),
890 .points
.count
= outline32
->points
.count
,
891 .points
.size
= outline32
->points
.size
,
894 struct get_glyph_outline_params params
=
897 params32
->simulations
,
904 status
= get_glyph_outline(¶ms
);
905 outline32
->points
.count
= outline
.points
.count
;
906 outline32
->tags
.count
= outline
.tags
.count
;
910 static NTSTATUS
wow64_get_glyph_count(void *args
)
916 } const *params32
= args
;
917 struct get_glyph_count_params params
=
920 ULongToPtr(params32
->count
),
923 return get_glyph_count(¶ms
);
926 static NTSTATUS
wow64_get_glyph_advance(void *args
)
936 } const *params32
= args
;
937 struct get_glyph_advance_params params
=
943 ULongToPtr(params32
->advance
),
944 ULongToPtr(params32
->has_contours
),
947 return get_glyph_advance(¶ms
);
950 static NTSTATUS
wow64_get_glyph_bbox(void *args
)
960 } const *params32
= args
;
961 struct get_glyph_bbox_params params
=
964 params32
->simulations
,
968 ULongToPtr(params32
->bbox
),
971 return get_glyph_bbox(¶ms
);
974 static NTSTATUS
wow64_get_glyph_bitmap(void *args
)
988 } const *params32
= args
;
989 struct get_glyph_bitmap_params params
=
992 params32
->simulations
,
999 ULongToPtr(params32
->bitmap
),
1000 ULongToPtr(params32
->is_1bpp
),
1003 return get_glyph_bitmap(¶ms
);
1006 static NTSTATUS
wow64_get_design_glyph_metrics(void *args
)
1016 } const *params32
= args
;
1017 struct get_design_glyph_metrics_params params
=
1020 params32
->simulations
,
1024 ULongToPtr(params32
->metrics
),
1027 return get_design_glyph_metrics(¶ms
);
1030 const unixlib_entry_t __wine_unix_call_wow64_funcs
[] =
1034 wow64_create_font_object
,
1035 wow64_release_font_object
,
1036 wow64_get_glyph_outline
,
1037 wow64_get_glyph_count
,
1038 wow64_get_glyph_advance
,
1039 wow64_get_glyph_bbox
,
1040 wow64_get_glyph_bitmap
,
1041 wow64_get_design_glyph_metrics
,