InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IFontInstance.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Eric Menninga
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // See the implementation CTPFontInstance.cpp and refer to the CoolType
24 // documentation for more information
25 //
26 //========================================================================================
27 
28 #ifndef __IFontInstance__
29 #define __IFontInstance__
30 
31 #include "GRRefCountedObj.h"
32 #include "InterfacePtr.h"
33 #include "IFontMgr.h" // for IFontMgr::WritingDirection
34 #include "CTextEnum.h" // for Text::GlyphID, etc
35 
36 class WideString;
37 class PMString;
38 class CTFontInst;
39 class PMMatrix;
40 class IOutlineInfo;
41 class PMRealGlyphPoint;
42 
47 {
48  public:
54  virtual Text::GlyphID GetGlyphID(UTF32TextChar charCode) const = 0;
55 
61  virtual void GetGlyphIDs(const WideString& textString, K2Vector<Text::GlyphID>& glyphIDs) const = 0;
62 
69  virtual void AppendGlyphIDs(const UTF16TextChar* buffer, int32 bufSize, K2Vector<Text::GlyphID>& glyphIDs) const = 0;
70 
79  virtual int32 FillOutGlyphIDs(PMRealGlyphPoint *glyphPoints, int32 numGlyphs, const UTF16TextChar* textchars, int32 bufSize) const = 0;
80 
85  virtual Text::GlyphID GetNotDefinedGlyph() const = 0;
86 
103  virtual PMReal GetGlyphWidth(Text::GlyphID glyphID) const = 0;
104 
120  virtual void GetWidths(PMRealGlyphPoint *glyphPoints, int32 numGlyphs) const = 0;
121 
127  virtual PMRect GetGlyphBBox(Text::GlyphID glyphID) const = 0;
128 
136  virtual void MeasureWText(const UTF16TextChar* text, int32 utf16BufferLength, PMReal& xWidth, PMReal* yHeight = nil) const = 0;
143  virtual void MeasureWText(const WideString& string, PMReal& xWidth, PMReal* yHeight = nil) const = 0;
144 
151  virtual void MeasureWText(const PMString& string, PMReal& xWidth, PMReal* yHeight = nil) const = 0;
152 
158  virtual bool16 HasKerningTable() const = 0;
159 
168  virtual void GetKerns(PMRealGlyphPoint *glyphPoints, int32 numGlyphs, bool16 vertical = kFalse, const char* scriptTag = nil, const char* langTag = nil) const = 0;
169 
185  enum { kNormalOutlines = 0,
186  kHintedOutlines = 1,
187  kVerticalOutlines = 2,
188  kVerticalGlyphs = 4 } ;
189 
199  virtual void GetOutlineInfo(IOutlineInfo *callBack, Text::GlyphID glyphID, PMReal xOffset, PMReal yOffset, int32 flags = kNormalOutlines) const = 0;
200 
204  virtual PMReal GetAscent() const = 0;
205 
209  virtual PMReal GetDescent() const = 0;
210 
214  virtual PMReal GetCapHeight() const = 0;
215 
219  virtual PMReal GetXHeight() const = 0;
220 
246  virtual PMReal GetEmBoxHeight() const = 0;
247 
264  virtual void GetICFBoxInsets(PMReal * fromEmTop, PMReal * fromEmBottom) const = 0;
265 
273  virtual PMReal GetHorizEmBoxDepth() const = 0;
274 
283  virtual PMReal GetHorizICFBoxDepth() const = 0;
284 
287  virtual CTFontInst* GetCTFontInst() const = 0;
288 
291  virtual CTFontDict* GetParentCTFontDict() const = 0;
292 
299  virtual void GetDesignVector(PMReal* designVec, size_t& designVecLen) const = 0;
300 
304  virtual size_t GetNumDesignAxes() const = 0;
305 
308  virtual const PMMatrix& GetPMMatrix() const = 0;
309 
312  virtual IFontMgr::WritingDirection GetWritingDirection() const = 0;
313 
320  kApplyGlyphSub = 1 << 0,
322  kApplyGlyphPos = 1 << 1,
325 // /** This flag is not used by ApplyFeatures. */
326 // kReportOriginalIndices = 1 << 2,
333  kRightToLeft = 1<<3,
334  kCTFlagsBitMask = 0x0F,
335 
336  kModifyWidthsInPlace = 1 << 5
337  };
338 
343  enum {
344  kNoChange = 0, //kCTOTNoChange
345 // kSingleSubstitute = 1<<0, // kCTOTSingleSubstitute
346 // kMultiSubstitute = 1<<1, // kCTOTMultiSubstitute
347 // kAlternate = 1<<3, // kCTOTAlternate
348  kLigatureApplied = 1<<4, //kCTOTLigature
349  kGlyphDeleted = 1<<5, //kCTOTDeleted
350 // kRepositioned = 1<<6 //kCTOTRepositioned
351  };
352 
456  virtual bool16 ApplyFeatures(PMRealGlyphPoint* glyphPoints, size_t& numGlyphPoints, size_t &numGlyphPointsAvail,
457  int32 numFeatures, const char* features, const int32* choiceIndices,
458  const size_t *featureRanges, char* changeAttrib, FeatureInfoFlags flags,
459  PMReal* penPos = nil, PMReal* caretPositions = nil,
460  const char* scriptTag = nil, const char* langTag = nil) const = 0;
461 
462 
466  virtual CTFontInstance* GetCTFontInstance() const = 0;
467 
475  virtual bool16 GermanLocaleDropsLigatures() const = 0;
476 
477 };
478 
479 
480 template <>
482 {
483 public:
484  // Note: Constructing an InterfacePtr from an existing,
485  // "real" interface pointer implies the InterfacePtr
486  // now owns the reference that was held by the real pointer.
487  InterfacePtr(IFontInstance * pFace)
488  : fFace(pFace) {}
489 
490  ~InterfacePtr()
491  { Release_(fFace); }
492 
493  InterfacePtr(void) : fFace(nil)
494  {}
495 
496  InterfacePtr(const InterfacePtr<IFontInstance>& o) : fFace(AddRef_(o.get()))
497  {}
498 
500  { if (&p != this) reset(AddRef_(p.get())); return *this; }
501 
502  operator IFontInstance*() const
503  { return fFace; }
504  // We allow the cast operator to return a nil pointer
505  // since it is valid to test against nil and may be valid
506  // to pass a nil pointer to some methods.
507 
508  IFontInstance * operator ->() const
509  {
510  #ifdef DEBUG
511  ASSERT_MSG(fFace != nil,"About to use nil interface ptr!");
512  #endif
513  return fFace;
514  }
515 
516  // Added forget, get and reset from InterfacePtr
518  {
519  IFontInstance* result = fFace;
520  fFace = 0;
521  return result;
522  }
523 
524  IFontInstance* get() const
525  { return fFace; }
526 
527  void reset(IFontInstance* p = 0)
528  {
529  Release_(fFace);
530  fFace = p;
531  }
532 
533  void reset(const IFontInstance* p)
534  {
535  Release_(fFace);
536  fFace = const_cast<IFontInstance*>(p);
537  }
538 
539 private:
540  static IFontInstance* AddRef_(const IFontInstance* p)
541  { if (p) p->AddRef(); return const_cast<IFontInstance*>(p);}
542  static void Release_(IFontInstance* p)
543  { if (p) p->Release(); }
544 
545 
546  IFontInstance * fFace;
547 };
548 #endif
549