PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/TeXmacs-1.0.7.11-src/src/Graphics/Bitmap_fonts/bitmap_font.cpp

#
C++ | 100 lines | 56 code | 23 blank | 21 comment | 4 complexity | bd21db06375ebdf3d561fa67645b0383 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception
  1. /******************************************************************************
  2. * MODULE : bitmap_font.cpp
  3. * DESCRIPTION: bitmap fonts
  4. * COPYRIGHT : (C) 1999 Joris van der Hoeven
  5. *******************************************************************************
  6. * This software falls under the GNU general public license version 3 or later.
  7. * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
  8. * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
  9. ******************************************************************************/
  10. #include "bitmap_font.hpp"
  11. RESOURCE_CODE(font_metric);
  12. RESOURCE_CODE(font_glyphs);
  13. /******************************************************************************
  14. * font_metrics
  15. ******************************************************************************/
  16. font_metric_rep::font_metric_rep (string name):
  17. rep<font_metric> (name), bad_font_metric (false) {}
  18. font_metric_rep::~font_metric_rep () {
  19. FAILED ("not yet implemented"); }
  20. /******************************************************************************
  21. * Standard bitmap metrics
  22. ******************************************************************************/
  23. static metric error_metric;
  24. struct std_font_metric_rep: public font_metric_rep {
  25. int bc, ec;
  26. metric* fnm;
  27. std_font_metric_rep (string name, metric* fnm, int bc, int ec);
  28. metric& get (int char_code);
  29. };
  30. std_font_metric_rep::std_font_metric_rep (
  31. string name, metric* fnm2, int bc2, int ec2):
  32. font_metric_rep (name), bc (bc2), ec (ec2), fnm (fnm2)
  33. {
  34. error_metric->x1= error_metric->y1= 0;
  35. error_metric->x2= error_metric->y2= 0;
  36. error_metric->x3= error_metric->y3= 0;
  37. error_metric->x4= error_metric->y4= 0;
  38. }
  39. metric&
  40. std_font_metric_rep::get (int c) {
  41. if ((c<bc) || (c>ec)) return error_metric;
  42. return fnm [c-bc];
  43. }
  44. font_metric
  45. std_font_metric (string name, metric* fnm, int bc, int ec) {
  46. return make (font_metric, name,
  47. tm_new<std_font_metric_rep> (name, fnm, bc, ec));
  48. }
  49. /******************************************************************************
  50. * font_glyphs
  51. ******************************************************************************/
  52. font_glyphs_rep::font_glyphs_rep (string name):
  53. rep<font_glyphs> (name), bad_font_glyphs (false) {}
  54. font_glyphs_rep::~font_glyphs_rep () {
  55. FAILED ("not yet implemented"); }
  56. /******************************************************************************
  57. * Standard bitmap fonts
  58. ******************************************************************************/
  59. static glyph error_glyph;
  60. struct std_font_glyphs_rep: public font_glyphs_rep {
  61. int bc, ec;
  62. glyph* fng; // definitions of the characters
  63. std_font_glyphs_rep (string name, glyph* fng, int bc, int ec);
  64. glyph& get (int char_code);
  65. };
  66. std_font_glyphs_rep::std_font_glyphs_rep (
  67. string name, glyph* fng2, int bc2, int ec2):
  68. font_glyphs_rep (name), bc (bc2), ec (ec2), fng (fng2) {}
  69. glyph&
  70. std_font_glyphs_rep::get (int c) {
  71. if ((c<bc) || (c>ec)) return error_glyph;
  72. return fng [c-bc];
  73. }
  74. font_glyphs
  75. std_font_glyphs (string name, glyph* fng, int bc, int ec) {
  76. return make (font_glyphs, name, tm_new<std_font_glyphs_rep> (name, fng, bc, ec));
  77. }