1 /* -*- C++ -*- 2 * 3 * FontInfo.h - Font information storage class of ONScripter 4 * 5 * Copyright (c) 2001-2020 Ogapee. All rights reserved. 6 * 7 * ogapee@aqua.dti2.ne.jp 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 */ 23 24 #ifndef __FONT_INFO_H__ 25 #define __FONT_INFO_H__ 26 27 #include <SDL.h> 28 #include "BaseReader.h" 29 #include "Encoding.h" 30 31 typedef unsigned char uchar3[3]; 32 33 class FontInfo{ 34 public: 35 enum { YOKO_MODE = 0, 36 TATE_MODE = 1 37 }; 38 void *ttf_font[2]; // 0...normal rendering, 1...outline rendering 39 uchar3 color; 40 uchar3 on_color, off_color, nofile_color; 41 int font_size_xy[2]; 42 int top_xy[2]; // Top left origin 43 int num_xy[2]; // Row and column of the text windows 44 float xy[2]; // Current position 45 int old_xy[2]; 46 int pitch_xy[2]; // Width and height of a character 47 int wait_time; 48 bool is_bold; 49 bool is_shadow; 50 bool is_transparent; 51 bool is_newline_accepted; 52 uchar3 window_color; 53 54 int line_offset_xy[2]; // ruby offset for each line 55 bool rubyon_flag; 56 int tateyoko_mode; 57 Encoding *enc; // encoding 58 bool is_line_space_fixed; 59 60 FontInfo(); 61 void reset(Encoding *enc); 62 void *openFont( char *font_file, int ratio1, int ratio2 ); 63 void setTateyokoMode( int tateyoko_mode ); 64 int getTateyokoMode(); 65 int getRemainingLine(); 66 void toggleStyle(int style); 67 68 int x(bool use_ruby_offset=true); 69 int y(bool use_ruby_offset=true); 70 void setXY( int x=-1, int y=-1 ); 71 void clear(); 72 void newLine(); 73 void setLineArea(const char *buf); 74 75 bool isEndOfLine(float margin=0.); 76 bool isLineEmpty(); 77 void advanceCharInHankaku(float offest); 78 void addLineOffset(int margin); 79 void setRubyOnFlag(bool flag); 80 81 SDL_Rect calcUpdatedArea(int start_xy[2], int ratio1, int ratio2); 82 void addShadeArea(SDL_Rect &rect, int dx, int dy, int dw, int dh); 83 int initRuby(FontInfo &body_info, int body_count, int ruby_count); 84 }; 85 86 #endif // __FONT_INFO_H__ 87