InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IPMFont.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: emenning
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 CTPFont.cpp and refer to the CoolType documentation for more information
24 //
25 //========================================================================================
26 
27 #ifndef __IFont__
28 #define __IFont__
29 
30 #include "GRRefCountedObj.h"
31 #include "CTextEnum.h"
32 #include "InterfacePtr.h"
33 #include "IFontMgr.h"
34 #include "IDFile.h" // for GetFontFiles()
35 #include "K2Vector.h"
36 #include "OTFeature.h"
37 #include <string> // for GetGlyphName()
38 
39 class KinsokuCharType;
40 class PMString;
41 class PMRect;
42 class WideString;
43 typedef int16 MojikumiClass;
44 class PMRealGlyphPoint;
45 
46 #define kDefaultScriptTag "DFLT"
47 #define kDefaultLanguageTag "dflt"
48 
55 {
56 public:
57  typedef object_type data_type;
58 
60 
64  int32 fDesiredTag;
65 
71  bool16 fFoundNonAALT;
76 };
77 
78 
84 class IPMFont : public grRefCountedObj
85 {
86  protected:
87  ~IPMFont(){} // you should not call delete on an IPMFont*. You should call Release()!
88  public:
89 
90  /*
91  This enum should not be used any more as from indesign 2019 onwards as we will be supporting variable fonts, so we will ask the font, for its number of design axes and make a dynamic allocation accordingly.
92  */
93  enum { kMaxDesignVectorSize = 5 };
94 
95 
100  virtual CTFontDict* GetCTFontDict() const = 0;
101 
106  virtual std::string GetPostScriptName() const = 0;
107 
108  // appends the name specified to the string passed in. Most useful
109  // format for menus. Also minimizes copying, memory allocations, etc.
110 
115  virtual void AppendFullName(PMString& s) const = 0;
116 
121  virtual void AppendFullNameNative(PMString& s) const = 0;
122 
126  virtual void AppendFamilyName(PMString& s) const = 0;
127 
131  virtual void AppendFamilyNameNative(PMString& s) const = 0;
132 
136  virtual void AppendStyleName(PMString& s) const = 0;
137 
141  virtual void AppendStyleNameNative(PMString& s) const = 0;
142 
149  virtual void AppendFontName(PMString& s, bool16 originalNameWhenMissing = kFalse) const = 0;
150 
151 
152  // multiple master font stuff
158  virtual int32 GetNumDesignAxes() const = 0;
166  virtual void AppendNthDesignAxisName(int32 index, PMString& s) const = 0;
174  virtual void GetNthDesignAxisLimits(int32 index, Fixed *min, Fixed *max) const = 0;
180  virtual Fixed* AccessDesignVector() = 0;
186  virtual const Fixed* AccessDesignVector() const = 0;
187 
195  virtual int32 FillOutMMInstances(Fixed *array, int32 *numberFit) const = 0;
202  virtual void AppendMMInstanceName(int32 which, PMString& s) const = 0;
203 
204 
205  // miscellaneous stuff
213  virtual PMRect GetFontBBox() const = 0;
219  virtual Text::GlyphID GetNotDefinedGlyph() const = 0;
220 
225  virtual int32 GetNumGlyphs() const = 0;
226 
233  virtual bool16 UsesStandardEncoding() const = 0;
234 
241  virtual int32 GetWritingScript() const = 0;
242 
250  virtual bool16 AppendVersion(PMString& s) const = 0;
251 
257  virtual K2Vector<PMString>* GetFullPath() const = 0;
258 
266  kInvalid = 0,
268  kNormal,
293  } ;
294 
300  virtual K2Vector<FontProtection>* GetProtection() const = 0;
301 
307  typedef enum {
309  kFontInstalled = 0x01,
311  kFontNotAvailable = 0x10,
313  kFontFauxed = 0x11,
315  kFontSubstituted = 0x12,
317  kFontUnknown = 0xFF
318  } FontStatus;
319 
336 
339  };
340 
346  typedef enum {
365 
368  } FontType;
369 
375  virtual FontStatus GetFontStatus() const = 0;
381  virtual FontTechnology GetFontTechnology() const = 0;
382 
388  virtual IPMFont::FontTechnology GetGlyphTechnology(Text::GlyphID glyphID) const = 0;
389 
395  virtual FontType GetFontType() const = 0;
396 
400  virtual IFontMgr::FontStyleBits GetFontStyle() const = 0;
401 
402 #ifdef WINDOWS
403 
413  virtual bool16 GetWindowsLogFont(LOGFONT *logfont) const = 0;
414 #endif
415 
422  virtual PMReal GetAscent(PMReal pointsize) const = 0;
429  virtual PMReal GetDescent(PMReal pointsize) const = 0;
437  virtual PMReal GetCapHeight(PMReal pointsize) const = 0;
445  virtual PMReal GetXHeight(PMReal pointsize) const = 0;
446 
454  virtual PMReal GetEmBoxHeight(PMReal pointsize, bool16 vertical) const = 0;
463  virtual void GetICFBoxInsets(PMReal pointsize, PMReal * fromLineTop, PMReal * fromLineBottom, bool16 vertical) const = 0;
464 
473  virtual PMRect GetEmBox() const = 0;
483  virtual PMRect GetICFBox() const = 0;
484 
485  typedef enum
486  {
488  kBaselineDefault,
490  kBaselineRoman,
492  kBaselineEmBoxTop,
494  kBaselineEmBoxBottom,
496  kBaselineEmBoxCenter,
498  kBaselineICFBoxTop,
500  kBaselineICFBoxBottom,
502  kBaselineICFBoxCenter,
504  kNumBaselines,
506  kBaselineInvalid = 0x7fffFFFF
507  } BaselineType;
521  virtual void TranslateBaseline(PMRealGlyphPoint *strikes, int32 numStrikes, PMMatrix *matrix, BaselineType fromBaseline, BaselineType toBaseline, IFontMgr::WritingDirection writingDirection) const = 0;
530  virtual PMReal GetHorizEmBoxDepth() const = 0;
539  virtual PMReal GetHorizICFBoxDepth() const = 0;
545  virtual bool16 VerticalMetricsProportionalByDefault() const = 0;
559  virtual bool16 HorizontalMetricsProportionalByDefault() const = 0;
560 
571  virtual void GetUnderlinePosition(PMReal *yOffset, PMReal *thickness, PMReal xScale = 1.0, PMReal yScale = 1.0, bool16 vertical = kFalse, bool16 isTcy = kFalse) const = 0;
572 
576  virtual bool16 AllowFakeLigatureSubstitutions() const = 0;
577 
587  virtual int32 DoLigatures(PMRealGlyphPoint* strikes, int32 *numStrikes, char *changeAttr = nil, bool16 tryOpenType = kTrue) const = 0;
588 
596  virtual bool16 HasOTFeature(const char feature[4], const char script[4] = 0, const char language[4] = kDefaultLanguageTag) const = 0;
597 
605  virtual int32 CountOTFeatures(const char script[4] = 0, const char language[4] = kDefaultLanguageTag) const = 0;
606 
612  virtual const char* NewOTFeaturesList(const char script[4] = 0, const char language[4] = kDefaultLanguageTag) const = 0;
613 
619  virtual bool16 GetIsEPSFont() const = 0;
620 
626  virtual bool16 GetIsEmbeddedFont() const = 0;
627 
635  virtual bool16 GetHasOutlines() const = 0;
636 
645  virtual bool16 GetFontRegistry( PMString *fontRegistryString ) const = 0;
653  virtual bool16 GetFontOrdering( PMString *fontOrderingString ) const = 0;
660  virtual int32 GetFontCIDSupplementNumber() const = 0;
661 
662 
667  virtual bool16 IsValidGlyphID(Text::GlyphID checkGlyphID) const = 0;
668 
669 
682  virtual PMString GetPlatformDependentName(IFontMgr::OriginalOS platformOS = IFontMgr::kOriginalUnknownOS) const = 0;
683 
684 
691  virtual void GetGlyphIDs(const WideString& textString, K2Vector<Text::GlyphID>& glyphIDs, bool16 vertical = kFalse) const = 0;
692 
699  virtual void AppendGlyphIDs(const UTF16TextChar* textBuffer, int32 numUTF16Chars, K2Vector<Text::GlyphID>& glyphIDs, bool16 vertical = kFalse) const = 0;
700 
707  virtual Text::GlyphID GetGlyphID(UTF32TextChar character, bool16 vertical = kFalse) const = 0;
708 
717  virtual Text::GlyphID GetPlatformGlyphID(const char* charString, int32 bytesPerChar = 1,
718  bool16 vertical = kFalse, CTEncoding *encoding = nil) const = 0;
719 
728  virtual void GetPlatformGlyphIDs(const char* charString, int32 stringLength, K2Vector<Text::GlyphID>& glyphIDs, bool16 vertical = kFalse,
729  CTEncoding *encoding = nil) const = 0;
730 
750  virtual void GetCharacterBoundaries(const UTF16TextChar * text, int32 utf16WordLength, K2Vector<size_t> &offsets) const = 0;
751 
752 
757  virtual bool16 IsDefinedAndValidGlyph(Text::GlyphID checkGlyphID) const = 0;
758 
762  virtual int32 GetNumValidGlyphIDRanges() const = 0;
763 
769  virtual void GetNthValidGlyphIDRange(int32 nthRange, Text::GlyphID &firstGlyphID, Text::GlyphID &lastGlyphID) const = 0;
770 
778  virtual bool16 IsEqual(const IPMFont *compareFont) const = 0;
779 
789  virtual bool16 GetOTGlyphAccess(Text::GlyphID glyphID, GlyphAccessData * glyphAccessData, int32 featureToSearchCount, const char * featuresToSearch) const = 0;
790 
798  virtual bool16 GetAllOTGlyphAccess(Text::GlyphID glyphID, K2Vector<GlyphAccessData>& glyphAccessData) const = 0;
799 
805  virtual void GetFontFiles(K2Vector<IDFile>& outFiles) const = 0;
806 
816  virtual bool16 GetCIDMojikumiTsume(Text::GlyphID cid, bool16 vertical, PMReal& leftTsume, PMReal& rightTsume) const = 0;
817 
826  virtual bool16 GetCIDMojikumiClass(Text::GlyphID cid, bool16 vertical, MojikumiClass& mojikumiClass) const = 0;
827 
835  virtual int32 GetNumAlternates(Text::GlyphID glyphID, const char* feature) const = 0;
836 
844  virtual IPMFont* QueryComponentFontAndGlyphID(Text::GlyphID glyphID, Text::GlyphID &componentGlyphID) const = 0;
845 
858  virtual int32 GetNumGlyphNames() const = 0;
859 
868  virtual std::string GetGlyphName(Text::GlyphID glyphID) const = 0;
869 
873  virtual CTEncoding* GetCTEncoding() const = 0;
874 
882  virtual bool16 IsCFF() const = 0;
883 
907  virtual PMReal GetATCBaselineShift(Text::GlyphID glyphID) const = 0;
908 
915  virtual bool16 AppendVendorID(PMString& vendorName) const = 0;
916 
923  virtual bool16 AppendCopyrightString(PMString& s) const = 0;
924 
931  virtual bool16 AppendLicenseInfoURL(PMString& s) const = 0;
932 
938  virtual bool16 IsSVGFont() const = 0;
939 
945  virtual bool16 IsSBIXFont() const = 0;
946 
952  virtual bool16 IsColorFont() const = 0;
953 
963  virtual bool16 HasValidSVGOTDescForGlyph (Text::GlyphID glyphId) const = 0;
964 
970  virtual bool16 IsEmojiFont() const = 0;
971 
977  virtual bool16 IsTypekitDesktopFont() const = 0;
978 
984  virtual PMString GetTypekitFontID() const = 0;
985 
986 
999  virtual PMString GetFontSytlisticName(const char featureTag[4]) const = 0;
1000  /*
1001  This method check whether a given font has the color glyph corresponding to the "Font Preview Text For Locale" example :- ["SAMPLE" string in the font preview of character panel]
1002  @return bool16 kTrue if the color text is available.
1003  */
1004  virtual bool16 IsColorTextAvailable() const = 0;
1005 
1006 
1010  typedef enum { // Mimicing from CTTypes. Leaving spaces between for some more if added.
1011  kFontWeightThin = 100,
1012  kFontWeightExtraLight = 200,
1013  kFontWeightLight = 300,
1014  kFontWeightNormal = 400,
1015  kFontWeightMedium = 500,
1016  kFontWeightSemiBold = 600,
1017  kFontWeightBold = 700,
1018  kFontWeightExtraBold = 800,
1019  kFontWeightHeavy = 900, // Black
1020  kFontWeight_Unknown = 0xFFFFFFFF,
1021  } FontWeightType;
1022 
1023  typedef enum {
1024  kFontWidthUltraCondensed = 100,
1042  kFontWidth_Unknown = 0xFFFFFFFF
1043  } FontWidthType;
1044 
1045  typedef enum {
1046  kFontXHeightAny = 100,
1063 
1064  } FontXHeightType;
1065 
1066  typedef enum {
1067  kFontContrastAny = 100,
1088  } FontContrastType;
1089 
1090  typedef enum {
1091  kFontCapStyleNone = 100,
1092  kFontCapStyleStandard = 200,
1093  kFontCapStyleCapsOnly = 300,
1094  kFontCapStyleUnknown = 0xffffffff
1095  } FontCapStyleType;
1096 
1097  typedef enum {
1098  kFontNumberStyleNone = 100,
1099  kFontNumberStyleLowerCase = 200,
1100  kFontNumberStyleUpperCase = 300,
1101  kFontNumberStyleUnknown = 0xffffffff
1102  } FontNumberStyleType;
1112  virtual bool16 GetFontInstallTime(std::time_t& installTime) = 0;
1113 
1123  virtual FontWeightType GetFontWeight() const = 0;
1124 
1134  virtual FontWidthType GetFontWidth() const = 0;
1135 
1136 
1146  virtual FontXHeightType GetFontXHeight() const = 0;
1147 
1148 
1158  virtual FontContrastType GetFontContrast() const = 0;
1159 
1164  virtual FontCapStyleType GetFontCapStyleType() = 0;
1165 
1170  virtual FontNumberStyleType GetFontNumberStyleType() = 0;
1171 
1175  virtual bool16 IsVariableFont() const = 0;
1176 
1181  virtual bool16 SetNthVariableDesignAxes(int32 n) = 0;
1182 
1187  virtual void SetNthVariableDesignAxes(Fixed* designAxes) = 0;
1188 
1193  virtual bool16 IsNthDesignAxisHidden(int32 n) = 0 ;
1194 
1195 };
1196 
1197 DECLARE_BASE_TYPE(IPMFont::FontProtection);
1198 
1199 template <>
1201 {
1202 public:
1203  // Note: Constructing an InterfacePtr from an existing,
1204  // "real" interface pointer implies the InterfacePtr
1205  // now owns the reference that was held by the real pointer.
1206  InterfacePtr(IPMFont * pFace)
1207  : fFace(pFace) {}
1208 
1209  ~InterfacePtr()
1210  { Release_(fFace); }
1211 
1212  InterfacePtr(void) : fFace(nil)
1213  {}
1214 
1215  InterfacePtr(const InterfacePtr<IPMFont>& f) : fFace(AddRef_(f.get()))
1216  {}
1217 
1218  // Constructor that enables InterfacePtr<const IFoo> to be constructed from an InterfacePtr<IFoo>.
1219 // template <class OtherType>
1220 // InterfacePtr(const InterfacePtr<OtherType>& p)
1221 // :fFace(AddRef_(p.get())) { }
1222 
1223  InterfacePtr<IPMFont>& operator=(const InterfacePtr<IPMFont>& p)
1224  { reset(AddRef_(p.get())); return *this; }
1226  { reset(AddRef_(p.get())); return *this; }
1227 
1228  operator IPMFont*() const
1229  { return fFace; }
1230  // We allow the cast operator to return a nil pointer
1231  // since it is valid to test against nil and may be valid
1232  // to pass a nil pointer to some methods.
1233 
1234 
1235  IPMFont* operator ->() const
1236  {
1237  #ifdef DEBUG
1238  ASSERT_MSG(fFace != nil,"About to use nil interface ptr!");
1239  #endif
1240  return fFace;
1241  }
1242 
1243  // Added forget, get and reset from InterfacePtr
1244  IPMFont* forget()
1245  {
1246  IPMFont* result = fFace;
1247  fFace = 0;
1248  return result;
1249  }
1250 
1251  IPMFont* get() const
1252  { return fFace; }
1253 
1254  void reset(IPMFont* p = 0)
1255  {
1256  Release_(fFace);
1257  fFace = p;
1258  }
1259 
1260  void reset(const IPMFont* p)
1261  {
1262  Release_(fFace);
1263  fFace = const_cast<IPMFont*>(p);
1264  }
1265 
1266 private:
1267  static IPMFont* AddRef_(const IPMFont* p)
1268  { if(p) p->AddRef(); return const_cast<IPMFont*>(p);}
1269  static void Release_(IPMFont* p)
1270  { if(p) p->Release(); }
1271 
1272  IPMFont * fFace;
1273 };
1274 
1275 
1276 #endif
1277  //__IFont__
1278