<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CodeBlog.ch &#187; Uncategorized</title>
	<atom:link href="http://www.codeblog.ch/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codeblog.ch</link>
	<description>Coding and more - Concrete5, Flex, JavaScript</description>
	<lastBuildDate>Mon, 05 Dec 2011 16:10:29 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Vorschau Text mit PHP</title>
		<link>http://www.codeblog.ch/de/2009/06/smart-text-trimming-with-php/</link>
		<comments>http://www.codeblog.ch/de/2009/06/smart-text-trimming-with-php/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 12:56:46 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[trim]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=353</guid>
		<description><![CDATA[Möchte man einen kurzen Vorschautext in PHP erstellen, der einen Anriss des effektiven Textes zeigt, so wird man wohl oft die einfachste Variante gewählt haben, und einfach nach einer Anzahl definierten Zeichen abgeschnitten haben. Dies generiert jedoch ein unschönes Ergebnis, wenn man eine proportionale Schrift verwendet. Sämtliche Text haben markant unterschiedliche Längen wie auf diesem [...]]]></description>
			<content:encoded><![CDATA[<p>Möchte man einen kurzen Vorschautext in PHP erstellen, der einen Anriss des effektiven Textes zeigt, so wird man wohl oft die einfachste Variante gewählt haben, und einfach nach einer Anzahl definierten Zeichen abgeschnitten haben. Dies generiert jedoch ein unschönes Ergebnis, wenn man eine proportionale Schrift verwendet. Sämtliche Text haben markant unterschiedliche Längen wie auf diesem Bild gezeigt wird:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/06/text-trimming.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/06/text-trimming-300x255.png" alt="text-trimming" title="text-trimming" width="300" height="255" class="alignnone size-medium wp-image-354" /></a></p>
<p>Dieser Artikel zeigt einen einfachen Ansatz, diese Problematik etwas eleganter zu lösen!</p>
<p><span id="more-353"></span></p>
<h2>Textlänge messen</h2>
<p>PHP bietet verschiedene Methoden um die Länge eines Textes zu messen. Zum Beispiel die Methode <a target="_blank" href="http://ch2.php.net/manual/en/function.imagefontwidth.php">ImageFontWidth</a> welche die Länge der PHP internen Schriften einfach und gut messen kann. Möchte man ein einfaches Captcha erstellen, das die internen Schriften verwendet, ist diese Methode sicherlich eine gute Wahl.</p>
<p>Allerdings gibt&#8217;s noch eine andere Methode, welche die komplette &#8220;Bounding Box&#8221; errechnet. Sie lautet <a href="http://ch2.php.net/manual/en/function.imagettfbbox.php">imagettfbbox</a>. Der Rückgabe-Wert ist eine Array welches sämtliche Werte für die &#8220;Bounding Box&#8221; enthält.</h2>
<p>Die Methode</h2>
<p>Wie zu Beginn des Artikels gezeigt, wollte ich eine Methode die den Text kürzt und am Ende einen weiteren Text (in diesem Fall &#8220;&#8230;&#8221;) anhängt um zu zeigen, dass der Text nicht vollständig ist.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> trim_by_width<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span><span style="color: #000088;">$font_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$font_size</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #000088;">$append_string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$append_string_box</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagettfbbox</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$font_size</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$font_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$append_string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$append_string_width</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$append_string_box</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$str_len</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$str_len</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$trimmed_text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$bounding_box</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagettfbbox</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$font_size</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$font_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$trimmed_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$trimmed_text_width</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$bounding_box</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$trimmed_text_width</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$append_string_width</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$str_to_return</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trimmed_text</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trimmed_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$trimmed_text_width</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$str_len</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$str_to_return</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$append_string</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str_to_return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$trimmed_text</span> <span style="color: #339933;">=</span> trim_by_width<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font_file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font_size</span><span style="color: #339933;">,</span> <span style="color: #000088;">$append_string</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>$text:<br />
<code>Der Text der zu kürzen </code></p>
<p>$width:<br />
<code>Die maximale Länge des Textes in Pixel!</code></p>
<p>$font_file:<br />
<code>Die True Type Schriftendatei</code></p>
<p>$font_size:<br />
<code>Die Schriftgrösse. Bitte beachten Sie, dass die Einheiten je nach GD Version anders sind. GD1 verwendet Pixel, GD2 hingegen Punkte./code></p>
<p>$append_string:<br />
<code>Ein optionaler String welcher bei gekürzten Texten angehängt wird. Standardmässig "..."</code></p>
<h2>Beispiel</h2>
<p>Sie können die Methode nach folgendem Schema aufrufen:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> trim_by_width<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'this is a long text'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">55</span><span style="color: #339933;">,</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/verdana.ttf'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Das Script geht davon aus, dass sich die Datei verdana.ttf im gleichen Verzeichnis wie das PHP Script befindet. Anschliessend wird der Text nach 55 Pixel gekürzt und ausgegeben.</p>
<p>Fertig!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/de/2009/06/smart-text-trimming-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Schriften im Internet &#8211; Cufón</title>
		<link>http://www.codeblog.ch/de/2009/04/schriften-im-internet-cufon/</link>
		<comments>http://www.codeblog.ch/de/2009/04/schriften-im-internet-cufon/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 08:43:55 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=264</guid>
		<description><![CDATA[Schriften im Internet Schriften unter Internetseiten ist seit langem ein beliebtes Thema. Grafiker wollen logischerweise völlige Freiheiten, der Programmierer eine solide Lösung die keine Probleme verursacht. Oft interessiert es den Leser nicht in welcher Schrift etwas dargestellt wird, solange der Inhalt lesbar ist. Bei kleinen Seiten mit wenig Inhalt spielen Schriften jedoch schnell eine grössere [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Schriften im Internet</strong></p>
<p>Schriften unter Internetseiten ist seit langem ein beliebtes Thema. Grafiker wollen logischerweise völlige Freiheiten, der Programmierer eine solide Lösung die keine Probleme verursacht. Oft interessiert es den Leser nicht in welcher Schrift etwas dargestellt wird, solange der Inhalt lesbar ist. Bei kleinen Seiten mit wenig Inhalt spielen Schriften jedoch schnell eine grössere Rolle.</p>
<p>Wie kann man sowas umsetzen:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/04/font.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/04/font-300x264.png" alt="font" title="font" width="300" height="264" class="alignnone size-medium wp-image-265" /></a></p>
<p><span id="more-264"></span></p>
<p><strong>Eigene Schriften im Internet</strong></p>
<p>Mit EOT, sIFR und anderen Ansätzen gibt es schon länger Lösungen. Unschöne Darstellungen wenn die Seite noch nicht gelanden ist, fehlende Unterstützung von Seiten der Browser haben jedoch die meisten Lösungen eher unbrauchbar gemacht.</p>
<p>Mit Cufón gibt&#8217;s jedoch eine neue Lösung die sehr vielversprechend aussieht!</p>
<ul>
<li>Keine Plugins erforderlich</li>
<li>Unterstützung von zahlreichen Browsern</li>
<li>Einfach einzusetzen</li>
<li>Schnell</li>
</ul>
<p>Die Schriften werden im JavaScript Format abgespeichert. Damit man allerdings ein JavaScript File verwenden kann, muss es zuerst erstellt werden. Dazu kann ein simples Webinterface verwendet werden:</p>
<p><a href="http://cufon.shoqolate.com/generate/">http://cufon.shoqolate.com/generate/</a></p>
<p>Im Hintergrund werden einige Aktionen ausgeführt. Die Linux Applikation FontForge wird verwendet um eine SVG Schrift zu erstellen. Aus der SVG Datei werden VML Pfade generiert und daraus wird ein JSON String erstellt. Klingt umständlich, ist es auch, aber glücklicherweise müssen wir uns um fast nichts kümmern!</p>
<p>Wir wählen als unsere Schrift aus und erhalten eine JavaScript Datei als Download wenn wir das Formular abschicken.</p>
<p><strong>JavaScript Schrift einbinden</strong></p>
<p>Wir benötigen als erstes das Cufon Script. <a href="http://cufon.shoqolate.com/js/cufon-yui.js">Komprimiert </a> oder auch <a href="http://github.com/sorccu/cufon/tree/master/js/cufon.js">unkomprimiert</a>.</p>
<p>Als Ausgangslage haben wir eine simple HTML Datei:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Etiam vel odio&lt;/h1&gt;
Proin tristique elit eget nisl. Donec dictum mauris a sem. Pellentesque at arcu. Mauris cursus erat at magna adipiscing commodo. Integer ornare. Sed sollicitudin, est imperdiet hendrerit bibendum, erat turpis venenatis mauris, non ullamcorper quam arcu sit amet lacus. Nullam ut eros. Vivamus luctus urna rhoncus sem. Duis vel nibh.
&lt;h2&gt;Praesent lobortis&lt;/h2&gt;
Mauris ornare tincidunt arcu. Mauris pretium. Vestibulum ac metus in erat condimentum accumsan. Aenean dignissim consectetur risus. Maecenas purus. Duis eget mauris. Duis venenatis. Fusce tortor nunc, adipiscing id, gravida vel, ullamcorper ac, metus. Pellentesque suscipit. Suspendisse mollis augue eu mauris. Nulla facilisi. 
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Wir wollen nun, dass H1 und H2 in unserer neu erstellten JavaScript Schrift dargestellt werden. Dazu kopieren wir die beiden JavaScripts in dasselbe Verzeichnis und ergänzen unsere HTML Datei so, dass wir folgendes Ergebnis erhalten:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;script src=&quot;cufon-yui.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script src=&quot;Remo_Laubacher_400.font.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;
		Cufon.replace('h1')('h2');
	&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Etiam vel odio&lt;/h1&gt;
Proin tristique elit eget nisl. Donec dictum mauris a sem. Pellentesque at arcu. Mauris cursus erat at magna adipiscing commodo. Integer ornare. Sed sollicitudin, est imperdiet hendrerit bibendum, erat turpis venenatis mauris, non ullamcorper quam arcu sit amet lacus. Nullam ut eros. Vivamus luctus urna rhoncus sem. Duis vel nibh.
&lt;h2&gt;Praesent lobortis&lt;/h2&gt;
Mauris ornare tincidunt arcu. Mauris pretium. Vestibulum ac metus in erat condimentum accumsan. Aenean dignissim consectetur risus. Maecenas purus. Duis eget mauris. Duis venenatis. Fusce tortor nunc, adipiscing id, gravida vel, ullamcorper ac, metus. Pellentesque suscipit. Suspendisse mollis augue eu mauris. Nulla facilisi. 
&nbsp;
&lt;script type=&quot;text/javascript&quot;&gt;Cufon.now();&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Im Kopf die beiden JavaScripts einbinden, mit Cufon.replace die HTML Tags ersetzen und am Ende, vor dem </body> Tag Cufon.now() aufrufen um ein Darstellungsprobleme von Internet-Explorer zu beheben &#8211; fertig!</p>
<p>Sämtliche Files zum <a href='http://www.codeblog.ch/wp-content/uploads/2009/04/cufon-beispiel.zip'>Download</a>. Viel Spass!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/de/2009/04/schriften-im-internet-cufon/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mac OS X &#8211; Maus Beschleunigung</title>
		<link>http://www.codeblog.ch/de/2008/11/mac-os-x-maus-beschleunigung/</link>
		<comments>http://www.codeblog.ch/de/2008/11/mac-os-x-maus-beschleunigung/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 09:01:02 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=114</guid>
		<description><![CDATA[Zugegeben etwas ungewöhnlich und vermutlich kein grosses Problem für die meisten Leute. Bei der Mausbeschleunigung geht es darum, dass man für einen Monitor der 50cm breit ist, die Maus nicht 50cm weit bewegen muss. Dabei muss es trotzdem möglich sein, kleine Distanzen präzise zurückzulegen. Das führt dazu, das sich der Mauszeiger in einer nicht linearen [...]]]></description>
			<content:encoded><![CDATA[<p>Zugegeben etwas ungewöhnlich und vermutlich kein grosses Problem für die meisten Leute. Bei der Mausbeschleunigung geht es darum, dass man für einen Monitor der 50cm breit ist, die Maus nicht 50cm weit bewegen muss. Dabei muss es trotzdem möglich sein, kleine Distanzen präzise zurückzulegen. Das führt dazu, das sich der Mauszeiger in einer nicht linearen Form gegenüber der Mausbewegung verschiebt.</p>
<p>Was hat das mit Mac OS X zu tun? Ich selbst besitze zwei Computer von Apple, ein Mac Mini und ein Macbook Pro mit einem Intel Prozessor.</p>
<p>So lächerlich das klingt &#8211; der Hauptgrund, wieso ich auf meinem Macbook kaum mit OS X arbeite ist, dass ich mit der Maus nicht umgehen kann. Es passt mir regelmässig, dass ich die Icons verfehle!</p>
<p>Hier gibt es jedoch Abhilfe &#8211; ein gratis Tool mit dem Namen &#8220;MouseFix&#8221;. <a href="http://www.knockknock.org.uk/mac/" target="_blank">MouseFix Seite</a></p>
<p>Das beste OS X Tool das ich je gefunden habe!<br />
 <img src='http://www.codeblog.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/de/2008/11/mac-os-x-maus-beschleunigung/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Schriften vektorisieren</title>
		<link>http://www.codeblog.ch/de/2008/07/schriften-vektorisieren/</link>
		<comments>http://www.codeblog.ch/de/2008/07/schriften-vektorisieren/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 11:01:32 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=38</guid>
		<description><![CDATA[Es gab noch Zeiten, da wollen Leute ihren Text vektorierisieren um mehr Freiheiten zu haben. Inzwischen gibt es Leute die finden noch ganz andere unnötige Gründe wieso man einen Text in einen &#8220;Pfad&#8221; umwandeln möchte. Sei es weil man zum Beispiel mit PHP einen Text ausgeben möchte, ohne FreeType (zusammen mit GD) zu verwenden. Eine [...]]]></description>
			<content:encoded><![CDATA[<p>Es gab noch Zeiten, da wollen Leute ihren Text vektorierisieren um mehr Freiheiten zu haben. Inzwischen gibt es Leute die finden noch ganz andere unnötige Gründe wieso man einen Text in einen &#8220;Pfad&#8221; umwandeln möchte. Sei es weil man zum Beispiel mit PHP einen Text ausgeben möchte, ohne FreeType (zusammen mit GD) zu verwenden. Eine Situation die wohl fast nie vorkommt, trotzdem ein kurzer Artikel zu diesem (eher spielerischen) Thema.</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2008/07/hui.png"><img class="alignnone size-medium wp-image-39" title="hui" src="http://www.codeblog.ch/wp-content/uploads/2008/07/hui.png" alt="" width="207" height="119" /></a></p>
<p><span id="more-38"></span></p>
<p>Als erstes müssen wir die gewünschte Schriftart in eine ganze Reihe von Koordinaten umwandeln. Viele Grafikprogramme können dies, wir wollen aber wissen wie man das selber programmieren kann. Hat in unserem Fall auch den Vorteil, dass wir die Ausgabe so gestalten können wie wir wollen.</p>
<p><strong>Vektorisieren</strong></p>
<p>Microsoft bietet für genau diese Aufgabe mit ihrem .Net Framework eine genial einfache Lösung an.  Im Namespace System.Drawing.Drawing2D befindet sich eine Klasse GraphicsPath die ideal ist um Dinge zu vektorisieren.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Drawing.Drawing2D</span><span style="color: #008000;">;</span>
<span style="color: #008000;">...</span>
<span style="color: #0000FF;">GraphicsPath</span> path <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> GraphicsPath<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
path<span style="color: #008000;">.</span><span style="color: #0000FF;">AddString</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello World!&quot;</span>, FontFamily, FontSize<span style="color: #008000;">...</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Dadurch hat man bereits alles in GraphicsPath gezeichnet was wir benötigen. Das auslesen der einzelnen Punkte ist genau so einfach:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>PointF p <span style="color: #0600FF; font-weight: bold;">in</span> path<span style="color: #008000;">.</span><span style="color: #0000FF;">PathPoints</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #008080; font-style: italic;">// Punkte verarbeiten</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Am Ende dieses Artikels befindet sich eine kleine Applikation die mit Visual Studio 2008 Express geschrieben wurde. Sie generiert ist ohne Abhängigkeiten lauffähig.</p>
<p><strong>Ausgabe</strong></p>
<p>Wie anfänglich erwähnt, wollte ich diese Punkte mittels PHP GD Library ausgeben.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Generierter PHP Code für die Schriftart. Bei den Zeichen ' und \ befindet sich ein kleiner Fehler weil ich keine Escape Sequenzen eingebaut habe!</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// call by reference for $font is not possible because we have to modify the array</span>
<span style="color: #000000; font-weight: bold;">function</span> drawLetter<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font</span><span style="color: #339933;">,</span><span style="color: #000088;">$letter</span><span style="color: #339933;">,</span><span style="color: #000088;">$offsetLeft</span><span style="color: #339933;">,</span><span style="color: #000088;">$offsetTop</span><span style="color: #339933;">,</span><span style="color: #000088;">$scale</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$line_color</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">66</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">14</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">91</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$letter</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$letter</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*=</span> <span style="color: #000088;">$scale</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$letter</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$offsetLeft</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">else</span>
      <span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$letter</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$offsetTop</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #990000;">imagepolygon</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$letter</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$letter</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$line_color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: image/png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">imagecreate</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cannot Initialize new GD image stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$background_color</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Hier beachten, dass man die korrekte Schriftart (analog PHP Schrift) verwendet!</span>
drawLetter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span><span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Mistral'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'H'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
drawLetter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span><span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Mistral'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'u'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">80</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
drawLetter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span><span style="color: #000088;">$font</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Mistral'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'i'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">145</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">imagepng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">imagedestroy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Und schon hat man eine TrueType Schriftart ohne FreeType mit PHP ausgegeben. Allerdings mit einigen Einschränkungen:</p>
<p><strong>Problematische Dinge</strong></p>
<p>Es ist wohl nicht besonders klug diese Art und Weise von Ausgabe oft zu verwenden. Hier ein paar Punkte die momentan buggy sind und die Einsatzfähigkeit einschränken:</p>
<ul>
<li>Buchstaben die nicht zusammenhängend sind (z.B.: &#8220;i&#8221;) werden nicht korrekt dargestellt, da eine Verbindung vom Strich zum Punkt gezeichnet wird</li>
<li>Der generierte PHP Code enthält zwei Fehler wenn die Zeichen &#8216; und \ ausgegeben werden. Findet ihr aber sicherlich selber <img src='http://www.codeblog.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li>Skalieren ist nur bedingt möglich da wir nur &#8220;Geraden&#8221; zeichnen und keine Kurven</li>
<li>Die Daten werden momentan in Form von PHP Code ausgebeben. Ein binäres Format wäre sicherlich viel Effizienter was die Dateigrösse angeht.</li>
</ul>
<p><a href='http://www.codeblog.ch/wp-content/uploads/2008/07/fontoutline.zip'>VS 2008 Express Quellcode</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/de/2008/07/schriften-vektorisieren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Icons</title>
		<link>http://www.codeblog.ch/de/2008/07/icons/</link>
		<comments>http://www.codeblog.ch/de/2008/07/icons/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 09:30:59 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=37</guid>
		<description><![CDATA[Egal ob Webdesigner oder Softwareentwickler &#8211; Icons braucht man bei fast jedem Projekt. Dankbarerweise gibt es zahlreiche Grafiker, die ihre Kunstwerke zur freien Verfügung ins Internet gestellt haben. Hier eine Liste von Seiten die wir im codeforum.ch gesammelt haben (http://codeforum.ch/index.php/topic,3503.0.html) http://www.iconlet.com/ Icon Suchmaschine mit ~50&#8217;000 freien Icons http://www.famfamfam.com/lab/icons/silk/ Hübsche Icon Sammlung http://www.famfamfam.com/lab/icons/flags/ Flaggen gibt es [...]]]></description>
			<content:encoded><![CDATA[<p>Egal ob Webdesigner oder Softwareentwickler &#8211; Icons braucht man bei fast jedem Projekt. Dankbarerweise gibt es zahlreiche Grafiker, die ihre Kunstwerke zur freien Verfügung ins Internet gestellt haben. Hier eine Liste von Seiten die wir im codeforum.ch gesammelt haben (http://codeforum.ch/index.php/topic,3503.0.html)</p>
<p><span id="more-37"></span></p>
<ul>
<li><a href="http://www.iconlet.com/">http://www.iconlet.com/</a> Icon Suchmaschine mit ~50&#8217;000 freien Icons</li>
<li><a href="http://www.famfamfam.com/lab/icons/silk/">http://www.famfamfam.com/lab/icons/silk/</a> Hübsche Icon Sammlung</li>
<li><a href="http://www.famfamfam.com/lab/icons/flags/">http://www.famfamfam.com/lab/icons/flags/</a> Flaggen gibt es auch noch</li>
<li><a href="http://iconaholic.com/downloads.html">http://iconaholic.com/downloads.html</a> Grosse verspielte Icons</li>
<li><a href="http://www.ndesign-studio.com/resources/mini-pixel-icons/">http://www.ndesign-studio.com/resources/mini-pixel-icons/</a> Übersichtlich gegliederte Mini Icons</li>
<li><a href="http://tango.freedesktop.org/Tango_Desktop_Project">http://tango.freedesktop.org/Tango_Desktop_Project</a> Das Tango Projekt von freedesktop</li>
<li><a href="http://www.websiteicons.net/">http://www.websiteicons.net/</a> Grosse, detaillierte Icons</li>
<li><a href="http://blogandweb.com/2007/07/05/iconos-para-tu-feed/">http://blogandweb.com/2007/07/05/iconos-para-tu-feed/</a> Verschiedene RSS Icons</li>
<li><a href="http://code.google.com/p/twotiny/">http://code.google.com/p/twotiny/</a> Zweifarbige Icons</li>
<li><a href="http://somerandomdude.net/srd-projects/bitcons/">http://somerandomdude.net/srd-projects/bitcons/</a> 16&#215;16 grosse Icons auf rotem Hintergrund</li>
<li><a href="http://valkyre.deviantart.com/art/Proxal-Icon-Set-v2-17102198">http://valkyre.deviantart.com/art/Proxal-Icon-Set-v2-17102198</a> Kleine, einfache Icons</li>
<li><a href="http://icons.primail.ch/">http://icons.primail.ch/</a> Umfangreiche Sammlung von Mini Icons</li>
<li><a href="http://www.crazyleafdesign.com/blog/sunday-design-resource-issue-3-500-icons-every-designer-needs/">http://www.crazyleafdesign.com&#8230;designer-needs/</a> Sehr umfangreiche Sammlung</li>
<li><a href="http://www.linkmatrix.de/icons">http://www.linkmatrix.de/icons</a> Icons von klein bis ganz gross</li>
<li><a href="http://www.freeiconsdownload.com/">http://www.freeiconsdownload.com/</a> Sehr detailliert und sorgfältig erstellte Icons</li>
<li><a href="http://min.frexy.com/article/bright_a_free_icon_set/">http://min.frexy.com/article/bright_a_free_icon_set/</a> 148 hübsche Icons im EPS Vektor-Format</li>
<li><a href="http://www.smashingmagazine.com/2008/05/21/40-professional-icon-sets-for-free-download/">http://www.smashingmagazine.com&#8230;icon-sets-for-free-download/</a> Unterschiedliche Icons zu verschiedenen Themen</li>
<li><a href="http://www.iconfinder.net/">http://www.iconfinder.net/</a> Icon Suchmaschine</li>
<li><a href="http://paularmstrongdesigns.com/projects/bwpx-icns/">http://paularmstrongdesigns.com/projects/bwpx-icns/</a> 250 Icons 18&#215;18 Pixel</li>
<li><a href="http://dryicons.com/free-icons/">http://dryicons.com/free-icons/</a> Über 1300 Icons in verschiedenen Größen (von 16&#215;16 Pixel bis 128&#215;128 Pixel)</li>
<li><a href="http://www.pinvoke.com/">http://www.pinvoke.com/</a> Umfangreiche Sammlung von Icon 16&#215;16 Pixel</li>
<li><a href="http://www.smashingmagazine.com/2008/07/02/55-free-high-quality-icon-sets/">http://www.smashingmagazine.com/2008/07/02/55-free-high-quality-icon-sets/</a> 55 profesionelle Icon-Sets</li>
<li><a href="http://www.paulspoerry.com/2008/06/04/50-free-icon-sets/">http://www.paulspoerry.com/2008/06/04/50-free-icon-sets/</a> Eine Liste von 50 Iconsets, manche sind schon bekannt</li>
<li><a href="http://www.brandspankingnew.net/archive/2006/12/hohoho.html">http://www.brandspankingnew.net/archive/2006/12/hohoho.html</a> Ein Paket mit 113 10&#215;10 Pixel Graustufen Icons. Nützlich, wenn mal die üblichen 16&#215;16 Pixel Icons zu groß sind für das Design.</li>
<li><a href="http://www.cult-f.net/2008/09/17/50-free-icons/">http://www.cult-f.net/2008/09/17/50-free-icons/</a> Ein Paket mit 50 freien schönen PNG Icons. Im Web 2.0 Glossy Stil und im ungewöhnlichen Format 52&#215;51 Pixel.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/de/2008/07/icons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>codeblog.ch eröffnet</title>
		<link>http://www.codeblog.ch/de/2008/04/codeblogch-eroffnet/</link>
		<comments>http://www.codeblog.ch/de/2008/04/codeblogch-eroffnet/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 19:15:21 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=4</guid>
		<description><![CDATA[Als Spin-Off zu codeforum.ch, ein Forum indem ich öfters anzutreffen bin, gibt es nun codeblog.ch. Momentan noch leer und erst seit ein paar Minuten online, noch nicht besonders spannend. Ich hoffe aber, dass mit der Zeit verschiedene Personen Artikel hier publizieren werden. Ein kleiner Wunsch wäre noch immer die Integration in codeforum.ch so dass man [...]]]></description>
			<content:encoded><![CDATA[<p>Als Spin-Off zu codeforum.ch, ein Forum indem ich öfters anzutreffen bin, gibt es nun codeblog.ch. Momentan noch leer und erst seit ein paar Minuten online, noch nicht besonders spannend.</p>
<p>Ich hoffe aber, dass mit der Zeit verschiedene Personen Artikel hier publizieren werden. Ein kleiner Wunsch wäre noch immer die Integration in codeforum.ch so dass man nur eine Seite besuchen muss um zu sehen was es denn neues auf code*.ch gibt!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/de/2008/04/codeblogch-eroffnet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

