840
840
* In the case of FreeType this means creating the FreeType library object.
842
842
static gs_fapi_retcode
843
ensure_open(gs_fapi_server * a_server, const char * server_param,
843
gs_fapi_ft_ensure_open(gs_fapi_server * a_server, const char * server_param,
844
844
int server_param_size)
846
846
ff_server *s = (ff_server *) a_server;
859
859
ft_error = FT_New_Library(s->ftmemory, &s->freetype_library);
861
gs_free(s->mem, s->ftmemory, 0, 0, "ensure_open");
861
gs_free(s->mem, s->ftmemory, 0, 0, "gs_fapi_ft_ensure_open");
864
864
FT_Add_Default_Modules(s->freetype_library);
1134
1134
* Open a font and set its size.
1136
1136
static gs_fapi_retcode
1137
get_scaled_font(gs_fapi_server * a_server, gs_fapi_font * a_font,
1137
gs_fapi_ft_get_scaled_font(gs_fapi_server * a_server, gs_fapi_font * a_font,
1138
1138
const gs_fapi_font_scale * a_font_scale,
1139
1139
const char *a_map, gs_fapi_descendant_code a_descendant_code)
1155
1155
s->outline_glyph = NULL;
1158
/* dpf("get_scaled_font enter: is_type1=%d is_cid=%d font_file_path='%s' a_descendant_code=%d\n",
1158
/* dpf("gs_fapi_ft_get_scaled_font enter: is_type1=%d is_cid=%d font_file_path='%s' a_descendant_code=%d\n",
1159
1159
a_font->is_type1, a_font->is_cid, a_font->font_file_path ? a_font->font_file_path : "", a_descendant_code); */
1161
1161
/* If this font is the top level font of an embedded CID type 0 font (font type 9)
1165
1165
if (a_font->is_cid && a_font->is_type1 && a_font->font_file_path == NULL
1166
1166
&& (a_descendant_code == gs_fapi_toplevel_begin
1167
1167
|| a_descendant_code == gs_fapi_toplevel_complete)) {
1168
/* dpf("get_scaled_font return 0\n"); */
1168
/* dpf("gs_fapi_ft_get_scaled_font return 0\n"); */
1178
1178
int own_font_data_len = -1;
1179
1179
FT_Stream ft_strm = NULL;
1181
/* dpf("get_scaled_font creating face\n"); */
1181
/* dpf("gs_fapi_ft_get_scaled_font creating face\n"); */
1183
1183
if (a_font->full_font_buf) {
1185
1185
own_font_data =
1186
1186
gs_malloc(((gs_memory_t *) (s->ftmemory->user)),
1187
1187
a_font->full_font_buf_len, 1,
1188
"get_scaled_font - full font buf");
1188
"gs_fapi_ft_get_scaled_font - full font buf");
1189
1189
if (!own_font_data) {
1190
1190
return_error(gs_error_VMerror);
1398
/* dpf("get_scaled_font return %d\n", a_font->server_font_data ? 0 : -1); */
1398
/* dpf("gs_fapi_ft_get_scaled_font return %d\n", a_font->server_font_data ? 0 : -1); */
1399
1399
return a_font->server_font_data ? 0 : -1;
1406
1406
* in lib/gs_res.ps.
1408
1408
static gs_fapi_retcode
1409
get_decodingID(gs_fapi_server * a_server, gs_fapi_font * a_font,
1409
gs_fapi_ft_get_decodingID(gs_fapi_server * a_server, gs_fapi_font * a_font,
1410
1410
const char **a_decoding_id)
1412
1412
*a_decoding_id = "Unicode";
1417
1417
* Get the font bounding box in font units.
1419
1419
static gs_fapi_retcode
1420
get_font_bbox(gs_fapi_server * a_server, gs_fapi_font * a_font, int a_box[4])
1420
gs_fapi_ft_get_font_bbox(gs_fapi_server * a_server, gs_fapi_font * a_font, int a_box[4])
1422
1422
ff_face *face = (ff_face *) a_font->server_font_data;
1433
1433
* or fixed-width.
1435
1435
static gs_fapi_retcode
1436
get_font_proportional_feature(gs_fapi_server * a_server,
1436
gs_fapi_ft_get_font_proportional_feature(gs_fapi_server * a_server,
1437
1437
gs_fapi_font * a_font, bool * a_proportional)
1439
1439
*a_proportional = true;
1449
1449
static gs_fapi_retcode
1450
can_retrieve_char_by_name(gs_fapi_server * a_server, gs_fapi_font * a_font,
1450
gs_fapi_ft_can_retrieve_char_by_name(gs_fapi_server * a_server, gs_fapi_font * a_font,
1451
1451
gs_fapi_char_ref * a_char_ref, bool * a_result)
1453
1453
ff_face *face = (ff_face *) a_font->server_font_data;
1471
1471
* Return non-zero if the metrics can be replaced.
1473
1473
static gs_fapi_retcode
1474
can_replace_metrics(gs_fapi_server * a_server, gs_fapi_font * a_font,
1474
gs_fapi_ft_can_replace_metrics(gs_fapi_server * a_server, gs_fapi_font * a_font,
1475
1475
gs_fapi_char_ref * a_char_ref, int *a_result)
1477
1477
/* Replace metrics only if the metrics are supplied in font units. */
1483
1483
* Retrieve the metrics of a_char_ref and put them in a_metrics.
1485
1485
static gs_fapi_retcode
1486
get_char_width(gs_fapi_server * a_server, gs_fapi_font * a_font,
1486
gs_fapi_ft_get_char_width(gs_fapi_server * a_server, gs_fapi_font * a_font,
1487
1487
gs_fapi_char_ref * a_char_ref, gs_fapi_metrics * a_metrics)
1489
1489
ff_server *s = (ff_server *) a_server;
1509
1509
* Rasterize the character a_char and return its metrics. Do not return the
1510
1510
* bitmap but store this. It can be retrieved by a subsequent call to
1511
* gs_fapi_ft_get_char_raster.
1513
1513
static gs_fapi_retcode
1514
get_char_raster_metrics(gs_fapi_server * a_server, gs_fapi_font * a_font,
1514
gs_fapi_ft_get_char_raster_metrics(gs_fapi_server * a_server, gs_fapi_font * a_font,
1515
1515
gs_fapi_char_ref * a_char_ref,
1516
1516
gs_fapi_metrics * a_metrics)
1527
* Return the bitmap created by the last call to get_char_raster_metrics.
1527
* Return the bitmap created by the last call to gs_fapi_ft_get_char_raster_metrics.
1529
1529
static gs_fapi_retcode
1530
get_char_raster(gs_fapi_server * a_server, gs_fapi_raster * a_raster)
1530
gs_fapi_ft_get_char_raster(gs_fapi_server * a_server, gs_fapi_raster * a_raster)
1532
1532
ff_server *s = (ff_server *) a_server;
1548
1548
* Create an outline for the character a_char and return its metrics. Do not
1549
1549
* return the outline but store this.
1550
* It can be retrieved by a subsequent call to get_char_outline.
1550
* It can be retrieved by a subsequent call to gs_fapi_ft_get_char_outline.
1552
1552
static gs_fapi_retcode
1553
get_char_outline_metrics(gs_fapi_server * a_server, gs_fapi_font * a_font,
1553
gs_fapi_ft_get_char_outline_metrics(gs_fapi_server * a_server, gs_fapi_font * a_font,
1554
1554
gs_fapi_char_ref * a_char_ref,
1555
1555
gs_fapi_metrics * a_metrics)
1606
1606
int64_t Control1x, Control1y, Control2x, Control2y;
1609
/* More complivated than above, we need to do arithmetic on the
1609
/* More complicated than above, we need to do arithmetic on the
1610
1610
* co-ordinates, so we want them as floats and we will convert the
1611
1611
* result into 16.16 fixed precision for FAPI
1679
* Return the outline created by the last call to get_char_outline_metrics.
1679
* Return the outline created by the last call to gs_fapi_ft_get_char_outline_metrics.
1681
1681
static gs_fapi_retcode
1682
get_char_outline(gs_fapi_server * a_server, gs_fapi_path * a_path)
1682
gs_fapi_ft_get_char_outline(gs_fapi_server * a_server, gs_fapi_path * a_path)
1684
1684
ff_server *s = (ff_server *) a_server;
1685
1685
FF_path_info p;
1737
1737
static gs_fapi_retcode
1738
check_cmap_for_GID(gs_fapi_server * server, uint * index)
1738
gs_fapi_ft_check_cmap_for_GID(gs_fapi_server * server, uint * index)
1740
1740
ff_face *face = (ff_face *) (server->ff.server_font_data);
1741
1741
FT_Face ft_face = face->ft_face;
1763
1763
{1, 0, 0, 1, 0, 0},
1768
get_font_proportional_feature,
1769
can_retrieve_char_by_name,
1770
can_replace_metrics,
1764
gs_fapi_ft_ensure_open,
1765
gs_fapi_ft_get_scaled_font,
1766
gs_fapi_ft_get_decodingID,
1767
gs_fapi_ft_get_font_bbox,
1768
gs_fapi_ft_get_font_proportional_feature,
1769
gs_fapi_ft_can_retrieve_char_by_name,
1770
gs_fapi_ft_can_replace_metrics,
1771
1771
NULL, /* can_simulate_style */
1774
get_char_raster_metrics,
1776
get_char_outline_metrics,
1772
gs_fapi_ft_get_fontmatrix,
1773
gs_fapi_ft_get_char_width,
1774
gs_fapi_ft_get_char_raster_metrics,
1775
gs_fapi_ft_get_char_raster,
1776
gs_fapi_ft_get_char_outline_metrics,
1777
gs_fapi_ft_get_char_outline,
1778
gs_fapi_ft_release_char_data,
1779
gs_fapi_ft_release_typeface,
1780
gs_fapi_ft_check_cmap_for_GID,
1781
1781
NULL /* get_font_info */