00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 static const char docstring[] =
00011 "text_on_image_font_helper: render characters of a font for use later\n"
00012 "\n"
00013 " [bm,cpos] = text_on_image_font_helper(fontfile, dict, height, width)\n"
00014 " * Renders a set of characters, dict, into a 3d stack of bitmaps bm,\n"
00015 " using a given TrueType font file, and a given height and width.\n"
00016 " The per-character positions (start and end) are given in cpos.\n"
00017 " * The font file name is given in `fontfile'. Reasonable\n"
00018 " truetype (.ttf) files work, and some truetype collections (.ttc/.ttfc)\n"
00019 " work. Some truetype collections (e.g., Apple's Menlo) do not work.\n"
00020 " However, ordinary .ttf files can be extracted from .ttc's.\n"
00021 " * The list of characters to convert is given in `dict'.\n"
00022 " * The dimensions of each output character are the same (which might\n"
00023 " be undesirable sometimes). This can be addressed using the wid output.\n"
00024 " * The height argument is in this format:\n"
00025 " [char_height allow_space_for_descenders top_pad bottom_pad]\n"
00026 " char_height is in pixels. By default, the highest ascender and lowest\n"
00027 " descender in the font fit into char_height. If allow_space_for_descenders\n"
00028 " is false, room is made for ascenders only, which is useful for, e.g.,\n"
00029 " maximizing compactness in digit-only text. The last two entries give\n"
00030 " top and bottom padding, respectively. They can be negative, which\n"
00031 " is helpful if, for example, too much space is being left for\n"
00032 " ascenders.\n"
00033 " * The width of each bitmap is enough to accommodate the character\n"
00034 " width(1) (which is an integer value supplied as a double, but\n"
00035 " representing a unicode character). Additionally, extra padding\n"
00036 " to the left and right can be given in width(2) and width(3), which\n"
00037 " can again be negative to soak up extra space.\n"
00038 " * The default height is 32 pixels, accommodating both ascenders\n"
00039 " and descenders, and no extra padding. The height entries can be\n"
00040 " cut off at any point, so [], [32], [32 1], [32 1 -1], and [32 1 -1 -2]\n"
00041 " are all legal inputs.\n"
00042 " * The default character-width is that of `0', and no extra padding.\n"
00043 " As with height, the entries may be cut off at any point.\n"
00044 " * The bitmap is in raster scan order (left -> right, top -> bottom).\n"
00045 " To display in matlab, use image(bm(:,:,nchar)').\n"
00046 " * The character positions can be used to extract the original character\n"
00047 " bitmap within the TrueType font from its embedding into a standard-size\n"
00048 " bitmap. It is offset by 1 and clipped to the valid range, so you can\n"
00049 " use: bm(cpos(1,nchar):cpos(2,nchar),:,nchar).\n"
00050 "\n"
00051 " Inputs:\n"
00052 " string font\n"
00053 " string dict(n)\n"
00054 " opt int height(0, 1, 2, 3, or 4) = [32 1 0 0]\n"
00055 " opt int width(0, 1, 2, or 3) = [double('0') 0 0]\n"
00056 "\n"
00057 " Outputs:\n"
00058 " uint8 bm(wd,ht,n)\n"
00059 " opt real cpos(2,n)\n"
00060 "\n"
00061 " See Also: text_on_image\n"
00062 "\n"
00063 "";
00064
00065
00066