File: glyphMgr.cpp

package info (click to toggle)
lasi 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,420 kB
  • ctags: 1,269
  • sloc: cpp: 1,049; makefile: 13
file content (67 lines) | stat: -rw-r--r-- 1,715 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/** @file
 * libLASi provides a C++ output stream interface for writing 
 * multi-language Postscript documents.
 * Copyright (C) 2003, 2004  Larry Siden.
 * See README file in project root directory for copyright and contact info.
 * See COPYING file in project root for terms of re-distribution.
 */

#include <stdexcept>

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H

#include <cassert>
#include "util.h"
#include "glyphMgr.h"

using namespace std;

/** Manage FT_Glyph by insuring that resources are freed when done.
 */
FreetypeGlyphMgr::FreetypeGlyphMgr() : _glyph((FT_Glyph)0) {
  _glyph = (FT_Glyph)0;
}

FreetypeGlyphMgr::FreetypeGlyphMgr(FT_Glyph glyph) : _glyph(_glyph) {}

FreetypeGlyphMgr::FreetypeGlyphMgr(const FreetypeGlyphMgr& ftgm) {
  //evalReturnCode(FT_Glyph_Copy(ftgm._glyph, &_glyph), "FT_Glyph_Copy() in FreetypeGlyphMgr(const FreetypeGlyphMgr& ftgm)");
  if (ftgm._glyph) {
    int return_code = FT_Glyph_Copy(ftgm._glyph, &_glyph);
    assert(0 == return_code);
  }
  else
    _glyph = 0;
}

FreetypeGlyphMgr& FreetypeGlyphMgr::operator=(const FreetypeGlyphMgr& ftgm) {
  if (this != &ftgm) {
    if (_glyph) {
      FT_Done_Glyph(_glyph);
    }
    //evalReturnCode(FT_Glyph_Copy(ftgm._glyph, &_glyph), "FT_Glyph_Copy() in operator=(const FreetypeGlyphMgr& ftgm)");
    if (ftgm._glyph) {
      int return_code = FT_Glyph_Copy(ftgm._glyph, &_glyph);
      assert(0 == return_code);
    }
    else
      _glyph = 0;
  }
  return *this;
}

FreetypeGlyphMgr::~FreetypeGlyphMgr() {
  if (_glyph) {
    FT_Done_Glyph(_glyph);
  }
}

FreetypeGlyphMgr::operator FT_Glyph() const {
  return _glyph;
}

void FreetypeGlyphMgr::assign(const FT_Glyph glyph) {
  _glyph = glyph;
}