~ubuntu-branches/ubuntu/jaunty/xterm/jaunty

« back to all changes in this revision

Viewing changes to fontutils.c

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Kavanagh
  • Date: 2008-11-23 17:15:10 UTC
  • mfrom: (1.1.10 upstream) (11.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081123171510-fdwvfr4ytnfvjwjl
Tags: 237-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - Enabled URL hilighting
  - Maintainer field
  - rm -rf for .pc patches
* Closes (LP: #301451)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XTermId: fontutils.c,v 1.272 2008/04/17 23:23:37 tom Exp $ */
 
1
/* $XTermId: fontutils.c,v 1.275 2008/09/14 22:21:14 tom Exp $ */
2
2
 
3
3
/************************************************************
4
4
 
1335
1335
{
1336
1336
    static XPoint VTbox[NBOX];
1337
1337
    XPoint *vp;
 
1338
    int fw = FontWidth(screen) - 1;
 
1339
    int fh = FontHeight(screen) - 1;
 
1340
    int hh = screen->cursor_underline ? 1 : fh;
1338
1341
 
1339
1342
    vp = &VTbox[1];
1340
 
    (vp++)->x = FontWidth(screen) - 1;
1341
 
    (vp++)->y = FontHeight(screen) - 1;
1342
 
    (vp++)->x = -(FontWidth(screen) - 1);
1343
 
    vp->y = -(FontHeight(screen) - 1);
 
1343
    (vp++)->x = fw;
 
1344
    (vp++)->y = hh;
 
1345
    (vp++)->x = -fw;
 
1346
    vp->y = -hh;
 
1347
 
1344
1348
    screen->box = VTbox;
1345
1349
}
1346
1350
 
1668
1672
#endif /* OPT_RENDERWIDE */
1669
1673
        }
1670
1674
        if (norm == 0) {
 
1675
            TRACE(("...no TrueType font found for number %d, disable menu entry\n", fontnum));
1671
1676
            xw->misc.render_font = False;
1672
1677
            update_font_renderfont();
1673
1678
            /* now we will fall through into the bitmap fonts */
2325
2330
    }
2326
2331
}
2327
2332
 
 
2333
#if OPT_RENDERFONT
 
2334
#define NMENU_RENDERFONTS (NMENUFONTS - 2)      /* no selection or escape */
 
2335
static Boolean
 
2336
useFaceSizes(XtermWidget xw)
 
2337
{
 
2338
    Boolean result = False;
 
2339
    int n;
 
2340
 
 
2341
    if (UsingRenderFont(xw)) {
 
2342
        result = True;
 
2343
        for (n = 0; n < NMENU_RENDERFONTS; ++n) {
 
2344
            if (xw->misc.face_size[n] <= 0.0) {
 
2345
                result = False;
 
2346
                break;
 
2347
            }
 
2348
        }
 
2349
    }
 
2350
    return result;
 
2351
}
 
2352
#endif
 
2353
 
2328
2354
/*
2329
2355
 * Find the index of a larger/smaller font (according to the sign of 'relative'
2330
2356
 * and its magnitude), starting from the 'old' index.
2335
2361
    TScreen *screen = TScreenOf(xw);
2336
2362
    int n, m = -1;
2337
2363
 
 
2364
    TRACE(("lookupRelativeFontSize(old=%d, relative=%d)\n", old, relative));
2338
2365
    if (!IsIcon(screen)) {
2339
 
        lookupFontSizes(xw);
2340
 
        if (relative != 0) {
2341
 
            for (n = 0; n < NMENUFONTS; ++n) {
2342
 
                if (screen->menu_font_sizes[n] > 0 &&
2343
 
                    screen->menu_font_sizes[n] != screen->menu_font_sizes[old]) {
2344
 
                    int cmp_0 = ((screen->menu_font_sizes[n] >
2345
 
                                  screen->menu_font_sizes[old])
2346
 
                                 ? relative
2347
 
                                 : -relative);
2348
 
                    int cmp_m = ((m < 0)
2349
 
                                 ? 1
2350
 
                                 : ((screen->menu_font_sizes[n] <
2351
 
                                     screen->menu_font_sizes[m])
2352
 
                                    ? relative
2353
 
                                    : -relative));
2354
 
                    if (cmp_0 > 0 && cmp_m > 0) {
2355
 
                        m = n;
2356
 
                    }
2357
 
                }
2358
 
            }
2359
 
            if (m >= 0) {
2360
 
                if (relative > 1)
2361
 
                    m = lookupRelativeFontSize(xw, m, relative - 1);
2362
 
                else if (relative < -1)
2363
 
                    m = lookupRelativeFontSize(xw, m, relative + 1);
2364
 
            }
 
2366
#if OPT_RENDERFONT
 
2367
        if (useFaceSizes(xw)) {
 
2368
            TRACE(("...using FaceSize\n"));
 
2369
            if (relative != 0) {
 
2370
                for (n = 0; n < NMENU_RENDERFONTS; ++n) {
 
2371
                    if (xw->misc.face_size[n] > 0 &&
 
2372
                        xw->misc.face_size[n] != xw->misc.face_size[old]) {
 
2373
                        int cmp_0 = ((xw->misc.face_size[n] >
 
2374
                                      xw->misc.face_size[old])
 
2375
                                     ? relative
 
2376
                                     : -relative);
 
2377
                        int cmp_m = ((m < 0)
 
2378
                                     ? 1
 
2379
                                     : ((xw->misc.face_size[n] <
 
2380
                                         xw->misc.face_size[m])
 
2381
                                        ? relative
 
2382
                                        : -relative));
 
2383
                        if (cmp_0 > 0 && cmp_m > 0) {
 
2384
                            m = n;
 
2385
                        }
 
2386
                    }
 
2387
                }
 
2388
            }
 
2389
        } else
 
2390
#endif
 
2391
        {
 
2392
            TRACE(("...using bitmap areas\n"));
 
2393
            lookupFontSizes(xw);
 
2394
            if (relative != 0) {
 
2395
                for (n = 0; n < NMENUFONTS; ++n) {
 
2396
                    if (screen->menu_font_sizes[n] > 0 &&
 
2397
                        screen->menu_font_sizes[n] !=
 
2398
                        screen->menu_font_sizes[old]) {
 
2399
                        int cmp_0 = ((screen->menu_font_sizes[n] >
 
2400
                                      screen->menu_font_sizes[old])
 
2401
                                     ? relative
 
2402
                                     : -relative);
 
2403
                        int cmp_m = ((m < 0)
 
2404
                                     ? 1
 
2405
                                     : ((screen->menu_font_sizes[n] <
 
2406
                                         screen->menu_font_sizes[m])
 
2407
                                        ? relative
 
2408
                                        : -relative));
 
2409
                        if (cmp_0 > 0 && cmp_m > 0) {
 
2410
                            m = n;
 
2411
                        }
 
2412
                    }
 
2413
                }
 
2414
            }
 
2415
        }
 
2416
        TRACE(("...new index %d\n", m));
 
2417
        if (m >= 0) {
 
2418
            if (relative > 1)
 
2419
                m = lookupRelativeFontSize(xw, m, relative - 1);
 
2420
            else if (relative < -1)
 
2421
                m = lookupRelativeFontSize(xw, m, relative + 1);
2365
2422
        }
2366
2423
    }
2367
2424
    return m;