Back to index

texmacs  1.0.7.15
bitmap_font.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : bitmap_font.cpp
00004 * DESCRIPTION: bitmap fonts
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include "bitmap_font.hpp"
00013 
00014 RESOURCE_CODE(font_metric);
00015 RESOURCE_CODE(font_glyphs);
00016 
00017 /******************************************************************************
00018 * font_metrics
00019 ******************************************************************************/
00020 
00021 font_metric_rep::font_metric_rep (string name):
00022   rep<font_metric> (name), bad_font_metric (false) {}
00023 
00024 font_metric_rep::~font_metric_rep () {
00025   FAILED ("not yet implemented"); }
00026 
00027 /******************************************************************************
00028 * Standard bitmap metrics
00029 ******************************************************************************/
00030 
00031 static metric error_metric;
00032 
00033 struct std_font_metric_rep: public font_metric_rep {
00034   int bc, ec;
00035   metric* fnm;
00036 
00037   std_font_metric_rep (string name, metric* fnm, int bc, int ec);
00038   metric& get (int char_code);
00039 };
00040 
00041 std_font_metric_rep::std_font_metric_rep (
00042   string name, metric* fnm2, int bc2, int ec2):
00043     font_metric_rep (name), bc (bc2), ec (ec2), fnm (fnm2)
00044 {
00045   error_metric->x1= error_metric->y1= 0;
00046   error_metric->x2= error_metric->y2= 0;
00047   error_metric->x3= error_metric->y3= 0;
00048   error_metric->x4= error_metric->y4= 0;
00049 }
00050 
00051 metric&
00052 std_font_metric_rep::get (int c) {
00053   if ((c<bc) || (c>ec)) return error_metric;
00054   return fnm [c-bc];
00055 }
00056 
00057 font_metric
00058 std_font_metric (string name, metric* fnm, int bc, int ec) {
00059   return make (font_metric, name,
00060               tm_new<std_font_metric_rep> (name, fnm, bc, ec));
00061 }
00062 
00063 /******************************************************************************
00064 * font_glyphs
00065 ******************************************************************************/
00066 
00067 font_glyphs_rep::font_glyphs_rep (string name):
00068   rep<font_glyphs> (name), bad_font_glyphs (false) {}
00069 
00070 font_glyphs_rep::~font_glyphs_rep () {
00071   FAILED ("not yet implemented"); }
00072 
00073 /******************************************************************************
00074 * Standard bitmap fonts
00075 ******************************************************************************/
00076 
00077 static glyph error_glyph;
00078 
00079 struct std_font_glyphs_rep: public font_glyphs_rep {
00080   int bc, ec;
00081   glyph* fng; // definitions of the characters
00082 
00083   std_font_glyphs_rep (string name, glyph* fng, int bc, int ec);
00084   glyph& get (int char_code);
00085 };
00086 
00087 std_font_glyphs_rep::std_font_glyphs_rep (
00088   string name, glyph* fng2, int bc2, int ec2):
00089     font_glyphs_rep (name), bc (bc2), ec (ec2), fng (fng2) {}
00090 
00091 glyph&
00092 std_font_glyphs_rep::get (int c) {
00093   if ((c<bc) || (c>ec)) return error_glyph;
00094   return fng [c-bc];
00095 }
00096 
00097 font_glyphs
00098 std_font_glyphs (string name, glyph* fng, int bc, int ec) {
00099   return make (font_glyphs, name, tm_new<std_font_glyphs_rep> (name, fng, bc, ec));
00100 }