Ejemplo n.º 1
0
void ffw_get_metric(double * ascent, double * descent)
{
    SplineFont * sf = cur_fv->sf;

    DBounds bb;
    SplineFontFindBounds(sf, &bb);

    int em = sf->ascent + sf->descent;

    if (em > 0)
    {
        *ascent = ((double)bb.maxy) / em;
        *descent = ((double)bb.miny) / em;
    }
    else
    {
        *ascent = *descent = 0;
    }
}
Ejemplo n.º 2
0
void ffw_metric(double * ascent, double * descent)
{
    SplineFont * sf = cur_fv->sf;
    struct pfminfo * info = &sf->pfminfo;

    SFDefaultOS2Info(info, sf, sf->fontname);
    info->pfmset = 1;
    sf->changed = 1;

    DBounds bb;
    SplineFontFindBounds(sf, &bb);

    /*
    printf("bb %lf %lf\n", bb.maxy, bb.miny);
    printf("_ %d %d\n", sf->ascent, sf->descent);
    printf("win %d %d\n", info->os2_winascent, info->os2_windescent);
    printf("%d %d\n", info->winascent_add, info->windescent_add);
    printf("typo %d %d\n", info->os2_typoascent, info->os2_typodescent);
    printf("%d %d\n", info->typoascent_add, info->typodescent_add);
    printf("hhead %d %d\n", info->hhead_ascent, info->hhead_descent);
    printf("%d %d\n", info->hheadascent_add, info->hheaddescent_add);
    */

    int em = sf->ascent + sf->descent;

    if (em > 0)
    {
        *ascent = ((double)bb.maxy) / em;
        *descent = ((double)bb.miny) / em;
    }
    else
    {
        *ascent = *descent = 0;
    }

    int a = floor(bb.maxy + 0.5);
    int d = floor(bb.miny + 0.5);
    
    if(a < 0) a = 0;
    if(d > 0) d = 0;

    /*
    sf->ascent = min(a, em);
    sf->descent = em - bb.maxy;
    */

    info->os2_winascent = a;
    info->os2_typoascent = a;
    info->hhead_ascent = a;
    info->winascent_add = 0;
    info->typoascent_add = 0;
    info->hheadascent_add = 0;

    info->os2_windescent = -d;
    info->os2_typodescent = d;
    info->hhead_descent = d;
    info->windescent_add = 0;
    info->typodescent_add = 0;
    info->hheaddescent_add = 0;

    info->os2_typolinegap = 0;
    info->linegap = 0;
}
Ejemplo n.º 3
0
void ffw_metric(double * ascent, double * descent)
{
    SplineFont * sf = cur_fv->sf;
    struct pfminfo * info = &sf->pfminfo;

    SFDefaultOS2Info(info, sf, sf->fontname);
    info->pfmset = 1;
    sf->changed = 1;

    DBounds bb;
    SplineFontFindBounds(sf, &bb);

    /*
    printf("bb %lf %lf\n", bb.maxy, bb.miny);
    printf("_ %d %d\n", sf->ascent, sf->descent);
    printf("win %d %d\n", info->os2_winascent, info->os2_windescent);
    printf("%d %d\n", info->winascent_add, info->windescent_add);
    printf("typo %d %d\n", info->os2_typoascent, info->os2_typodescent);
    printf("%d %d\n", info->typoascent_add, info->typodescent_add);
    printf("hhead %d %d\n", info->hhead_ascent, info->hhead_descent);
    printf("%d %d\n", info->hheadascent_add, info->hheaddescent_add);
    */

    int em = sf->ascent + sf->descent;

    if (em > 0)
    {
        *ascent = ((double)bb.maxy) / em;
        *descent = ((double)bb.miny) / em;
    }
    else
    {
        *ascent = *descent = 0;
    }

    int a = floor(bb.maxy + 0.5);
    int d = floor(bb.miny + 0.5);
    
    if(a < 0) a = 0;
    if(d > 0) d = 0;

    /*
    sf->ascent = min(a, em);
    sf->descent = em - bb.maxy;
    */

    /*
     * The embedded fonts are likely to have inconsistent values for the 3 sets of ascent/descent
     * PDF viewers don't care, since they don't even use these values
     * But have to unify them, for different browsers on different platforms
     * Things may become easier when there are CSS rules for baseline-based positioning.
     */

    info->os2_winascent = a;
    info->os2_typoascent = a;
    info->hhead_ascent = a;
    info->winascent_add = 0;
    info->typoascent_add = 0;
    info->hheadascent_add = 0;

    info->os2_windescent = -d;
    info->os2_typodescent = d;
    info->hhead_descent = d;
    info->windescent_add = 0;
    info->typodescent_add = 0;
    info->hheaddescent_add = 0;

    info->os2_typolinegap = 0;
    info->linegap = 0;
}