home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / src / f.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.1 KB  |  145 lines

  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* 
  19.  * f.h (FontObject.h)
  20.  *
  21.  * C++ implementation of the (f) FontObject
  22.  *
  23.  * dp Suresh <dp@netscape.com>
  24.  */
  25.  
  26.  
  27. #ifndef _f_H_
  28. #define _f_H_
  29.  
  30. #include "libfont.h"
  31.  
  32. // Uses :    RenderingContext
  33. //            RenderableFont
  34. //            FontDisplayer
  35. //            Font
  36. #include "Mnfrc.h"
  37. #include "Mnfrf.h"
  38. #include "Mnffp.h"
  39. #include "Mnff.h"
  40.  
  41. #include "wffpPeer.h"
  42. #include "wfList.h"
  43. #include "wfSzList.h"
  44.  
  45. struct fh_store {
  46.   FontDisplayerPeerObject *fppeer;
  47.   void *fh;
  48.   wfSizesList sizesList;
  49. };
  50.  
  51. class FontObject : public wfList {
  52. private:
  53.   // The nff that has this FontObject. This is reverse mapping
  54.   // for the purpose of accessing refcount.
  55.   // WARNING: Holding this will not increment the refcount of the
  56.   //            nff. This is there for the purpose of elements of the
  57.   //            list to refcount the FontObject.
  58.   struct nff *self;
  59.  
  60.   // While the GarbageColletor for the Font object is running it
  61.   // will set this member. This will ensure that when the GC is
  62.   // releasing references to the Font object, it will not step over
  63.   // itself.
  64.   int inGC;
  65.   
  66.   // These are valid only for webfonts. If this font object
  67.   // reflects a webfont, then isWebFont will be 1 and
  68.   // {urlOffont} will indicate where this was created
  69.   // from.
  70.   int iswebfont;
  71.   const char *urlOfFont;
  72.  
  73.   // For webfonts this specifies the state of the font. For
  74.   // non-webfonts, this state will always be in the complete state.
  75.   int state;
  76.  
  77.   // Specified if this font object can be shared or not.
  78.   // All font objects that just have the native displayer serving rfs
  79.   // are sharable across different accessors. Webfonts are not.
  80.   int shared;
  81.  
  82.   // The rc this font was created for
  83.   jint m_rcMajorType;
  84.   jint m_rcMinorType;
  85.   void computeSizes(struct nfrc *rc, struct fh_store *ele);
  86.   
  87. public:
  88.   FontObject(struct nff *self, struct nfrc *rc,
  89.       const char *urlOfFont = NULL);
  90.   ~FontObject();
  91.  
  92.   int GC();
  93.  
  94.   jdouble *EnumerateSizes(struct nfrc *rc);
  95.   struct nfrf *GetRenderableFont(struct nfrc *rc, jdouble pointsize);
  96.  
  97.   struct nffmi *GetMatchInfo(struct nfrc *rc, jdouble pointsize);
  98.  
  99.   // Rc type that this font was created with
  100.   jint GetRcMajorType();
  101.   jint GetRcMinorType();
  102.  
  103.   //
  104.   // FontBroker specific
  105.   //
  106.   int addFontHandle(FontDisplayerPeerObject *fp_peer, void *font_handle);
  107.  
  108.   // Returns 1 is rf exists in the Font. 0 otherwise.
  109.   int isRfExist(struct nfrf *rf);
  110.  
  111.   // Returns the number of rf's that were released
  112.   int releaseRf(struct nfrf *rf);
  113.  
  114.   int isWebFont();
  115.   //const char *name();
  116.   const char *url();
  117.  
  118.   //
  119.   // Webfont specific
  120.   //
  121.   // getState() returns the status of the webfont. Valid status's are
  122.   // NF_FONT_INCOMPLETE
  123.   //    : Not yet complete. The font is in the process of being made.
  124.   //        XXX we might want to distinguish this from the
  125.   //        XXX NOT-YET-ACTIVE state.
  126.   // NF_FONT_COMPLETE
  127.   //    : complete. The font is ready for use. For non-webfonts, this
  128.   //        will be the state on creation.
  129.   // NF_FONT_ERROR
  130.   //    : Error. There was some error in creation of this font.
  131.   //        This font will never be complete.
  132.   int GetState();
  133.   int setState(int completion_state);
  134.  
  135.   //
  136.   // Query if this font is shared
  137.   //
  138.   int isShared(void);
  139.   int setShared(int sharedState);
  140.  
  141.   friend void free_fh_store(wfList *object, void *item);
  142. };
  143. #endif /* _f_H_ */
  144.  
  145.