| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
| <title>FTGL: FTSize.cpp Source File</title> |
| <link href="doxygen.css" rel="stylesheet" type="text/css"> |
| </head><body> |
| <!-- Generated by Doxygen 1.3.6 --> |
| <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div> |
| <h1>FTSize.cpp</h1><a href="FTSize_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#include "<a class="code" href="FTSize_8h.html">FTSize.h</a>"</span> |
| 00002 |
| 00003 |
| <a name="l00004"></a><a class="code" href="classFTSize.html#a0">00004</a> <a class="code" href="classFTSize.html#a0">FTSize::FTSize</a>() |
| 00005 : ftFace(0), |
| 00006 ftSize(0), |
| 00007 size(0), |
| 00008 xResolution(0), |
| 00009 yResolution(0), |
| 00010 err(0) |
| 00011 {} |
| 00012 |
| 00013 |
| <a name="l00014"></a><a class="code" href="classFTSize.html#a1">00014</a> <a class="code" href="classFTSize.html#a1">FTSize::~FTSize</a>() |
| 00015 {} |
| 00016 |
| 00017 |
| <a name="l00018"></a><a class="code" href="classFTSize.html#a2">00018</a> <span class="keywordtype">bool</span> <a class="code" href="classFTSize.html#a3">FTSize::CharSize</a>( FT_Face* face, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pointSize, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> xRes, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> yRes ) |
| 00019 { |
| 00020 <span class="keywordflow">if</span>( size != pointSize || xResolution != xRes || yResolution != yRes) |
| 00021 { |
| 00022 err = FT_Set_Char_Size( *face, 0L, pointSize * 64, xResolution, yResolution); |
| 00023 |
| 00024 <span class="keywordflow">if</span>( !err) |
| 00025 { |
| 00026 ftFace = face; |
| 00027 size = pointSize; |
| 00028 xResolution = xRes; |
| 00029 yResolution = yRes; |
| 00030 ftSize = (*ftFace)->size; |
| 00031 } |
| 00032 <span class="keywordflow">else</span> |
| 00033 { |
| 00034 ftFace = 0; |
| 00035 size = 0; |
| 00036 xResolution = 0; |
| 00037 yResolution = 0; |
| 00038 ftSize = 0; |
| 00039 } |
| 00040 } |
| 00041 |
| 00042 <span class="keywordflow">return</span> !err; |
| 00043 } |
| 00044 |
| 00045 |
| <a name="l00046"></a><a class="code" href="classFTSize.html#a3">00046</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classFTSize.html#a3">FTSize::CharSize</a>()<span class="keyword"> const</span> |
| 00047 <span class="keyword"></span>{ |
| 00048 <span class="keywordflow">return</span> size; |
| 00049 } |
| 00050 |
| 00051 |
| <a name="l00052"></a><a class="code" href="classFTSize.html#a4">00052</a> <span class="keywordtype">float</span> <a class="code" href="classFTSize.html#a4">FTSize::Ascender</a>()<span class="keyword"> const</span> |
| 00053 <span class="keyword"></span>{ |
| 00054 <span class="keywordflow">return</span> ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.ascender) / 64.0f; |
| 00055 } |
| 00056 |
| 00057 |
| <a name="l00058"></a><a class="code" href="classFTSize.html#a5">00058</a> <span class="keywordtype">float</span> <a class="code" href="classFTSize.html#a5">FTSize::Descender</a>()<span class="keyword"> const</span> |
| 00059 <span class="keyword"></span>{ |
| 00060 <span class="keywordflow">return</span> ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.descender) / 64.0f; |
| 00061 } |
| 00062 |
| 00063 |
| <a name="l00064"></a><a class="code" href="classFTSize.html#a6">00064</a> <span class="keywordtype">float</span> <a class="code" href="classFTSize.html#a6">FTSize::Height</a>()<span class="keyword"> const</span> |
| 00065 <span class="keyword"></span>{ |
| 00066 <span class="keywordflow">if</span>( 0 == ftSize) |
| 00067 { |
| 00068 <span class="keywordflow">return</span> 0.0f; |
| 00069 } |
| 00070 |
| 00071 <span class="keywordflow">if</span>( FT_IS_SCALABLE((*ftFace))) |
| 00072 { |
| 00073 <span class="keywordflow">return</span> ( (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin) * ( (<span class="keywordtype">float</span>)ftSize->metrics.y_ppem / (<span class="keywordtype">float</span>)(*ftFace)->units_per_EM); |
| 00074 } |
| 00075 <span class="keywordflow">else</span> |
| 00076 { |
| 00077 <span class="keywordflow">return</span> static_cast<float>( ftSize->metrics.height) / 64.0f; |
| 00078 } |
| 00079 } |
| 00080 |
| 00081 |
| <a name="l00082"></a><a class="code" href="classFTSize.html#a7">00082</a> <span class="keywordtype">float</span> <a class="code" href="classFTSize.html#a7">FTSize::Width</a>()<span class="keyword"> const</span> |
| 00083 <span class="keyword"></span>{ |
| 00084 <span class="keywordflow">if</span>( 0 == ftSize) |
| 00085 { |
| 00086 <span class="keywordflow">return</span> 0.0f; |
| 00087 } |
| 00088 |
| 00089 <span class="keywordflow">if</span>( FT_IS_SCALABLE((*ftFace))) |
| 00090 { |
| 00091 <span class="keywordflow">return</span> ( (*ftFace)->bbox.xMax - (*ftFace)->bbox.xMin) * ( static_cast<float>(ftSize->metrics.x_ppem) / static_cast<float>((*ftFace)->units_per_EM)); |
| 00092 } |
| 00093 <span class="keywordflow">else</span> |
| 00094 { |
| 00095 <span class="keywordflow">return</span> static_cast<float>( ftSize->metrics.max_advance) / 64.0f; |
| 00096 } |
| 00097 } |
| 00098 |
| 00099 |
| <a name="l00100"></a><a class="code" href="classFTSize.html#a8">00100</a> <span class="keywordtype">float</span> <a class="code" href="classFTSize.html#a8">FTSize::Underline</a>()<span class="keyword"> const</span> |
| 00101 <span class="keyword"></span>{ |
| 00102 <span class="keywordflow">return</span> 0.0f; |
| 00103 } |
| 00104 |
| </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Dec 5 22:24:06 2004 for FTGL by |
| <a href="http://www.doxygen.org/index.html"> |
| <img src="doxygen.png" alt="doxygen" align="middle" border=0 > |
| </a>1.3.6 </small></address> |
| </body> |
| </html> |