summaryrefslogtreecommitdiffstats
path: root/private/mvdm/wow16/write/loadfnt2.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/mvdm/wow16/write/loadfnt2.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/mvdm/wow16/write/loadfnt2.c')
-rw-r--r--private/mvdm/wow16/write/loadfnt2.c155
1 files changed, 155 insertions, 0 deletions
diff --git a/private/mvdm/wow16/write/loadfnt2.c b/private/mvdm/wow16/write/loadfnt2.c
new file mode 100644
index 000000000..dcc7b195f
--- /dev/null
+++ b/private/mvdm/wow16/write/loadfnt2.c
@@ -0,0 +1,155 @@
+/************************************************************/
+/* Windows Write, Copyright 1985-1992 Microsoft Corporation */
+/************************************************************/
+
+/* loadfnt2.c - MW font support code */
+
+#define NOWINMESSAGES
+#define NOVIRTUALKEYCODES
+#define NOSYSMETRICS
+#define NOMENUS
+#define NOWINSTYLES
+#define NOCTLMGR
+#define NOCLIPBOARD
+#include <windows.h>
+
+#include "mw.h"
+#include "macro.h"
+#define NOUAC
+#include "cmddefs.h"
+#include "fontdefs.h"
+#include "docdefs.h"
+
+
+extern int vifceMac;
+extern union FCID vfcidScreen;
+extern union FCID vfcidPrint;
+extern struct FCE rgfce[ifceMax];
+extern struct FCE *vpfceMru;
+extern struct FCE *vpfceScreen;
+extern struct FCE *vpfcePrint;
+extern struct DOD (**hpdocdod)[];
+
+
+struct FCE * (PfceLruGet(void));
+struct FCE * (PfceFcidScan(union FCID *));
+
+
+struct FCE * (PfceLruGet())
+/* tosses out the LRU cache entry's information */
+
+ {
+ struct FCE *pfce;
+
+ pfce = vpfceMru->pfcePrev;
+ FreePfce(pfce);
+ return(pfce);
+ }
+
+
+FreePfce(pfce)
+/* frees the font objects for this cache entry */
+struct FCE *pfce;
+
+ {
+ int ifce;
+ HFONT hfont;
+
+ if (pfce->fcidRequest.lFcid != fcidNil)
+ {
+ hfont = pfce->hfont;
+
+ /* see if we're about to toss the screen or printer's current font */
+ if (pfce == vpfceScreen)
+ {
+ ResetFont(FALSE);
+ }
+ else if (pfce == vpfcePrint)
+ {
+ ResetFont(TRUE);
+ }
+
+#ifdef DFONT
+ CommSzNum("Deleting font: ", hfont);
+#endif /* DFONT */
+
+ if (hfont != NULL)
+ {
+ DeleteObject(hfont);
+ pfce->hfont = NULL;
+ }
+
+ if (pfce->hffn != 0)
+ {
+ FreeH(pfce->hffn);
+ }
+
+ pfce->fcidRequest.lFcid = fcidNil;
+ }
+ }
+
+
+FreeFonts(fScreen, fPrinter)
+/* frees up the font objects for the screen, and the printer */
+
+int fScreen, fPrinter;
+ {
+ int ifce, bit;
+
+ for (ifce = 0; ifce < vifceMac; ifce++)
+ {
+ bit = (rgfce[ifce].fcidRequest.strFcid.wFcid & bitPrintFcid) != 0;
+ if (bit && fPrinter || !bit && fScreen)
+ FreePfce(&rgfce[ifce]);
+ }
+ }
+
+
+struct FCE * (PfceFcidScan(pfcid))
+union FCID *pfcid;
+
+/* look for this font the "hard way" in the LRU list */
+ {
+ struct FFN **hffn, **hffnT;
+ register struct FCE *pfce;
+ struct FFN **MpFcidHffn();
+
+ hffn = MpFcidHffn(pfcid);
+ pfce = vpfceMru;
+ do
+ {
+ hffnT = pfce->hffn;
+ if (hffnT != NULL)
+ if (WCompSz((*hffn)->szFfn, (*hffnT)->szFfn) == 0 &&
+ pfcid->strFcid.hps == pfce->fcidRequest.strFcid.hps &&
+ pfcid->strFcid.wFcid == pfce->fcidRequest.strFcid.wFcid)
+ {
+ pfce->fcidRequest.strFcid.doc = pfcid->strFcid.doc;
+ pfce->fcidRequest.strFcid.ftc = pfcid->strFcid.ftc;
+ return(pfce);
+ }
+ pfce = pfce->pfceNext;
+ }
+ while (pfce != vpfceMru);
+
+ return(NULL);
+ }
+
+
+
+struct FFN **MpFcidHffn(pfcid)
+/* makes sure we use a font code that exists in the table - this is insurance
+ against out of memory problems */
+
+union FCID *pfcid;
+ {
+ int ftc;
+ struct FFNTB **hffntb;
+
+ ftc = pfcid->strFcid.ftc;
+ hffntb = HffntbGet(pfcid->strFcid.doc);
+ if (ftc >= (*hffntb)->iffnMac)
+ ftc = 0;
+
+ return((*hffntb)->mpftchffn[ftc]);
+ }