YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
chrmap.cpp
浏览该文件的文档.
1 /*
2  © 2009-2013 FrankHB.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
28 #include "CHRLib/YModules.h"
29 #include YFM_CHRLib_CharacterMapping
30 
31 namespace CHRLib
32 {
33 
34 using namespace CharSet;
35 
36 size_t
38 {
39  switch(cp)
40  {
41  case csASCII:
42  return 1;
43  case csUnicode:
44  case csUTF16BE:
45  case csUTF16LE:
46  case csUTF16:
47  return 2;
48  case csUCS4:
49  case csUTF32:
50  case csUTF32BE:
51  case csUTF32LE:
52  return 4;
53  default:
54  return 0;
55  }
56 }
57 
58 size_t
60 {
61  const auto r = FetchFixedCharWidth(cp);
62 
63  return r == 0 ? FetchMaxVariantCharWidth(cp) : r;
64 }
65 
66 size_t
68 {
69  switch(cp)
70  {
71  case csGBK:
72  return 2;
73  case csGB18030:
74  case csUTF8:
75  return 4;
76  default:
77  return 0;
78  }
79 }
80 
81 } // namespace CHRLib;
82 
YF_API size_t FetchMaxVariantCharWidth(Encoding)
取指定变长编码的最大字符宽度。
Definition: chrmap.cpp:67
YF_API size_t FetchFixedCharWidth(Encoding)
取指定固定编码的固定字符宽度。
Definition: chrmap.cpp:37
YF_API size_t FetchMaxCharWidth(Encoding)
取指定编码的最大字符宽度。
Definition: chrmap.cpp:59
bounds & r
Definition: ydraw.h:220