From 3cecc58607db7e841dc0976a5ff367617e4af881 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 8 Aug 2020 22:44:47 +0900 Subject: [PATCH] Narrow dependency on font.h This removes font.h dependency from header files such as ags.h and nact.h. After this, font.h must be explicitly included in order to use font functions. --- modules/NIGHTDLL/NIGHTDLL.c | 2 +- modules/SACT/SACT.c | 2 +- src/ags.h | 15 +++++++++++++-- src/font.h | 11 ----------- src/nact.h | 1 - src/sdl_core.h | 2 +- src/sdl_private.h | 5 +++-- src/sdl_video.c | 4 ++-- src/xcore.h | 3 +-- src/xcore_private.h | 5 +++-- src/xcore_video.c | 2 +- src/xsystem35.c | 1 + 12 files changed, 27 insertions(+), 26 deletions(-) diff --git a/modules/NIGHTDLL/NIGHTDLL.c b/modules/NIGHTDLL/NIGHTDLL.c index dc8726f..7dc1a28 100644 --- a/modules/NIGHTDLL/NIGHTDLL.c +++ b/modules/NIGHTDLL/NIGHTDLL.c @@ -39,7 +39,7 @@ static void Init(void) { /* 0 */ } static void InitGame() { /* 1 */ - nact->ags.font->antialiase_on = TRUE; + ags_setAntialiasedStringMode(TRUE); sys_setHankakuMode(2); nact->msgout = ntmsg_add; diff --git a/modules/SACT/SACT.c b/modules/SACT/SACT.c index 84ca26b..2c89c1b 100644 --- a/modules/SACT/SACT.c +++ b/modules/SACT/SACT.c @@ -132,7 +132,7 @@ static void Init() { sact.dmap = sf_create_pixel(sf0->width, sf0->height, 16); // その他 System35 のデフォルト動作の変更 - nact->ags.font->antialiase_on = TRUE; + ags_setAntialiasedStringMode(TRUE); sys_setHankakuMode(2); // 全角半角変換無し ags_autorepeat(FALSE); // key auto repeat off diff --git a/src/ags.h b/src/ags.h index 2233665..9f6573b 100644 --- a/src/ags.h +++ b/src/ags.h @@ -29,8 +29,8 @@ #include "portab.h" #include "cg.h" #include "graphics.h" -#include "font.h" +struct _FONT; /* マウスカーソルの種類 */ #define CURSOR_ARROW 1 @@ -136,7 +136,7 @@ struct _ags { boolean fullscree_is_on; /* if full-screen mode then true */ - FONT *font; /* font device */ + struct _FONT *font; /* font device */ agsurface_t *dib; /* main surface */ void (*eventcb)(agsevent_t *e); /* deliver event */ }; @@ -224,6 +224,17 @@ extern void ags_whiteOut(int rate, boolean flg); extern void ags_fader_callback(); /* フォント関連 */ + +typedef enum { + FONT_X11, + FONT_FT2, + FONT_SDLTTF +} fontdev_t; + +enum FontType { + FONT_GOTHIC, + FONT_MINCHO, +}; extern void ags_setFont(int type, int size); /* カーソル関係 */ diff --git a/src/font.h b/src/font.h index 50d48cc..06cd70a 100644 --- a/src/font.h +++ b/src/font.h @@ -30,10 +30,6 @@ /* font の種類 */ #define FONTTYPEMAX 2 -/* fontの名前 */ -#define FONT_GOTHIC (0) -#define FONT_MINCHO (1) - struct agsurface; struct _FONT { @@ -71,13 +67,6 @@ extern FONT *font_x11_new(); /* デフォルトのフォント名 */ #define FONT_DEFAULTNAME_X "-*-*-medium-r-normal--%d-*-*-*-c-*-jisx0208.1983-0,-*-*-medium-r-normal--%d-*-*-*-c-*-jisx0201.1976-0,*" -// Font devices -typedef enum { - FONT_X11, - FONT_FT2, - FONT_SDLTTF -} fontdev_t; - #ifdef __EMSCRIPTEN__ int load_mincho_font(void); #endif diff --git a/src/nact.h b/src/nact.h index f534129..08bdece 100644 --- a/src/nact.h +++ b/src/nact.h @@ -27,7 +27,6 @@ #include "portab.h" #include "graphics.h" #include "scenario.h" -#include "font.h" #include "s39ain.h" #include "gameresource.h" #include "selection.h" diff --git a/src/sdl_core.h b/src/sdl_core.h index caa0952..df42096 100644 --- a/src/sdl_core.h +++ b/src/sdl_core.h @@ -78,7 +78,7 @@ extern void sdl_delRegion(void *src); extern void sdl_maskupdate(int sx, int sy, int w, int h, int dx, int dy, int func, int step); /* フォント関連 */ -extern void sdl_setFontDevice(FONT *f); +extern void sdl_setFontDevice(struct _FONT *f); /* fader */ extern void sdl_fadeIn(int step); diff --git a/src/sdl_private.h b/src/sdl_private.h index a8f6123..799bc73 100644 --- a/src/sdl_private.h +++ b/src/sdl_private.h @@ -29,7 +29,8 @@ #include "portab.h" #include "ags.h" -#include "font.h" + +struct _FONT; struct sdl_private_data { SDL_Window *window; @@ -47,7 +48,7 @@ struct sdl_private_data { SDL_Rect view; - FONT *font; + struct _FONT *font; boolean dirty; diff --git a/src/sdl_video.c b/src/sdl_video.c index cb88a6f..58cdb71 100644 --- a/src/sdl_video.c +++ b/src/sdl_video.c @@ -173,8 +173,8 @@ static void makeDIB(int width, int height, int depth) { image_setdepth(sdl_dibinfo->depth); } -void sdl_setFontDevice(FONT *f) { - sdl_font = f; +void sdl_setFontDevice(struct _FONT *f) { + sdl_font = f; } /* offscreen の設定 */ diff --git a/src/xcore.h b/src/xcore.h index 31d92ba..e2dcc18 100644 --- a/src/xcore.h +++ b/src/xcore.h @@ -29,7 +29,6 @@ #include "portab.h" #include "image.h" #include "xcore_image.h" -#include "font.h" #include "cursor.h" #include "ags.h" @@ -71,7 +70,7 @@ extern void Xcore_maskupdate(int sx, int sy, int w, int h, int dx, int dy, int f /* フォント関連 */ // extern FONT *Xcore_getFontDevice(void); -extern void Xcore_setFontDevice(FONT *f); +extern void Xcore_setFontDevice(struct _FONT *f); /* fader */ extern void Xcore_fadeIn(int step); diff --git a/src/xcore_private.h b/src/xcore_private.h index 99392ff..964a5cf 100644 --- a/src/xcore_private.h +++ b/src/xcore_private.h @@ -31,10 +31,11 @@ #include #include "portab.h" -#include "font.h" #include "ags.h" #include "image.h" +struct _FONT; + /* dib/work image 情報 */ typedef struct { XImage *ximg; /* XImage/ShmXImage 使用時の XImage */ @@ -63,7 +64,7 @@ struct xcore_private_data { int dib_depth_candidate; /* DIB depth if required pixmap depth isnt 8 */ - FONT *fontinfo; /* font object */ + struct _FONT *fontinfo; /* font object */ boolean noSHM; /* dont have X-SHM extension */ diff --git a/src/xcore_video.c b/src/xcore_video.c index d9e26d1..2d083cd 100644 --- a/src/xcore_video.c +++ b/src/xcore_video.c @@ -486,7 +486,7 @@ void x11_makeWorkImage(int w, int h) { alloced = TRUE; } -void Xcore_setFontDevice(FONT *f) { +void Xcore_setFontDevice(struct _FONT *f) { x11_font = f; } diff --git a/src/xsystem35.c b/src/xsystem35.c index 8feea84..ca0a33b 100644 --- a/src/xsystem35.c +++ b/src/xsystem35.c @@ -62,6 +62,7 @@ #include "randMT.h" #include "counter.h" #include "ags.h" +#include "font.h" #include "graphicsdevice.h" #include "menu.h" #include "music.h"