home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / src / fb.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.4 KB  |  153 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.  * fb.h (FontBrokerObject.h)
  20.  *
  21.  * C++ implementation of the (fb) FontBrokerObject
  22.  *
  23.  * dp Suresh <dp@netscape.com>
  24.  */
  25.  
  26.  
  27. #ifndef _fb_H_
  28. #define _fb_H_
  29.  
  30. #include "libfont.h"
  31. #include "nf.h"
  32.  
  33. // Uses :    FontMatchInfo
  34. //            Font
  35. //            RenderingContext
  36. //            Observer
  37. #include "Mnffmi.h"
  38. #include "Mnff.h"
  39. #include "Mnfrc.h"
  40. #include "Mnfdoer.h"
  41.  
  42.  
  43. #include "wfFCache.h"
  44. #include "wffpPeer.h"
  45.  
  46. struct wf_font_broker_pref {
  47.     int enableWebfonts;
  48. };
  49.  
  50. class FontBrokerObject {
  51. private:
  52.   struct wf_font_broker_pref pref;
  53.   int merge(struct nffmi ** &srcList, int &srcMax,
  54.             struct nffmi **newList);
  55.   FontDisplayerPeerObject *findDisplayer(const char *DisplayerName);
  56.   int scanDisplayersFromDir(const char* dlm_dir);
  57.   jint registerDisplayer(FontDisplayerPeerObject *fpp);
  58.  
  59. public:
  60.   // Cache of Font Objects. Font <--> {RC,Fmi} mapping is done by this.
  61.   wfFontObjectCache fontObjectCache;
  62.  
  63.   // A list of all FontDisplayers that we know about.
  64.   wfList fpPeers;
  65.  
  66.   // The catalog filename
  67.   const char *catalogFilename;
  68.   wfList fpPeersFromCatalog;
  69.  
  70.   // Constructor and Destructor
  71.   FontBrokerObject(void);
  72.   ~FontBrokerObject(void);
  73.  
  74.   //
  75.   // FontBrokerConsumer Interface specific
  76.   //
  77.   struct nff *LookupFont(struct nfrc *rc, struct nffmi *fmi, const char *accessor);
  78.  
  79.   struct nff *CreateFontFromUrl(struct nfrc* rc, const char* url_of_font,
  80.                                 const char *url_of_page, jint faux,
  81.                                 struct nfdoer* completion_callback,
  82.                                 MWContext *context);
  83.   struct nff *CreateFontFromFile(struct nfrc* rc, const char *mimetype,
  84.                                  const char* fontfilename,
  85.                                  const char *url_of_page);
  86.  
  87.   //
  88.   // Catalog specific routines
  89.   struct nffmi **ListFonts(struct nfrc *rc, struct nffmi *fmi);
  90.  
  91.   jdouble *ListSizes(struct nfrc *rc, struct nffmi *fmi);
  92.  
  93.   struct nff *GetBaseFont(struct nfrf *rf);
  94.  
  95.   //
  96.   // FontBrokerDisplayer interface specific
  97.   //
  98.   jint RegisterFontDisplayer(struct nffp* fp);
  99.  
  100.   jint CreateFontDisplayerFromDLM(const char* dlm_name);
  101.  
  102.   // dlm_dir is a semicolon separated list of directory names
  103.   //    eg.
  104.   //    ~/.netscape/fonts;/usr/lib/netscape/fonts
  105.   // Each directory tree in this list searched for displayer DLMs
  106.   // The number of displayers that were loaded is returned.
  107.   //
  108.   // Expansion happens for
  109.   // ~    HOME
  110.   //
  111.   jint ScanForFontDisplayers(const char* dlm_dir);
  112.  
  113.   void RfDone(struct nfrf *rf);
  114.  
  115.   //
  116.   // FontBrokerUtility interface specific
  117.   //
  118.   struct nffmi *CreateFontMatchInfo(const char* name, const char* charset,
  119.                                     const char* encoding, jint weight,
  120.                                     jint pitch, jint style, jint underline,
  121.                                     jint strikeOut, jint resX, jint resY);
  122.  
  123.   struct nfrc *CreateRenderingContext(jint majorType, jint minorType,
  124.       void ** args, jsize nargs);
  125.  
  126.   struct nfdoer *CreateFontObserver(nfFontObserverCallback callback,
  127.       void *call_data);
  128.  
  129.   //
  130.   // Preferences
  131.   //
  132.   jint IsWebfontsEnabled(void);
  133.   jint EnableWebfonts(void);
  134.   jint DisableWebfonts(void);
  135.  
  136.   const char **ListFontDisplayers();
  137.   jint IsFontDisplayerEnabled(const char *displayer);
  138.   const char **ListFontDisplayersForMimetype(const char *mimetype);
  139.   const char *FontDisplayerForMimetype(const char *mimetype);
  140.  
  141.   jint EnableFontDisplayer(const char *displayer);
  142.   jint DisableFontDisplayer(const char *displayer);
  143.   jint EnableMimetype(const char *displayer, const char *mimetype);
  144.   jint DisableMimetype(const char *displayer, const char *mimetype);
  145.  
  146.   jint LoadCatalog(const char *filename);
  147.   jint SaveCatalog(const char *filename);
  148.  
  149.   const char *GetMimetype(const char *imimetype, const char *address);
  150. };
  151. #endif /* _fb_H_ */
  152.  
  153.