~ubuntu-branches/ubuntu/vivid/ghostscript/vivid-security

« back to all changes in this revision

Viewing changes to base/fapi_ft.c

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2013-08-28 18:05:40 UTC
  • mfrom: (1.1.41)
  • Revision ID: package-import@ubuntu.com-20130828180540-372a9b9b1wuesdwi
Tags: 9.10~dfsg~rc1-0ubuntu1
* New upstream release
   - Ghostscript 9.10rc1.
   - Upstream: Mainly, changes to our Postscript startup code (to improve
     compatibility with Adobe) have had unexpected and undesirable side
     effects. Most of these have been in fairly widely relied upon, but also
     decidedly non-standard uses (pdf2dsc being a prime example).
   - We are using Ghostscript's libopenjpeg again, using the system's one
     does not (yet) work as there are still patches of the Ghostscript
     developers which did not get accepted upstream yet..
* debian/control: Removed build dependency on libopenjpeg-dev.
* debian/rules: Removed check for removed openjpeg/ subdirectory in the
  repackaging check again, also set build options for using Ghostscript's
  built-in libopenjpeg library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
840
840
 * In the case of FreeType this means creating the FreeType library object.
841
841
 */
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)
845
845
{
846
846
    ff_server *s = (ff_server *) a_server;
858
858
 
859
859
        ft_error = FT_New_Library(s->ftmemory, &s->freetype_library);
860
860
        if (ft_error) {
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");
862
862
        }
863
863
        else {
864
864
            FT_Add_Default_Modules(s->freetype_library);
1134
1134
 * Open a font and set its size.
1135
1135
 */
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)
1140
1140
{
1155
1155
        s->outline_glyph = NULL;
1156
1156
    }
1157
1157
 
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); */
1160
1160
 
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"); */
1169
1169
        return 0;
1170
1170
    }
1171
1171
 
1178
1178
        int own_font_data_len = -1;
1179
1179
        FT_Stream ft_strm = NULL;
1180
1180
 
1181
 
        /* dpf("get_scaled_font creating face\n"); */
 
1181
        /* dpf("gs_fapi_ft_get_scaled_font creating face\n"); */
1182
1182
 
1183
1183
        if (a_font->full_font_buf) {
1184
1184
 
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);
1191
1191
            }
1395
1395
        }
1396
1396
    }
1397
1397
 
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;
1400
1400
}
1401
1401
 
1406
1406
 * in lib/gs_res.ps.
1407
1407
 */
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)
1411
1411
{
1412
1412
    *a_decoding_id = "Unicode";
1417
1417
 * Get the font bounding box in font units.
1418
1418
 */
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])
1421
1421
{
1422
1422
    ff_face *face = (ff_face *) a_font->server_font_data;
1423
1423
 
1433
1433
 * or fixed-width.
1434
1434
 */
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)
1438
1438
{
1439
1439
    *a_proportional = true;
1447
1447
 * return code.
1448
1448
 */
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)
1452
1452
{
1453
1453
    ff_face *face = (ff_face *) a_font->server_font_data;
1471
1471
 * Return non-zero if the metrics can be replaced.
1472
1472
 */
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)
1476
1476
{
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.
1484
1484
 */
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)
1488
1488
{
1489
1489
    ff_server *s = (ff_server *) a_server;
1494
1494
}
1495
1495
 
1496
1496
static gs_fapi_retcode
1497
 
get_fontmatrix(gs_fapi_server * server, gs_matrix * m)
 
1497
gs_fapi_ft_get_fontmatrix(gs_fapi_server * server, gs_matrix * m)
1498
1498
{
1499
1499
    m->xx = 1.0;
1500
1500
    m->xy = 0.0;
1508
1508
/*
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
 
 * get_char_raster.
 
1511
 * gs_fapi_ft_get_char_raster.
1512
1512
 */
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)
1517
1517
{
1524
1524
}
1525
1525
 
1526
1526
/*
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.
1528
1528
 */
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)
1531
1531
{
1532
1532
    ff_server *s = (ff_server *) a_server;
1533
1533
 
1547
1547
/*
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.
1551
1551
 */
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)
1556
1556
{
1606
1606
    int64_t Control1x, Control1y, Control2x, Control2y;
1607
1607
    floatp sx, sy;
1608
1608
 
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
1612
1612
     *
1676
1676
};
1677
1677
 
1678
1678
/*
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.
1680
1680
 */
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)
1683
1683
{
1684
1684
    ff_server *s = (ff_server *) a_server;
1685
1685
    FF_path_info p;
1706
1706
}
1707
1707
 
1708
1708
static gs_fapi_retcode
1709
 
release_char_data(gs_fapi_server * a_server)
 
1709
gs_fapi_ft_release_char_data(gs_fapi_server * a_server)
1710
1710
{
1711
1711
    ff_server *s = (ff_server *) a_server;
1712
1712
 
1726
1726
}
1727
1727
 
1728
1728
static gs_fapi_retcode
1729
 
release_typeface(gs_fapi_server * a_server, void *a_server_font_data)
 
1729
gs_fapi_ft_release_typeface(gs_fapi_server * a_server, void *a_server_font_data)
1730
1730
{
1731
1731
    ff_face *face = (ff_face *) a_server_font_data;
1732
1732
 
1735
1735
}
1736
1736
 
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)
1739
1739
{
1740
1740
    ff_face *face = (ff_face *) (server->ff.server_font_data);
1741
1741
    FT_Face ft_face = face->ft_face;
1761
1761
    0,
1762
1762
    false,
1763
1763
    {1, 0, 0, 1, 0, 0},
1764
 
    ensure_open,
1765
 
    get_scaled_font,
1766
 
    get_decodingID,
1767
 
    get_font_bbox,
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 */
1772
 
    get_fontmatrix,
1773
 
    get_char_width,
1774
 
    get_char_raster_metrics,
1775
 
    get_char_raster,
1776
 
    get_char_outline_metrics,
1777
 
    get_char_outline,
1778
 
    release_char_data,
1779
 
    release_typeface,
1780
 
    check_cmap_for_GID,
 
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 */
1782
1782
};
1783
1783