[<<][math][>>][..]
Mon May 11 18:11:07 CEST 2009

Computer Modern is Too Thin

Not really so math-y but I have no other place for it..

Something that has been bugging me ever since I used LateX for the
first time (1998?) is that Computer Modern is a very thin font.
Looking around the web, I've found several people complaining about
this.

On paper this problem isn't as pronounced because resolution is high
enough, and black is black.  But on screen, thin lines turns grey, and
that is really annoying.  It's easier to read black blobs than grey
ones.  On blurry low-quality paper, ink doesn't turn to grey either.

So, how to fix this?

The simplest way to fatten up a font is to use erosion (replace pixel
with minimal pixel value in a 3x3 square).  Alternatively, blur
followed by increased contrast will also work.

So, why doesn't ink on paper turn grey when it spills out a bit?  The
reason is probably that what is diffused is pigment (amount of
absorption or negative color) and not light intensity.  Even with
pigment diluted, black is still very black.


Code:


#include <stdlib.h>
#include <stdio.h>

int min (int a, int b) {
    return (a < b) ? a : b;
}

int main(int argc, char **argv) {
    int w=0,h=0,d=0;
    size_t size = w*h;
    unsigned char *buf;
    unsigned char *obuf;
    int l,c;
  again:
    if (3 != fscanf(stdin, "P5\n%d %d\n%d\n", &w, &h, &d)) exit(0);
    printf("P5\n%d %d\n%d\n", w, h, d);
    size = w*h;
    buf = malloc(size);
    obuf = malloc(size);
    fread(buf, 1, size, stdin);

    for (l = 1; l < h-1; l++) {
        int line = l * w;
        for (c = 1; c < w-1; c++) {
            int l1 = buf[(line-w) + (c-1)];
            int l2 = buf[(line-w) + (c)];
            int l3 = buf[(line-w) + (c+1)];
            int l4 = buf[(line)   + (c-1)];
            int l5 = buf[(line)   + (c)];
            int l6 = buf[(line)   + (c+1)];
            int l7 = buf[(line+w) + (c-1)];
            int l8 = buf[(line+w) + (c)];
            int l9 = buf[(line+w) + (c+1)];

            obuf[line + c] = 
                min(min(min(min(l1,l2),
                            min(l3,l4)),
                        min(min(l5,l6),
                            min(l7,l8))),
                    l9);
        }
    }

    fwrite(obuf, 1, size, stdout);
    fflush(stdout);
    free(buf);
    free(obuf);
    goto again;

    return 0;
}


Let this operate on images generated by "pdftoppm -gray -r 300" before
passing it to a DJVU converter.  Don't do this on lower rez.







[Reply][About]
[<<][math][>>][..]