opennurbs_internal_glyph.h
1 /*
2 //
3 // Copyright (c) 1993-2017 Robert McNeel & Associates. All rights reserved.
4 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
5 // McNeel & Associates.
6 //
7 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
10 //
11 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
12 //
13 ////////////////////////////////////////////////////////////////
14 */
15 #if !defined(OPENNURBS_INTERNAL_GLYPH_INC_)
16 #define OPENNURBS_INTERNAL_GLYPH_INC_
17 
19 {
20 private:
21  friend class ON_FontGlyph;
22  friend class ON_GlyphMap;
24  ~ON_Internal_FontGlyphPool() = default;
26  ON_Internal_FontGlyphPool operator=(const ON_Internal_FontGlyphPool&) = delete;
27  static ON_Internal_FontGlyphPool theGlyphItemPool;
28 };
29 
31 {
32 public:
33  // List is the only instance of this class.
35 
36  const ON_Font* GetFromFontCharacteristics(
37  const ON_Font& font_characteristics,
38  bool bCreateIfNotFound
39  );
40 
41  const ON_Font* GetFromAppleFontName(
42  const wchar_t* apple_font_name,
43  bool bCreateIfNotFound
44  );
45 
46  const ON_Font* GetFromSerialNumber(
47  unsigned int managed_font_runtime_serial_number
48  );
49 
50  unsigned int GetList(
52  );
53 
54  /*
55  Returns:
56  0: failure
57  >0: success font glyph id
58  */
59  static ON__UINT_PTR GetGlyphMetrics(
60  const class ON_Font* font,
61  ON__UINT32 unicode_code_point,
62  class ON_TextBox& font_unit_glyph_box
63  );
64 
65  static void GetFontMetrics(
66  const ON_Font* font,
67  ON_FontMetrics& font_unit_font_metrics
68  );
69 
70 private:
71  ON_ManagedFonts() = default;
72  ~ON_ManagedFonts();
73 
74  const ON_Font* Internal_AddManagedFont(
75  const ON_Font* managed_font
76  );
77 
78 private:
79  ON_SimpleArray<const ON_Font*> m_managed_fonts;
80  ON_SimpleArray<const ON_Font*> m_managed_fonts_by_serial_number;
81  unsigned int m_sorted_count = 0;
82  unsigned int m_sorted_by_serial_number_count = 0;
83 };
84 
85 class ON_CLASS ON_GlyphMap
86 {
87 public:
88  ON_GlyphMap();
89  ~ON_GlyphMap() = default;
90 
91 public:
92  const class ON_FontGlyph* FindGlyph(
93  const ON__UINT32 unicode_code_point
94  ) const;
95 
96  // returns pointer to the persistent glyph item
97  const ON_FontGlyph* InsertGlyph(
98  const ON_FontGlyph& glyph
99  );
100 
101  unsigned int GlyphCount() const;
102 
103 private:
104  friend class ON_Font;
105  friend class ON_FontGlyph;
106  unsigned int m_glyph_count = 0;
107  unsigned int m_reserved = 0;
109 };
110 
111 #endif
Definition: opennurbs_font.h:1958
static ON_ManagedFonts List
List is the only instance of this class.
Definition: opennurbs_internal_glyph.h:34
Definition: opennurbs_array.h:36
Definition: opennurbs_internal_glyph.h:30
Definition: opennurbs_fsp.h:19
Definition: opennurbs_internal_glyph.h:18
Definition: opennurbs_font.h:2081
Definition: opennurbs_font.h:18
Definition: opennurbs_internal_glyph.h:84
An ON_Font is a face in a font family. It corresponds to a Windows LOGFONT, a .NET System...
Definition: opennurbs_font.h:225
friend class ON_GlyphMap
Definition: opennurbs_internal_glyph.h:22