SDXFrameWork  0.12
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Font.h
1 //Copyright © 2014 SDXFramework
2 //[License]GNU Affero General Public License, version 3
3 //[Contact]http://sourceforge.jp/projects/dxframework/
4 #pragma once
5 #include <Multimedia/SDX.h>
6 #include <Multimedia/Screen.h>
7 #include <Multimedia/IFont.h>
8 #include <Multimedia/SystemFont.h>
9 #include <Multimedia/Image.h>
10 #include <Framework/ImagePack.h>
11 #include <Multimedia/Window.h>
12 #include <Multimedia/File.h>
13 
14 #include <map>
15 #include <iomanip>
16 
17 namespace SDX
18 {
24  class Font : public IFont
25  {
26  private:
27  TTF_Font* handle = nullptr;
28  bool isBlendRender;
29  int size = 0;
30  int enterHeight = 0;
31  mutable std::map<int, Image*> hash;
32 
33  int style = TTF_STYLE_NORMAL;
34 
35  static bool GetUTFSize(unsigned char 一文字目,int &文字長さ )
36  {
37  if (一文字目 < 0x20)
38  {
39  //空白文字
40  文字長さ = 1;
41  return false;
42  }
43 
44  if (一文字目 < 0x80){ 文字長さ = 1; }
45  else if (一文字目 < 0xE0){ 文字長さ = 2; }
46  else if (一文字目 < 0xF0){ 文字長さ = 3; }
47  else { 文字長さ = 4; }
48  return true;
49  }
50 
52  void DrawUTFString(const Point &座標, const std::string &文字列 , const Color &描画色) const
53  {
54  Point 位置 = 座標;
55 
56  int charSize;
57  for (auto it = 文字列.begin(); it != 文字列.end(); it += charSize)
58  {
59  if (!GetUTFSize(*it, charSize)){ continue; }
60  if (handle == nullptr && *it == ' ')
61  {
62  位置.x += size;
63  continue;
64  }
65 
66  Image* str = GetHash(文字列.substr(std::distance(文字列.begin(), it), charSize).c_str() , charSize);
67  if (str == nullptr){ continue; }
68 
69  str->SetColor(描画色);
70  str->Draw(位置);
71  位置.x += str->GetWidth();
72  }
73  }
75  void DrawUTFString(const Point &座標, double X拡大率, double Y拡大率, const std::string &文字列, const Color &描画色) const
76  {
77  Point 位置 = 座標;
78 
79  int charSize = 0;
80  for (auto it = 文字列.begin(); it != 文字列.end(); it += charSize)
81  {
82  if (!GetUTFSize(*it, charSize)){ continue; }
83  if (handle == nullptr && *it == ' ')
84  {
85  位置.x += size * X拡大率;
86  continue;
87  }
88 
89  Image* str = GetHash(文字列.substr(std::distance(文字列.begin(), it), charSize).c_str(),charSize);
90  if (str == nullptr){ continue; }
91 
92  str->SetColor(描画色);
93  str->DrawExtend({ 位置.x , 位置. y , str->GetWidth()*X拡大率, str->GetHeight()*Y拡大率 });
94  位置.x += str->GetWidth() * X拡大率;
95  }
96  }
98  void DrawRotateUTFString(const Point &座標, int X補正, int Y補正, double 拡大率, double 角度, const std::string &文字列, const Color &描画色) const
99  {
100  Point 位置 = 座標;
101 
102  int charSize = 0;
103  for (auto it = 文字列.begin(); it != 文字列.end(); it += charSize)
104  {
105  if (!GetUTFSize(*it, charSize)){ continue; }
106  if (handle == nullptr && *it == ' ')
107  {
108  位置.x += size * 拡大率;
109  continue;
110  }
111 
112  Image* str = GetHash(文字列.substr(std::distance(文字列.begin(), it), charSize).c_str(),charSize);
113  if (str == nullptr){ continue; }
114 
115  double x = 位置.x + std::cos(角度) * X補正 + std::cos(角度 + PAI / 2) * Y補正;
116  double y = 位置.y + std::sin(角度) * X補正 + std::sin(角度 + PAI / 2) * Y補正;
117 
118  str->SetColor(描画色);
119  str->DrawRotate({ x, y }, 拡大率, 角度);
120  X補正 += int(str->GetWidth() * 拡大率);
121  }
122  }
123 
125  Image* GetHash(const char* 文字 , int 文字長さ) const
126  {
127  int ID = 文字[0];
128  if (文字長さ >= 2){ ID += 文字[1]*256; }
129  if (文字長さ >= 3){ ID += 文字[2]*256*256; }
130  if (文字長さ >= 4){ ID += 文字[3] * 256 * 256 * 256; }
131 
132  auto it = hash.find(ID);
133 
134  if (it == hash.end())
135  {
136  if (handle == nullptr){ return nullptr; }
137 
138  SDL_Surface* surface;
139 
140  if (isBlendRender)
141  {
142  surface = TTF_RenderUTF8_Blended(handle, 文字, { 255, 255, 255 });
143  }
144  else
145  {
146  surface = TTF_RenderUTF8_Solid(handle, 文字, { 255, 255, 255 });
147  }
148 
149  SDL_Texture* moji = SDL_CreateTextureFromSurface(Screen::GetHandle(), surface);
150  hash[ID] = new Image(moji, surface->w, surface->h);
151 
152  SDL_FreeSurface(surface);
153  return hash[ID];
154  }
155  return it->second;
156  }
157 
159  void SetHash(const char* 文字, int 文字長さ, Image *対応Image)
160  {
161  int ID = 文字[0];
162  if (文字長さ >= 2){ ID += 文字[1] * 256; }
163  if (文字長さ >= 3){ ID += 文字[2] * 256 * 256; }
164  if (文字長さ >= 4){ ID += 文字[3] * 256 * 256 * 256; }
165 
166  hash[ID] = 対応Image;
167  }
168 
169  public:
170 
171  Font() = default;
172 
174  Font(const char *フォント名, int 大きさ, int 行間 = 0 , bool 高品質レンダリングフラグ = true )
175  {
176  Load(フォント名, 大きさ, 行間, 高品質レンダリングフラグ);
177  }
178 
182  bool Load(const char *フォント名, int 大きさ, int 行間 = 0, bool 高品質レンダリングフラグ = true )
183  {
184  if (Loading::isLoading)
185  {
186  Loading::AddLoading([=]{ Load(フォント名, 大きさ, 行間, 高品質レンダリングフラグ); });
187  return true;
188  }
189 
190  //すでに読み込んでいる場合は失敗
191  if (handle != nullptr){ return false; }
192 
193  this->size = 大きさ;
194  this->enterHeight = 行間 + 大きさ;
195  isBlendRender = 高品質レンダリングフラグ;
196  handle = TTF_OpenFont(フォント名, 大きさ);
197 
198  return (handle != nullptr);
199  }
200 
202  bool Release() const
203  {
204  //すでに読み込んでいる場合は失敗
205  if (handle != nullptr){ return false; }
206  TTF_CloseFont(handle);
207  for (auto && it : hash)
208  {
209  it.second->Release();
210  }
211  return true;
212  }
213 
215  TTF_Font* GetHandle() const
216  {
217  return handle;
218  }
219 
221  Image MakeImage(Color 文字色, bool 反転フラグ, const VariadicStream &描画する文字列) const
222  {
223  if (handle == nullptr){ return Image(); }
224 
225  int 幅 = GetDrawStringWidth(描画する文字列);
226  int 高さ = ((int)描画する文字列.StringS.size() - 1) * enterHeight + size;
227  int Y座標 = 0;
228 
229  std::vector<SDL_Surface*> surfaces;
230  SDL_Surface* surface;
231 
232  for (auto it : 描画する文字列.StringS)
233  {
234  if (isBlendRender)
235  {
236  surface = TTF_RenderUTF8_Blended(handle, it.c_str(), 文字色);
237  }
238  else
239  {
240  surface = TTF_RenderUTF8_Solid(handle, it.c_str(), 文字色);
241  }
242 
243  幅 = std::max(幅, surface->w);
244  surfaces.push_back(surface);
245  }
246 
247  SDL_Surface* toRend = SDL_CreateRGBSurface(0, 幅, 高さ, 32, 0, 0, 0, 0);
248  SDL_Renderer* render = SDL_CreateSoftwareRenderer(toRend);
249 
250  for (auto it : surfaces)
251  {
252  SDL_Texture* texture = SDL_CreateTextureFromSurface(render, it);
253 
254  SDL_Rect temp = { 0, Y座標, it->w, it->h };
255  SDL_RenderCopy(render, texture, 0, &temp);
256 
257  Y座標 += this->enterHeight;
258 
259  SDL_FreeSurface(it);
260  SDL_DestroyTexture(texture);
261  }
262  //描画先を戻す
263  Image image(SDL_CreateTextureFromSurface(Screen::GetHandle(), toRend), 幅, 高さ);
264 
265  SDL_FreeSurface(toRend);
266  SDL_DestroyRenderer(render);
267 
268  return image;
269  }
270 
274  bool MakeBMPFont(const std::string テキストファイル名 )
275  {
276  if (handle == nullptr){ return false; }
277  SDL_Surface* surface;
278  SDL_Surface* buff;
279 
280  SDL_Rect pos;
281  SDL_Rect rect;
282  rect.x = 0;
283  rect.y = 0;
284  pos.x = 0;
285  pos.y = 0;
286 
287  /* OpenGLのテクスチャとして使うために
288  各ピクセルがR,G,B,A順の32bitサーフェイスを生成する */
289  Uint32 rmask, gmask, bmask, amask;
290 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
291  rmask = 0xff000000;
292  gmask = 0x00ff0000;
293  bmask = 0x0000ff00;
294  amask = 0x000000ff;
295 #else
296  rmask = 0x000000ff;
297  gmask = 0x0000ff00;
298  bmask = 0x00ff0000;
299  amask = 0xff000000;
300 #endif
301  //追加フォント
302  File file(テキストファイル名.c_str(), FileMode::Read, true);
303  auto strS = file.GetLineS();
304  int count = strS.size();
305 
306  unsigned int index = 0;
307 
308  if( (unsigned char)strS[0][0] == 0xEF && (unsigned char)strS[0][1] == 0xBB && (unsigned char)strS[0][2] == 0xBF ){index = 3;}
309 
310  while(1)
311  {
312  if( strS[0].size() <= index ){break;}
313 
314  if( (unsigned char)strS[0][index] < 0x80 ){index += 1;}
315  else if ( (unsigned char)strS[0][index] < 0xE0){ index += 2; }
316  else if ( (unsigned char)strS[0][index] < 0xF0){ index += 3; }
317  else { index += 4; }
318 
319  ++count;
320  }
321 
322  int high = TTF_FontHeight(handle);
323  surface = SDL_CreateRGBSurface(0, size * 32 , high * (12+((count+31)/32) ) , 32, rmask, gmask, bmask, amask);
324 
325  std::string str;
326 
327  //基本フォントを生成
328  for (int a = 0; a < 12; ++a)
329  {
330  //全角32文字ずつ
331  switch (a)
332  {
333  case 0: str = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"; break;
334  case 1: str = "abcdefghijklmnopqrstuvwxyz{|}~。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソ"; break;
335  case 2: str = "タチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚"; break;
336  case 3: str = "ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただ"; break;
337  case 4: str = "ちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむ"; break;
338  case 5: str = "めもゃやゅゆょよらりるれろゎわゐゑをんゔゕゖ"; break;
339  case 6: str = "ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダ"; break;
340  case 7: str = "チヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミム"; break;
341  case 8: str = "メモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・ーヽヾヿ゠"; break;
342  case 9: str = "!"#$%&'()*+,-./0123456789:;<=>?@"; break;
343  case 10: str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"; break;
344  case 11: str = "abcdefghijklmnopqrstuvwxyz{|}~⦅⦆"; break;
345  }
346 
347  if (isBlendRender)
348  {
349  buff = TTF_RenderUTF8_Blended(handle, str.c_str(), { 255, 255, 255 });
350  }
351  else
352  {
353  buff = TTF_RenderUTF8_Solid(handle, str.c_str(), { 255, 255, 255 });
354  }
355  pos.w = buff->w;
356  pos.h = buff->h;
357 
358  SDL_BlitSurface(buff, NULL, surface, &pos);
359 
360  pos.y += high;
361  SDL_FreeSurface(buff);
362  }
363 
364 
365  //一文字ずつ
366  //http://1bit.mobi/20101026101350.html 常用漢字表
367  index = 0;
368  int length = 0;
369  if( (unsigned char)strS[0][0] == 0xEF && (unsigned char)strS[0][1] == 0xBB && (unsigned char)strS[0][2] == 0xBF ){index = 3;}
370 
371  while(1)
372  {
373  if( strS[0].size() <= index ){break;}
374 
375  if( (unsigned char)strS[0][index] < 0x80 )
376  {
377  length = 1;
378  }
379  else if ( (unsigned char)strS[0][index] < 0xE0)
380  {
381  length = 2;
382  }
383  else if ( (unsigned char)strS[0][index] < 0xF0)
384  {
385  length = 3;
386  }
387  else
388  {
389  length = 4;
390  }
391  if (isBlendRender)
392  {
393  buff = TTF_RenderUTF8_Blended(handle, strS[0].substr(index,length).c_str() , { 255, 255, 255 });
394  }
395  else
396  {
397  buff = TTF_RenderUTF8_Solid(handle, strS[0].substr(index,length).c_str() , { 255, 255, 255 });
398  }
399 
400  index += length;
401 
402  pos.w = buff->w;
403  pos.h = buff->h;
404 
405  SDL_BlitSurface(buff, NULL, surface, &pos);
406 
407  pos.x += pos.w;
408  if (pos.x >= size * 32)
409  {
410  pos.x = 0;
411  pos.y += high;
412  }
413  SDL_FreeSurface(buff);
414  }
415 
416  std::string fileName = TTF_FontFaceFamilyName(handle);
417  fileName += TTF_FontFaceStyleName(handle);
418  fileName += ".bmp";
419 
420  SDL_SaveBMP(surface, fileName.c_str());
421  SDL_FreeSurface(surface);
422 
423  return true;
424  }
425 
428  bool LoadBMPFont( const Image& BMPフォント , const std::string テキストファイル名)
429  {
430  File file(テキストファイル名.c_str(), FileMode::Read, true);
431  auto strS = file.GetLineS();
432  int count = 0;
433 
434  unsigned int index = 0;
435 
436  if( (unsigned char)strS[0][0] == 0xEF && (unsigned char)strS[0][1] == 0xBB && (unsigned char)strS[0][2] == 0xBF ){index = 3;}
437 
438  while(1)
439  {
440  if( strS[0].size() <= index ){break;}
441 
442  if( (unsigned char)strS[0][index] < 0x80 ){index += 1;}
443  else if ( (unsigned char)strS[0][index] < 0xE0){ index += 2; }
444  else if ( (unsigned char)strS[0][index] < 0xF0){ index += 3; }
445  else { index += 4; }
446 
447  ++count;
448  }
449 
450  int h = BMPフォント.GetHeight() / ((count+31)/32 + 12);
451  int w = BMPフォント.GetWidth() / 32;
452 
453  std::string str;
454 
455  for (int a = 0; a < 12; ++a)
456  {
457  switch (a)
458  {
459  case 0: str = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"; break;
460  case 1: str = "abcdefghijklmnopqrstuvwxyz{|}~。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソ"; break;
461  case 2: str = "タチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚"; break;
462  case 3: str = "ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただ"; break;
463  case 4: str = "ちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむ"; break;
464  case 5: str = "めもゃやゅゆょよらりるれろゎわゐゑをんゔゕゖ"; break;
465  case 6: str = "ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダ"; break;
466  case 7: str = "チヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミム"; break;
467  case 8: str = "メモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・ーヽヾヿ゠"; break;
468  case 9: str = "!"#$%&'()*+,-./0123456789:;<=>?@"; break;
469  case 10: str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"; break;
470  case 11: str = "abcdefghijklmnopqrstuvwxyz{|}~⦅⦆"; break;
471  }
472 
473  for (int b = 0; b < 64; ++b)
474  {
475  int ID;
476  if (a <= 2)
477  {
478  if (a == 1 && b == 61){ break; }
479  if( a == 2 && b == 32){ break;}
480  ID = str[b];
481  hash[ID] = new Image(BMPフォント, { b * w/2, a * h, w / 2, h });
482  }
483  else
484  {
485  if (b >= 32){ break; }
486  if (a == 5 && b == 22){ break; }
487 
488  ID = str[b * 3] + str[b * 3 + 1] * 256 + str[b * 3 + 2] * 256 * 256;
489  hash[ID] = new Image(BMPフォント, { b * w, a * h, w, h });
490  }
491  }
492  }
493 
494  //一文字ずつ
495  //http://1bit.mobi/20101026101350.html 常用漢字表
496  int c = 0;
497 
498  index = 0;
499  int length = 0;
500  if( (unsigned char)strS[0][0] == 0xEF && (unsigned char)strS[0][1] == 0xBB && (unsigned char)strS[0][2] == 0xBF ){index = 3;}
501 
502  while(1)
503  {
504  if( strS[0].size() <= index ){break;}
505 
506  if( (unsigned char)strS[0][index] < 0x80 )
507  {
508  length = 1;
509  }
510  else if ( (unsigned char)strS[0][index] < 0xE0)
511  {
512  length = 2;
513  }
514  else if ( (unsigned char)strS[0][index] < 0xF0)
515  {
516  length = 3;
517  }
518  else
519  {
520  length = 4;
521  }
522 
523  SetImage(strS[0].substr(index,length).c_str(), new Image(BMPフォント, { c%32*w, (c/32+12)*h, w , h }));
524 
525  index += length;
526  ++c;
527  }
528 
529 
530  return true;
531  }
532 
534  int GetSize() const
535  {
536  return this->size;
537  }
538 
540  int GetDrawStringWidth(const VariadicStream &幅を計算する文字列) const
541  {
542  int 最大幅 = 0;
543 
544  for (auto 文字列 : 幅を計算する文字列.StringS)
545  {
546  unsigned char lead;
547  int charSize = 0;
548  int 幅 = 0;
549 
550  for (auto it = 文字列.begin(); it != 文字列.end(); it += charSize)
551  {
552  lead = *it;
553  if (lead < 0x20){ continue; }
554  else if (lead < 0x80){ charSize = 1; }
555  else if (lead < 0xE0){ charSize = 2; }
556  else if (lead < 0xF0){ charSize = 3; }
557  else { charSize = 4; }
558 
559  幅 += GetHash(文字列.substr(std::distance(文字列.begin(), it), charSize).c_str(),charSize)->GetWidth();
560  }
561 
562  最大幅 = std::max(幅, 最大幅);
563  }
564  return 最大幅;
565  }
566 
569  bool Draw(const Point &座標, const Color &描画色, const VariadicStream &描画する文字列 , bool 反転フラグ = false) const override
570  {
571  Point 位置 = 座標;
572 
573  for (auto it : 描画する文字列.StringS)
574  {
575  DrawUTFString(位置, it, 描画色);
576  位置.y += this->enterHeight;
577  }
578 
579  return true;
580  }
581 
583  bool DrawShadow(const Point &座標, Color 表色, Color 影色, const VariadicStream &描画する文字列) const
584  {
585  Draw({ 座標.x + 1, 座標.y + 1 }, 影色, 描画する文字列);
586  return Draw(座標, 表色, 描画する文字列);
587  }
588 
591  bool DrawRotate(const Point &座標, double 拡大率, double 角度, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ = false) const override
592  {
593  int 行数 = 描画する文字列.StringS.size();
594 
595  int X補正 = int(-GetDrawStringWidth(描画する文字列) * 拡大率 * 0.5);
596  int Y補正 = int(-enterHeight * 拡大率 * 0.5*行数);
597 
598  for (auto it : 描画する文字列.StringS)
599  {
600  DrawRotateUTFString(座標, X補正, Y補正, 拡大率, 角度, it, 描画色);
601  Y補正 += int(enterHeight * 拡大率);
602  }
603 
604  return true;
605  }
606 
609  bool DrawExtend(const Point &座標, double X拡大率, double Y拡大率, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ = false) const override
610  {
611  Point 位置 = 座標;
612 
613  for (auto it : 描画する文字列.StringS)
614  {
615  DrawUTFString(位置, X拡大率, Y拡大率, it, 描画色);
616  位置.y += this->enterHeight * Y拡大率;
617  }
618 
619  return true;
620  }
621 
624  void SetImage(const std::string &文字, Image *対応画像)
625  {
626  if (Loading::isLoading)
627  {
628  Loading::AddLoading([=]{ SetImage(文字,対応画像); });
629  return;
630  }
631 
632  int charSize;
633  auto it = 文字.begin();
634 
635  if (!GetUTFSize(*it, charSize)){ return; }
636  SetHash(文字.substr(std::distance(文字.begin(), it), charSize).c_str(), charSize, 対応画像);
637  }
638 
642  void SetImageS(const std::string &文字列, ImagePack *対応画像, int 登録数)
643  {
644  if (Loading::isLoading)
645  {
646  Loading::AddLoading([=]{ SetImageS(文字列, 対応画像,登録数); });
647  return;
648  }
649 
650  int charSize;
651 
652  auto it = 文字列.begin();
653  if (!GetUTFSize(*it, charSize)){ return; }
654  std::string str = 文字列.substr(0, charSize);
655 
656  for (int a = 0; a < 登録数;++a)
657  {
658  if (!GetUTFSize(*it, charSize)){ continue; }
659  SetHash(str.c_str(),charSize,対応画像[0][a]);
660  if (str[charSize - 1] == 0xff)
661  {
662  str[charSize - 2]++;
663  str[charSize - 1] = 0;
664  }
665  else
666  {
667  str[charSize - 1]++;
668  }
669  }
670  }
671  };
672 }
bool Draw(const Point &座標, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
文字を描画.
Definition: Font.h:569
const double PAI
円周率
Definition: SDX.h:26
double y
座標
Definition: Point.h:26
Fontのインターフェース.
Definition: IFont.h:12
bool DrawExtend(const Rect &描画領域, bool 反転フラグ=false) const override
指定矩形内に描画.
Definition: Image.h:201
bool MakeBMPFont(const std::string テキストファイル名)
BMPフォントデータを生成する.
Definition: Font.h:274
void SetImageS(const std::string &文字列, ImagePack *対応画像, int 登録数)
指定した文字から連続してに対応するImageをまとめて設定.
Definition: Font.h:642
点を表す図形クラス.
Definition: Point.h:22
入出力可能なテキストかバイナリファイルを表すクラス.
Definition: File.h:28
std::vector< std::string > GetLineS()
ファイルを改行区切りで一括して読み込む.
Definition: File.h:282
TrueTypeFontとBMPFontをまとめて扱うクラス.
Definition: Font.h:24
std::vector< std::string > StringS
一行ずつの文字列.
Definition: VariadicStream.h:53
読込のみ
bool DrawRotate(const Point &座標, double 拡大率, double 角度, bool 反転フラグ=false) const override
角度、拡大率を指定して描画.
Definition: Image.h:229
bool DrawRotate(const Point &座標, double 拡大率, double 角度, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
文字を回転して描画.
Definition: Font.h:591
int GetSize() const
大きさを取得.
Definition: Font.h:534
画像データを表すクラス.
Definition: Image.h:17
色を表すクラス.
Definition: Color.h:11
bool Load(const char *フォント名, int 大きさ, int 行間=0, bool 高品質レンダリングフラグ=true)
フォントを作成する.
Definition: Font.h:182
bool LoadBMPFont(const Image &BMPフォント, const std::string テキストファイル名)
MakeBMPFontで生成したBMPフォントデータを読み込む.
Definition: Font.h:428
static void AddLoading(std::function< void(void)> &&読み込み関数)
非同期読み込み処理に追加.
Definition: Loading.h:96
int GetHeight() const
高さを取得.
Definition: Image.h:310
int GetWidth() const
幅を取得.
Definition: Image.h:304
bool Release() const
フォントハンドルをメモリから開放する.
Definition: Font.h:202
TTF_Font * GetHandle() const
フォントのハンドルを取得.
Definition: Font.h:215
static SDL_Renderer * GetHandle()
スクリーンハンドルを取得.
Definition: Screen.h:26
Image MakeImage(Color 文字色, bool 反転フラグ, const VariadicStream &描画する文字列) const
FontからImageを生成.
Definition: Font.h:221
bool DrawShadow(const Point &座標, Color 表色, Color 影色, const VariadicStream &描画する文字列) const
文字を影付きで描画.
Definition: Font.h:583
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:25
bool DrawExtend(const Point &座標, double X拡大率, double Y拡大率, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
拡大率を指定して文字を描画.
Definition: Font.h:609
double x
座標
Definition: Point.h:25
複数のImageをまとめるクラス.
Definition: ImagePack.h:14
void SetColor(const Color &描画色)
描画色を指定.
Definition: Image.h:316
bool Draw(const Point &座標, bool 反転フラグ=false) const override
指定座標に描画.
Definition: Image.h:181
int GetDrawStringWidth(const VariadicStream &幅を計算する文字列) const
描画時の幅を取得.
Definition: Font.h:540
Font(const char *フォント名, int 大きさ, int 行間=0, bool 高品質レンダリングフラグ=true)
コンストラクタ
Definition: Font.h:174
void SetImage(const std::string &文字, Image *対応画像)
指定した文字に対応するImageを設定.
Definition: Font.h:624