Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 1506

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Crystal Space 1.2.1: csplugincommon/canvas/draw_text.h Source File (Crystal Space 1.2.1 Public API Reference)</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="head">
 <tr height="59">
  <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td>
  <td class="head"><h2>Public API Reference</h2></td>
 </tr>
 <tr height="11">
  <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td>
 </tr>
</table>
<div class="content">
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li><a href="classes.html"><span>Classes</span></a></li>
    <li class="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<h1>csplugincommon/canvas/draw_text.h</h1><a href="draw__text_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">    Copyright (C) 2004 by Jorrit Tyberghein</span>
<a name="l00003"></a>00003 <span class="comment">              (C) 2004 by Frank Richter</span>
<a name="l00004"></a>00004 <span class="comment"></span>
<a name="l00005"></a>00005 <span class="comment">    This library is free software; you can redistribute it and/or</span>
<a name="l00006"></a>00006 <span class="comment">    modify it under the terms of the GNU Library General Public</span>
<a name="l00007"></a>00007 <span class="comment">    License as published by the Free Software Foundation; either</span>
<a name="l00008"></a>00008 <span class="comment">    version 2 of the License, or (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment"></span>
<a name="l00010"></a>00010 <span class="comment">    This library is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00013"></a>00013 <span class="comment">    Library General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">    You should have received a copy of the GNU Library General Public</span>
<a name="l00016"></a>00016 <span class="comment">    License along with this library; if not, write to the Free</span>
<a name="l00017"></a>00017 <span class="comment">    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span>
<a name="l00018"></a>00018 <span class="comment">*/</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef __CS_CSPLUGINCOMMON_CANVAS_DRAW_TEXT_H__</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define __CS_CSPLUGINCOMMON_CANVAS_DRAW_TEXT_H__</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="draw__common_8h.html" title="Common software canvas drawing tools.">csplugincommon/canvas/draw_common.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="softfontcache_8h.html" title="Font cache base class for software canvases.">csplugincommon/canvas/softfontcache.h</a>"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="csuctransform_8h.html" title="Converter between UTF encodings.">csutil/csuctransform.h</a>"</span>
<a name="l00030"></a>00030 
<a name="l00041"></a>00041 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Tpixel, <span class="keyword">class</span> Tpixmixer1, <span class="keyword">class</span> Tpixmixer2, <span class="keyword">class</span> Tpixmixer3&gt;
<a name="l00042"></a><a class="code" href="classcsG2DDrawText.html">00042</a> <span class="keyword">class </span><a class="code" href="classcsG2DDrawText.html" title="Class to write some text.">csG2DDrawText</a>
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044 <span class="keyword">public</span>:
<a name="l00045"></a><a class="code" href="classcsG2DDrawText.html#fee1943b1499efe3971fca379ee741da">00045</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classcsG2DDrawText.html#fee1943b1499efe3971fca379ee741da">DrawText</a> (<a class="code" href="classcsSoftFontCache.html" title="Font cache base class for software canvases.">csSoftFontCache</a>* cache, <a class="code" href="structiFont.html" title="A font object.">iFont</a>* font, <span class="keywordtype">int</span> pen_x, <span class="keywordtype">int</span> pen_y,
<a name="l00046"></a>00046     Tpixel fg, <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> alphaFG, Tpixel bg, <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> alphaBG, <span class="keyword">const</span> <span class="keywordtype">void</span>* text, 
<a name="l00047"></a>00047     <span class="keywordtype">bool</span> isWide, <a class="code" href="group__util.html#g91ad9478d81a7aaf2593e8d9c3d06a14" title="Shortcut for default unsigned int.">uint</a> flags)
<a name="l00048"></a>00048   {
<a name="l00049"></a>00049     <a class="code" href="classcsGraphics2D.html" title="This is the base class for 2D canvases.">csGraphics2D</a>* G2D = cache-&gt;<a class="code" href="classcsSoftFontCache.html#6111a0ed75c70512827b2d88fdc92c5e">G2D</a>;
<a name="l00050"></a>00050     <span class="keyword">const</span> <span class="keywordtype">int</span> ClipX1 = cache-&gt;<a class="code" href="classcsFontCache.html#90726d3aa3b492044e5c9412b4c23333" title="the current clipping rect">ClipX1</a>, ClipY1 = cache-&gt;<a class="code" href="classcsFontCache.html#a4ad143f29be9dd6ae051021511bf35d">ClipY1</a>, 
<a name="l00051"></a>00051       ClipX2 = cache-&gt;<a class="code" href="classcsFontCache.html#f1af1f7bf2c53aaa3b7d48dad4e03d08">ClipX2</a>, ClipY2 = cache-&gt;<a class="code" href="classcsFontCache.html#cfa9dd29fb4e01a6d3f420f9b4c9ee02">ClipY2</a>;
<a name="l00052"></a>00052     Tpixmixer1 mixerFG (G2D, fg, alphaFG);
<a name="l00053"></a>00053     Tpixmixer2 mixerBG (G2D, bg, alphaBG);
<a name="l00054"></a>00054     
<a name="l00055"></a>00055     <span class="keywordflow">if</span> (!font)
<a name="l00056"></a>00056       <span class="keywordflow">return</span>;
<a name="l00057"></a>00057     
<a name="l00058"></a>00058     <span class="keywordflow">if</span> (!(flags &amp; <a class="code" href="group__gfx2d.html#gga57e16cd48de3b9a989056ff8df26f8454886ddf8e7152c7de68ce148eeba005" title="Write by baseline, x and y are treated as the pen position on a baseline.">CS_WRITE_BASELINE</a>)) pen_y += font-&gt;<a class="code" href="structiFont.html#4bbbbf7fac4f9eaa28e1bfaa7c30cdaf" title="Get the font&amp;#39;s ascent in pixels.">GetAscent</a> ();
<a name="l00059"></a>00059   
<a name="l00060"></a>00060     <a class="code" href="structcsFontCache_1_1KnownFont.html" title="A font known to the cache.">csSoftFontCache::KnownFont</a>* knownFont = cache-&gt;<a class="code" href="classcsFontCache.html#b1e554e9aecffc78c9bdb61d5ebf3335" title="Request whether a font is known already.">GetCachedFont</a> (font);
<a name="l00061"></a>00061     <span class="keywordflow">if</span> (knownFont == 0) knownFont = cache-&gt;<a class="code" href="classcsFontCache.html#c0a20b2fe3fc29d13c78a98b9a0220c5" title="Set up stuff to cache glyphs of this font.">CacheFont</a> (font);
<a name="l00062"></a>00062   
<a name="l00063"></a>00063     <span class="keywordtype">size_t</span> textLen = isWide ? wcslen ((<span class="keywordtype">wchar_t</span>*)text) : strlen ((<span class="keywordtype">char</span>*)text);
<a name="l00064"></a>00064     <span class="keywordtype">int</span> charW, charH, advance = 0;
<a name="l00065"></a>00065     <span class="keywordtype">bool</span> firstchar = <span class="keyword">true</span>;
<a name="l00066"></a>00066     <span class="keywordflow">while</span> (textLen &gt; 0)
<a name="l00067"></a>00067     {
<a name="l00068"></a>00068       <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> glyph;
<a name="l00069"></a>00069       <span class="keywordflow">if</span> (isWide)
<a name="l00070"></a>00070       {
<a name="l00071"></a>00071         <span class="keywordtype">int</span> skip = <a class="code" href="classcsUnicodeTransform.html#24c171b2e92da381499801aba4422106" title="Decode an Unicode code point encoded in UTF-8.">csUnicodeTransform::Decode</a> ((<span class="keywordtype">wchar_t</span>*)text, textLen, glyph, 0);
<a name="l00072"></a>00072         <span class="keywordflow">if</span> (skip == 0) <span class="keywordflow">break</span>;
<a name="l00073"></a>00073   
<a name="l00074"></a>00074         text = ((<span class="keywordtype">wchar_t</span>*)text + skip);
<a name="l00075"></a>00075         textLen -= skip;
<a name="l00076"></a>00076       }
<a name="l00077"></a>00077       <span class="keywordflow">else</span>
<a name="l00078"></a>00078       {
<a name="l00079"></a>00079         <span class="keywordtype">int</span> skip = <a class="code" href="classcsUnicodeTransform.html#21e5a75955302bbc73751a4dc459af54" title="Decode an Unicode code point encoded in UTF-8.">csUnicodeTransform::UTF8Decode</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>*)text, textLen, glyph, 0);
<a name="l00080"></a>00080         <span class="keywordflow">if</span> (skip == 0) <span class="keywordflow">break</span>;
<a name="l00081"></a>00081   
<a name="l00082"></a>00082         text = ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>*)text + skip);
<a name="l00083"></a>00083         textLen -= skip;
<a name="l00084"></a>00084       }
<a name="l00085"></a>00085   
<a name="l00086"></a>00086       <a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html">csSoftFontCache::SoftGlyphCacheData</a>* cacheData = 
<a name="l00087"></a>00087         (<a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html">csSoftFontCache::SoftGlyphCacheData</a>*)cache-&gt;<a class="code" href="classcsFontCache.html#61305de121a1d7b55ba5371275095f8e" title="Store glyph-specific information.">CacheGlyph</a> (knownFont, 
<a name="l00088"></a>00088         glyph, flags);
<a name="l00089"></a>00089       <span class="keywordflow">if</span> (!cacheData-&gt;<a class="code" href="structcsFontCache_1_1GlyphCacheData.html#110992ec2310e52196321b8deffb76ab" title="Does this font have this glyph?">hasGlyph</a>) 
<a name="l00090"></a>00090       {
<a name="l00091"></a>00091         <span class="comment">// fall back to the default glyph (CS_FONT_DEFAULT_GLYPH)</span>
<a name="l00092"></a>00092         cacheData = (<a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html">csSoftFontCache::SoftGlyphCacheData</a>*)cache-&gt;<a class="code" href="classcsFontCache.html#61305de121a1d7b55ba5371275095f8e" title="Store glyph-specific information.">CacheGlyph</a> (
<a name="l00093"></a>00093           knownFont, <a class="code" href="group__gfx2d.html#g3721ddc874319a718319041805acba34" title="The default char, drawn in case a glyph wasn&amp;#39;t present in the font.">CS_FONT_DEFAULT_GLYPH</a>, flags);
<a name="l00094"></a>00094         <span class="keywordflow">if</span> (!cacheData-&gt;<a class="code" href="structcsFontCache_1_1GlyphCacheData.html#110992ec2310e52196321b8deffb76ab" title="Does this font have this glyph?">hasGlyph</a>) <span class="keywordflow">continue</span>;
<a name="l00095"></a>00095       }
<a name="l00096"></a>00096   
<a name="l00097"></a>00097       <a class="code" href="structcsBitmapMetrics.html" title="Metrics for a glyph that are dependent from whether a simple or antialiased image...">csBitmapMetrics</a>* bmetrics;
<a name="l00098"></a>00098       <span class="keywordflow">if</span> (cacheData-&gt;<a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html#746fd4166df2603b83a7e46a3df7f6e0">glyphAlphaDataBuf</a>.<a class="code" href="classcsRef.html#620198af96e2f744bab6207d9c546ed8" title="Smart pointer validity check.">IsValid</a>())
<a name="l00099"></a>00099       {
<a name="l00100"></a>00100         bmetrics = &amp;cacheData-&gt;<a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html#ea2a4006e5374fefbae5ac7e650086d8">alphaMetrics</a>;
<a name="l00101"></a>00101       }
<a name="l00102"></a>00102       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cacheData-&gt;<a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html#f7933549ac26e3054d4d30ef323a295f">glyphDataBuf</a>.<a class="code" href="classcsRef.html#620198af96e2f744bab6207d9c546ed8" title="Smart pointer validity check.">IsValid</a>())
<a name="l00103"></a>00103       {
<a name="l00104"></a>00104         bmetrics = &amp;cacheData-&gt;<a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html#c52ddd294102d54be1a830ea320ad67a">bitmapMetrics</a>;
<a name="l00105"></a>00105       }
<a name="l00106"></a>00106       <span class="keywordflow">else</span>
<a name="l00107"></a>00107         <span class="keywordflow">continue</span>;
<a name="l00108"></a>00108 
<a name="l00109"></a>00109       <span class="keyword">register</span> <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> *CharImageAlpha = cacheData-&gt;<a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html#e4e306d6c020c90649cc2ae576f4f768">glyphAlphaData</a>;
<a name="l00110"></a>00110       <span class="keyword">register</span> <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> *CharImage = cacheData-&gt;<a class="code" href="structcsSoftFontCache_1_1SoftGlyphCacheData.html#4bd2ffcc0b58dc478b7bd65d026d880c">glyphData</a>;
<a name="l00111"></a>00111   
<a name="l00112"></a>00112       charW = bmetrics-&gt;<a class="code" href="structcsBitmapMetrics.html#0476b883a91814827a3a74b9478e46c1" title="Width of the glyph image.">width</a>;
<a name="l00113"></a>00113       charH = bmetrics-&gt;<a class="code" href="structcsBitmapMetrics.html#04f8a98cd4bb13e503dc04d2a2a74870" title="Height of the glyph image.">height</a>;
<a name="l00114"></a>00114       
<a name="l00115"></a>00115       <span class="keywordtype">int</span> y = pen_y - bmetrics-&gt;<a class="code" href="structcsBitmapMetrics.html#60c8d7a93ceeb76dd1b7385a681cd227" title="Y offset of the image to the pen position.">top</a>;
<a name="l00116"></a>00116       
<a name="l00117"></a>00117       <span class="comment">// If we are advancing more than the last char was wide, we have to</span>
<a name="l00118"></a>00118       <span class="comment">// fill the 'gap' with bg.</span>
<a name="l00119"></a>00119       
<a name="l00120"></a>00120       <span class="keywordtype">int</span> x = pen_x - (advance &gt; 0 ? advance : 0) + (bmetrics-&gt;<a class="code" href="structcsBitmapMetrics.html#decd5c98d4de92f88d8b37460cb2bacb" title="X offset of the image to the pen position.">left</a> &lt; 0 ? bmetrics-&gt;<a class="code" href="structcsBitmapMetrics.html#decd5c98d4de92f88d8b37460cb2bacb" title="X offset of the image to the pen position.">left</a> : 0);
<a name="l00121"></a>00121       advance += bmetrics-&gt;<a class="code" href="structcsBitmapMetrics.html#decd5c98d4de92f88d8b37460cb2bacb" title="X offset of the image to the pen position.">left</a>;
<a name="l00122"></a>00122       
<a name="l00123"></a>00123       <span class="comment">// Hack: in case the first char has a negative left bitmap offset,</span>
<a name="l00124"></a>00124       <span class="comment">// some of the background isn't drawn. Fix that.</span>
<a name="l00125"></a>00125       <span class="keywordflow">if</span> (firstchar)
<a name="l00126"></a>00126       {
<a name="l00127"></a>00127         <span class="keywordflow">if</span> (advance &lt; 0)
<a name="l00128"></a>00128         {
<a name="l00129"></a>00129           advance = 0;
<a name="l00130"></a>00130         }
<a name="l00131"></a>00131         firstchar = <span class="keyword">false</span>;
<a name="l00132"></a>00132       }
<a name="l00133"></a>00133      
<a name="l00134"></a>00134       <span class="keywordflow">if</span> (alphaBG != 0)
<a name="l00135"></a>00135       {
<a name="l00136"></a>00136         <span class="keywordflow">while</span> (advance &gt; 0)
<a name="l00137"></a>00137         {
<a name="l00138"></a>00138           <span class="keywordflow">if</span> (x &gt;= ClipX2)
<a name="l00139"></a>00139             <span class="keywordflow">return</span>;
<a name="l00140"></a>00140     
<a name="l00141"></a>00141           <span class="keywordtype">int</span> cury = y;
<a name="l00142"></a>00142           <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; charH; i++, cury++)
<a name="l00143"></a>00143           {
<a name="l00144"></a>00144             <span class="keywordflow">if</span> ((cury &lt; ClipY1) || (cury &gt;= ClipY2)) <span class="keywordflow">continue</span>;
<a name="l00145"></a>00145             <span class="keyword">register</span> Tpixel *VRAM = (Tpixel*)G2D-&gt;<a class="code" href="classcsGraphics2D.html#68beac8a1ae92e157a916b9d55f9f8ea" title="Same but exposed through iGraphics2D interface.">GetPixelAt</a> (x, cury);
<a name="l00146"></a>00146             <span class="keywordflow">if</span> (x &gt;= ClipX1) mixerBG.Mix (*VRAM);
<a name="l00147"></a>00147           }
<a name="l00148"></a>00148           x++; advance--;
<a name="l00149"></a>00149         }
<a name="l00150"></a>00150       }
<a name="l00151"></a>00151       <span class="keywordflow">else</span>
<a name="l00152"></a>00152       {
<a name="l00153"></a>00153         <span class="keywordflow">if</span> (advance &gt; 0)
<a name="l00154"></a>00154         {
<a name="l00155"></a>00155           x += advance;
<a name="l00156"></a>00156           advance = 0;
<a name="l00157"></a>00157         }
<a name="l00158"></a>00158       }
<a name="l00159"></a>00159   
<a name="l00160"></a>00160       <span class="keywordflow">if</span> (x &gt;= ClipX2)
<a name="l00161"></a>00161         <span class="keywordflow">return</span>;
<a name="l00162"></a>00162   
<a name="l00163"></a>00163       <span class="comment">// If character is completely outside the clipping rectangle, continue</span>
<a name="l00164"></a>00164       <span class="keywordflow">if</span> (!((x + charW &lt;= ClipX1) || (x &gt;= ClipX2)
<a name="l00165"></a>00165        || (y + charH &lt;= ClipY1) || (y &gt;= ClipY2)))
<a name="l00166"></a>00166       {
<a name="l00167"></a>00167         <span class="keywordtype">int</span> cury = y;
<a name="l00168"></a>00168     
<a name="l00169"></a>00169         <span class="keywordtype">int</span> oldAdvance = advance;
<a name="l00170"></a>00170         <span class="comment">// If character should not be clipped, go the fast path</span>
<a name="l00171"></a>00171         <span class="keywordflow">if</span> ((x &lt; ClipX1) || (x + charW &gt;= ClipX2)
<a name="l00172"></a>00172          || (y &lt; ClipY1) || (y + charH &gt;= ClipY2))
<a name="l00173"></a>00173         {
<a name="l00174"></a>00174           <span class="comment">// Perform full clipping</span>
<a name="l00175"></a>00175           <span class="keywordtype">int</span> lX = x &lt; ClipX1 ? ClipX1 - x : 0;
<a name="l00176"></a>00176           <span class="keywordtype">int</span> rX = x + charW &gt;= ClipX2 ? ClipX2 - x : charW;
<a name="l00177"></a>00177           <span class="keywordtype">int</span> lBytes = CharImageAlpha ? lX : lX &gt;&gt; 3;
<a name="l00178"></a>00178           <span class="keywordtype">int</span> shiftX = CharImageAlpha ? 0 : lX &amp; 7;
<a name="l00179"></a>00179           <span class="keywordtype">int</span> bbl = CharImageAlpha ? charW : (charW + 7) / 8; <span class="comment">// bytes per line</span>
<a name="l00180"></a>00180           <span class="keywordtype">int</span> lAbsX = x + lX;
<a name="l00181"></a>00181           <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> *p = CharImageAlpha ? CharImageAlpha - bbl : CharImage - bbl;
<a name="l00182"></a>00182           
<a name="l00183"></a>00183           <span class="keywordflow">if</span> (CharImageAlpha)
<a name="l00184"></a>00184           {
<a name="l00185"></a>00185             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; charH; i++, cury++)
<a name="l00186"></a>00186             {
<a name="l00187"></a>00187               advance = oldAdvance;
<a name="l00188"></a>00188               p += bbl;
<a name="l00189"></a>00189               <span class="keywordflow">if</span> ((cury &lt; ClipY1) || (cury &gt;= ClipY2)) 
<a name="l00190"></a>00190               {
<a name="l00191"></a>00191                 <span class="keywordflow">if</span> (advance &lt; 0) advance = MIN(0, advance + (rX - lX));
<a name="l00192"></a>00192                 <span class="keywordflow">continue</span>;
<a name="l00193"></a>00193               }
<a name="l00194"></a>00194               CharImageAlpha = p + lBytes;
<a name="l00195"></a>00195               <span class="keyword">register</span> <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> CharLine = (*CharImageAlpha++) &lt;&lt; shiftX;
<a name="l00196"></a>00196               <span class="keyword">register</span> Tpixel* VRAM = (Tpixel*)G2D-&gt;<a class="code" href="classcsGraphics2D.html#68beac8a1ae92e157a916b9d55f9f8ea" title="Same but exposed through iGraphics2D interface.">GetPixelAt</a> (lAbsX, cury);
<a name="l00197"></a>00197               <span class="comment">// If we are advancing less than the last char was wide, the current</span>
<a name="l00198"></a>00198               <span class="comment">// and last chars overlap. So we can't draw opaque, but have to draw</span>
<a name="l00199"></a>00199               <span class="comment">// transparent instead.</span>
<a name="l00200"></a>00200               <span class="keywordflow">if</span> (advance &gt;= 0)
<a name="l00201"></a>00201               {
<a name="l00202"></a>00202                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = lX; j &lt; rX; j++)
<a name="l00203"></a>00203                 {
<a name="l00204"></a>00204                   <span class="keywordflow">if</span> (CharLine == 0xff)
<a name="l00205"></a>00205                   {
<a name="l00206"></a>00206                     mixerFG.Mix (*VRAM);
<a name="l00207"></a>00207                   }
<a name="l00208"></a>00208                   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (CharLine == 0x00)
<a name="l00209"></a>00209                   {
<a name="l00210"></a>00210                     mixerBG.Mix (*VRAM);
<a name="l00211"></a>00211                   }
<a name="l00212"></a>00212                   <span class="keywordflow">else</span>
<a name="l00213"></a>00213                   {
<a name="l00214"></a>00214                     <span class="comment">// @@@ Could be more optimal, probably.</span>
<a name="l00215"></a>00215                     Tpixel mixedFG = *VRAM;
<a name="l00216"></a>00216                     mixerFG.Mix (mixedFG);
<a name="l00217"></a>00217                     mixerBG.Mix (*VRAM);
<a name="l00218"></a>00218                     
<a name="l00219"></a>00219                     Tpixmixer3 mixer (G2D, mixedFG, CharLine);
<a name="l00220"></a>00220                     mixer.Mix (*VRAM);
<a name="l00221"></a>00221                   }
<a name="l00222"></a>00222                   VRAM++;
<a name="l00223"></a>00223                   <span class="keywordflow">if</span> (j &lt; rX-1) CharLine = (*CharImageAlpha++);
<a name="l00224"></a>00224                 } <span class="comment">/* endfor */</span>
<a name="l00225"></a>00225               }
<a name="l00226"></a>00226               <span class="keywordflow">else</span>
<a name="l00227"></a>00227               {
<a name="l00228"></a>00228                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = lX; j &lt; rX; j++)
<a name="l00229"></a>00229                 {
<a name="l00230"></a>00230                   <span class="keywordflow">if</span> (CharLine == 0xff)
<a name="l00231"></a>00231                   {
<a name="l00232"></a>00232                     mixerFG.Mix (*VRAM);
<a name="l00233"></a>00233                   }
<a name="l00234"></a>00234                   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (CharLine != 0x00)
<a name="l00235"></a>00235                   {
<a name="l00236"></a>00236                     <span class="comment">// @@@ Could be more optimal, probably.</span>
<a name="l00237"></a>00237                     Tpixel mixedFG = *VRAM;
<a name="l00238"></a>00238                     mixerFG.Mix (mixedFG);
<a name="l00239"></a>00239                     
<a name="l00240"></a>00240                     Tpixmixer3 mixer (G2D, mixedFG, CharLine);
<a name="l00241"></a>00241                     mixer.Mix (*VRAM);
<a name="l00242"></a>00242                   }
<a name="l00243"></a>00243                   VRAM++;
<a name="l00244"></a>00244                   <span class="keywordflow">if</span> (j &lt; rX-1) CharLine = (*CharImageAlpha++);
<a name="l00245"></a>00245                 } <span class="comment">/* endfor */</span>
<a name="l00246"></a>00246                 <span class="keywordflow">if</span> (advance &lt; 0) advance++;
<a name="l00247"></a>00247               }
<a name="l00248"></a>00248             }
<a name="l00249"></a>00249           }
<a name="l00250"></a>00250           <span class="keywordflow">else</span> <span class="keywordflow">if</span> (CharImage)
<a name="l00251"></a>00251           {
<a name="l00252"></a>00252             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; charH; i++, cury++)
<a name="l00253"></a>00253             {
<a name="l00254"></a>00254               advance = oldAdvance;
<a name="l00255"></a>00255               p += bbl;
<a name="l00256"></a>00256               <span class="keywordflow">if</span> ((cury &lt; ClipY1) || (cury &gt;= ClipY2))
<a name="l00257"></a>00257               {
<a name="l00258"></a>00258                 <span class="keywordflow">if</span> (advance &lt; 0) advance = MIN(0, advance + (rX - lX));
<a name="l00259"></a>00259                 <span class="keywordflow">continue</span>;
<a name="l00260"></a>00260               }
<a name="l00261"></a>00261               CharImage = p + lBytes;
<a name="l00262"></a>00262               <span class="keyword">register</span> <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> CharLine = (*CharImage++) &lt;&lt; shiftX;
<a name="l00263"></a>00263               <span class="keyword">register</span> Tpixel* VRAM = (Tpixel*)G2D-&gt;<a class="code" href="classcsGraphics2D.html#68beac8a1ae92e157a916b9d55f9f8ea" title="Same but exposed through iGraphics2D interface.">GetPixelAt</a> (lAbsX, cury);
<a name="l00264"></a>00264               <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = lX; j &lt; rX; j++)
<a name="l00265"></a>00265               {
<a name="l00266"></a>00266                 <span class="keywordflow">if</span> (advance &gt;= 0)
<a name="l00267"></a>00267                 {
<a name="l00268"></a>00268                   <span class="keywordflow">if</span> (CharLine &amp; 0x80)
<a name="l00269"></a>00269                     mixerFG.Mix (*VRAM++);
<a name="l00270"></a>00270                   <span class="keywordflow">else</span>
<a name="l00271"></a>00271                     mixerBG.Mix (*VRAM++);
<a name="l00272"></a>00272                 }
<a name="l00273"></a>00273                 <span class="keywordflow">else</span>
<a name="l00274"></a>00274                 {
<a name="l00275"></a>00275                   <span class="keywordflow">if</span> (CharLine &amp; 0x80)
<a name="l00276"></a>00276                     mixerFG.Mix (*VRAM++);
<a name="l00277"></a>00277                   <span class="keywordflow">else</span>
<a name="l00278"></a>00278                     VRAM++;
<a name="l00279"></a>00279                   advance++;
<a name="l00280"></a>00280                 }
<a name="l00281"></a>00281                 <span class="keywordflow">if</span> ((j &amp; 7) == 7)
<a name="l00282"></a>00282                   CharLine = (*CharImage++);
<a name="l00283"></a>00283                 <span class="keywordflow">else</span>
<a name="l00284"></a>00284                   CharLine += CharLine;
<a name="l00285"></a>00285               } <span class="comment">/* endfor */</span>
<a name="l00286"></a>00286             }
<a name="l00287"></a>00287           }
<a name="l00288"></a>00288         }
<a name="l00289"></a>00289         <span class="keywordflow">else</span>
<a name="l00290"></a>00290         {
<a name="l00291"></a>00291           <span class="comment">// no clipping</span>
<a name="l00292"></a>00292           <span class="keywordflow">if</span> (CharImageAlpha)
<a name="l00293"></a>00293           {
<a name="l00294"></a>00294             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; charH; i++, cury++)
<a name="l00295"></a>00295             {
<a name="l00296"></a>00296               advance = oldAdvance;
<a name="l00297"></a>00297               <span class="keyword">register</span> Tpixel* VRAM = (Tpixel*)G2D-&gt;<a class="code" href="classcsGraphics2D.html#68beac8a1ae92e157a916b9d55f9f8ea" title="Same but exposed through iGraphics2D interface.">GetPixelAt</a> (x, cury);
<a name="l00298"></a>00298               <span class="keyword">register</span> <span class="keywordtype">unsigned</span> pixW = charW;
<a name="l00299"></a>00299               <span class="keyword">register</span> <span class="keywordtype">int</span> pix;
<a name="l00300"></a>00300               <span class="keywordflow">for</span> (pix = pixW; pix &gt; 0; pix--)
<a name="l00301"></a>00301               {
<a name="l00302"></a>00302                 <span class="keyword">register</span> <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> CharLine = (*CharImageAlpha++);
<a name="l00303"></a>00303                 <span class="keywordflow">if</span> (advance &lt; 0)
<a name="l00304"></a>00304                 {
<a name="l00305"></a>00305                   <span class="keywordflow">if</span> (CharLine == 0xff)
<a name="l00306"></a>00306                   {
<a name="l00307"></a>00307                     mixerFG.Mix (*VRAM);
<a name="l00308"></a>00308                   }
<a name="l00309"></a>00309                   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (CharLine != 0x00)
<a name="l00310"></a>00310                   {
<a name="l00311"></a>00311                     <span class="comment">// @@@ Could be more optimal, probably.</span>
<a name="l00312"></a>00312                     Tpixel mixedFG = *VRAM;
<a name="l00313"></a>00313                     mixerFG.Mix (mixedFG);
<a name="l00314"></a>00314                     
<a name="l00315"></a>00315                     Tpixmixer3 mixer (G2D, mixedFG, CharLine);
<a name="l00316"></a>00316                     mixer.Mix (*VRAM);
<a name="l00317"></a>00317                   }
<a name="l00318"></a>00318                 }
<a name="l00319"></a>00319                 <span class="keywordflow">else</span>
<a name="l00320"></a>00320                 {
<a name="l00321"></a>00321                   <span class="keywordflow">if</span> (CharLine == 0xff)
<a name="l00322"></a>00322                   {
<a name="l00323"></a>00323                     mixerFG.Mix (*VRAM);
<a name="l00324"></a>00324                   }
<a name="l00325"></a>00325                   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (CharLine == 0x00)
<a name="l00326"></a>00326                   {
<a name="l00327"></a>00327                     mixerBG.Mix (*VRAM);
<a name="l00328"></a>00328                   }
<a name="l00329"></a>00329                   <span class="keywordflow">else</span>
<a name="l00330"></a>00330                   {
<a name="l00331"></a>00331                     <span class="comment">// @@@ Could be more optimal, probably.</span>
<a name="l00332"></a>00332                     Tpixel mixedFG = *VRAM;
<a name="l00333"></a>00333                     mixerFG.Mix (mixedFG);
<a name="l00334"></a>00334                     mixerBG.Mix (*VRAM);
<a name="l00335"></a>00335                     
<a name="l00336"></a>00336                     Tpixmixer3 mixer (G2D, mixedFG, CharLine);
<a name="l00337"></a>00337                     mixer.Mix (*VRAM);
<a name="l00338"></a>00338                   }
<a name="l00339"></a>00339                 }
<a name="l00340"></a>00340                 <span class="keywordflow">if</span> (advance &lt; 0) advance++;
<a name="l00341"></a>00341                 VRAM++;
<a name="l00342"></a>00342               }
<a name="l00343"></a>00343             }
<a name="l00344"></a>00344           }
<a name="l00345"></a>00345           <span class="keywordflow">else</span> <span class="keywordflow">if</span> (CharImage)
<a name="l00346"></a>00346           {
<a name="l00347"></a>00347             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; charH; i++, cury++)
<a name="l00348"></a>00348             {
<a name="l00349"></a>00349               <span class="keyword">register</span> Tpixel* VRAM = (Tpixel*)G2D-&gt;<a class="code" href="classcsGraphics2D.html#68beac8a1ae92e157a916b9d55f9f8ea" title="Same but exposed through iGraphics2D interface.">GetPixelAt</a> (x, cury);
<a name="l00350"></a>00350               <span class="keyword">register</span> <span class="keywordtype">unsigned</span> pixW = charW;
<a name="l00351"></a>00351               <span class="keywordflow">while</span> (pixW)
<a name="l00352"></a>00352               {
<a name="l00353"></a>00353                 <span class="keyword">register</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> CharLine = *CharImage++;
<a name="l00354"></a>00354                 <span class="keyword">register</span> <span class="keywordtype">int</span> pix;
<a name="l00355"></a>00355                 <span class="keywordflow">for</span> (pix = pixW &lt; 8 ? pixW : 8, pixW -= pix; CharLine &amp;&amp; pix; pix--)
<a name="l00356"></a>00356                 {
<a name="l00357"></a>00357                   <span class="keywordflow">if</span> (advance &lt; 0)
<a name="l00358"></a>00358                   {
<a name="l00359"></a>00359                     <span class="keywordflow">if</span> (CharLine &amp; 0x80)
<a name="l00360"></a>00360                       mixerFG.Mix (*VRAM++);
<a name="l00361"></a>00361                     <span class="keywordflow">else</span>
<a name="l00362"></a>00362                       VRAM++;
<a name="l00363"></a>00363                     <span class="comment">// Addition is faster than shift, at least on i586+</span>
<a name="l00364"></a>00364                     CharLine += CharLine;
<a name="l00365"></a>00365                   }
<a name="l00366"></a>00366                   <span class="keywordflow">else</span>
<a name="l00367"></a>00367                   {
<a name="l00368"></a>00368                     <span class="keywordflow">if</span> (CharLine &amp; 0x80)
<a name="l00369"></a>00369                       mixerFG.Mix (*VRAM++);
<a name="l00370"></a>00370                     <span class="keywordflow">else</span>
<a name="l00371"></a>00371                       mixerBG.Mix (*VRAM++);
<a name="l00372"></a>00372                     <span class="comment">// Addition is faster than shift, at least on i586+</span>
<a name="l00373"></a>00373                     CharLine += CharLine;
<a name="l00374"></a>00374                   }
<a name="l00375"></a>00375                   <span class="keywordflow">if</span> (advance &lt; 0) advance++;
<a name="l00376"></a>00376                 } <span class="comment">/* endfor */</span>
<a name="l00377"></a>00377                 <span class="keywordflow">if</span> (advance &lt; 0)
<a name="l00378"></a>00378                 {
<a name="l00379"></a>00379                   VRAM -= advance;
<a name="l00380"></a>00380                   pix += advance;
<a name="l00381"></a>00381                 }
<a name="l00382"></a>00382                 <span class="keywordflow">while</span> (pix--)
<a name="l00383"></a>00383                   mixerBG.Mix (*VRAM++);
<a name="l00384"></a>00384               } 
<a name="l00385"></a>00385             } 
<a name="l00386"></a>00386           }
<a name="l00387"></a>00387         } <span class="comment">/* endif */</span>
<a name="l00388"></a>00388       }
<a name="l00389"></a>00389   
<a name="l00390"></a>00390       pen_x += cacheData-&gt;<a class="code" href="structcsFontCache_1_1GlyphCacheData.html#8590499841ca8f452c9fd23515e6123a" title="Glyph metrics.">glyphMetrics</a>.<a class="code" href="structcsGlyphMetrics.html#1262dc16a7cfb279477286f15fd1d18c" title="Amount of pixels the pen needs to advance after the glyph.">advance</a>;
<a name="l00391"></a>00391       advance += cacheData-&gt;<a class="code" href="structcsFontCache_1_1GlyphCacheData.html#8590499841ca8f452c9fd23515e6123a" title="Glyph metrics.">glyphMetrics</a>.<a class="code" href="structcsGlyphMetrics.html#1262dc16a7cfb279477286f15fd1d18c" title="Amount of pixels the pen needs to advance after the glyph.">advance</a> - (charW + bmetrics-&gt;<a class="code" href="structcsBitmapMetrics.html#decd5c98d4de92f88d8b37460cb2bacb" title="X offset of the image to the pen position.">left</a>);
<a name="l00392"></a>00392     }
<a name="l00393"></a>00393     cache-&gt;<a class="code" href="classcsFontCache.html#cbf8f584e177e022eadea2553946dad5" title="Delete empty PlaneGlyphs from known fonts.">PurgeEmptyPlanes</a> ();
<a name="l00394"></a>00394     
<a name="l00395"></a>00395   }
<a name="l00396"></a>00396 };
<a name="l00397"></a>00397 
<a name="l00400"></a>00400 <span class="preprocessor">#endif // __CS_CSPLUGINCOMMON_CANVAS_DRAW_TEXT_H___</span>
</pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by 
<a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 
</small></address> </div></body> </html>