2 * Copyright 2012 Google, Inc. All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * Google Author(s): Behdad Esfahbod, Maysum Panju
19 /* Intentionally doesn't have include guards */
29 #include FT_FREETYPE_H
33 glyphy_freetype_move_to(FT_Vector *to,
34 glyphy_arc_accumulator_t *acc)
36 glyphy_point_t p1 = {static_cast<double>(to->x), static_cast<double>(to->y)};
37 glyphy_arc_accumulator_close_path (acc);
38 glyphy_arc_accumulator_move_to (acc, &p1);
39 return glyphy_arc_accumulator_successful (acc) ? FT_Err_Ok : FT_Err_Out_Of_Memory;
43 glyphy_freetype_line_to(FT_Vector *to,
44 glyphy_arc_accumulator_t *acc)
46 glyphy_point_t p1 = {static_cast<double>(to->x), static_cast<double>(to->y)};
47 glyphy_arc_accumulator_line_to (acc, &p1);
48 return glyphy_arc_accumulator_successful (acc) ? FT_Err_Ok : FT_Err_Out_Of_Memory;
52 glyphy_freetype_conic_to(FT_Vector *control, FT_Vector *to,
53 glyphy_arc_accumulator_t *acc)
55 glyphy_point_t p1 = {static_cast<double>(control->x), static_cast<double>(control->y)};
56 glyphy_point_t p2 = {static_cast<double>(to->x), static_cast<double>(to->y)};
57 glyphy_arc_accumulator_conic_to (acc, &p1, &p2);
58 return glyphy_arc_accumulator_successful (acc) ? FT_Err_Ok : FT_Err_Out_Of_Memory;
62 glyphy_freetype_cubic_to(FT_Vector *control1, FT_Vector *control2, FT_Vector *to,
63 glyphy_arc_accumulator_t *acc)
65 glyphy_point_t p1 = {static_cast<double>(control1->x), static_cast<double>(control1->y)};
66 glyphy_point_t p2 = {static_cast<double>(control2->x), static_cast<double>(control2->y)};
67 glyphy_point_t p3 = {static_cast<double>(to->x), static_cast<double>(to->y)};
68 glyphy_arc_accumulator_cubic_to (acc, &p1, &p2, &p3);
69 return glyphy_arc_accumulator_successful (acc) ? FT_Err_Ok : FT_Err_Out_Of_Memory;
73 glyphy_freetype_outline_decompose(const FT_Outline *outline,
74 glyphy_arc_accumulator_t *acc)
76 const FT_Outline_Funcs outline_funcs = {
77 (FT_Outline_MoveToFunc) glyphy_freetype_move_to,
78 (FT_Outline_LineToFunc) glyphy_freetype_line_to,
79 (FT_Outline_ConicToFunc) glyphy_freetype_conic_to,
80 (FT_Outline_CubicToFunc) glyphy_freetype_cubic_to,
85 return FT_Outline_Decompose ((FT_Outline *) outline, &outline_funcs, acc);