﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3A2.4%2FSource%2FUI%2FText_Rendering</id>
	<title>Dev:2.4/Source/UI/Text Rendering - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3A2.4%2FSource%2FUI%2FText_Rendering"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Source/UI/Text_Rendering&amp;action=history"/>
	<updated>2026-06-22T19:58:58Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:2.4/Source/UI/Text_Rendering&amp;diff=54846&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Source/UI/Text_Rendering&amp;diff=54846&amp;oldid=prev"/>
		<updated>2018-06-28T17:51:37Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 17:51時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:2.4/Source/UI/Text_Rendering&amp;diff=54845&amp;oldid=prev</id>
		<title>wiki&gt;Mindrones: moved Dev:2.4/Source/Architecture/UI/Text Rendering to Dev:2.4/Source/UI/Text Rendering:&amp;#32;uniforming with structure in 2.5/</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Source/UI/Text_Rendering&amp;diff=54845&amp;oldid=prev"/>
		<updated>2010-05-13T08:25:14Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/Dev:2.4/Source/Architecture/UI/Text_Rendering&quot; class=&quot;mw-redirect&quot; title=&quot;Dev:2.4/Source/Architecture/UI/Text Rendering&quot;&gt;Dev:2.4/Source/Architecture/UI/Text Rendering&lt;/a&gt; to &lt;a href=&quot;/Dev:2.4/Source/UI/Text_Rendering&quot; title=&quot;Dev:2.4/Source/UI/Text Rendering&quot;&gt;Dev:2.4/Source/UI/Text Rendering&lt;/a&gt;: uniforming with structure in 2.5/&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Some Terminology==&lt;br /&gt;
APIs that are referred to by their prefixes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BMF_...&lt;br /&gt;
FTF_...&lt;br /&gt;
FTGL_...&lt;br /&gt;
BIF_...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The uses of these, and the relationships between them are the subject of this document, but it probably makes this more readable if you know that these are all used for drawing fonts in one way or another, and all of them have one (or more!) DrawString(...) functions.&lt;br /&gt;
&lt;br /&gt;
=Current Specification=&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Interface text rendering in Blender is currently achieved through a series of APIs using the FreeType library at the lowest level, as shown by the callgraph.&lt;br /&gt;
&lt;br /&gt;
The callgraph is for a cvs build circa 2.44 The untidy calls from ui_draw_but_tip() (red block, second line) are resolved by [https://projects.blender.org/tracker/index.php?func=detail&amp;amp;aid=6770&amp;amp;group_id=9&amp;amp;atid=127 patch 6770], after this patch all of the translatable interface text rendering is all achieved through the dark blue functions on the third row.&lt;br /&gt;
&lt;br /&gt;
There is &amp;lt;s&amp;gt;some&amp;lt;/s&amp;gt; a lot of non-translatable text however - [[#Current Limitations | see below]] - that is still drawn directly using the bitmap functions.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
 |valign=top|[[Image:Design-BlenderFontCallGraph-BIF_Drawstring.png|200px|thumb|right|cachgrind callgraph for BIF_Drawstring (draws translatable text)]]&lt;br /&gt;
 |valign=top|[[Image:Design-FTGL-IncumbantFontClassDiagram.png|200px|thumb|right|Class diagram of fonts in the FTGL library]]&lt;br /&gt;
 |valign=top|[[Image:Design-BlenderFontCallgraph_depth8_70percent.png|200px|thumb|right|cachgrind callgraph for FT_Render_Glyph]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{clr}}&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
The relationships can be summarised:&lt;br /&gt;
&lt;br /&gt;
[[Image:Design-textRenderingInterfaces.png|300px|thumb|right|Structure of the current text rendering system]]&lt;br /&gt;
&lt;br /&gt;
*Bitmap text rendering using internal fonts.&lt;br /&gt;
**This is the BMF_Font API, which can only use the bitmap fonts (of various sizes) built into blender at compile time, the actual font drawing is done using 2D OpenGL functions.&lt;br /&gt;
*Pixmap text rendering using external fonts.&lt;br /&gt;
**Provided by [http://homepages.paradise.net.nz/henryj/code/ FTGL] (a modified version of, compiled into Blender)&lt;br /&gt;
**Pixmap fonts are drawn using OpenGL's '''2D drawing functions''', which makes them very slow on most systems.&lt;br /&gt;
*Texture text rendering using external fonts.&lt;br /&gt;
**Also provided by FTGL, the choice between Pixmap or texture font is made by the BFFont_TTFont layer.&lt;br /&gt;
**Texture fonts are fully 3D OpenGL entities, they are also very fast.&lt;br /&gt;
*Translation of strings as they are drawn.&lt;br /&gt;
*:Using the GNUGetText library.&lt;br /&gt;
{{clr}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==2D and 3D Coordinate systems==&lt;br /&gt;
When calling &amp;lt;code&amp;gt;BIF_DrawString()&amp;lt;/code&amp;gt;, the string may be drawn in either Bitmap, pixmap, or texture modes, depending on the current settings. This means that any function that draws text must first set up '''both''' the 2D openGL coordinates, and a correct openGL transformation matrix before drawing.&lt;br /&gt;
===2D===&lt;br /&gt;
The BMF_ and FTGL pixmap fonts both render strings starting from the current openGL raster position, (set with &amp;lt;code&amp;gt;glRasterPos2f(float,  float);&amp;lt;/code&amp;gt; and family).&lt;br /&gt;
&lt;br /&gt;
The funtion &amp;lt;code&amp;gt;BIF_RasterPos(float x, float y);&amp;lt;/code&amp;gt; does not set an offset for the raster fonts, but only for the 3D texture fonts, [[#3D|See below]].&lt;br /&gt;
&lt;br /&gt;
The Pixmap fonts are drawn at the resolution at which they are loaded by FTGL, which can be set with a call to &amp;lt;code&amp;gt;BIF_SetScale(float aspect)&amp;lt;/code&amp;gt;. This function calls &amp;lt;code&amp;gt;FTF_SetScale(float s)&amp;lt;/code&amp;gt;, which indirectly results in a series of calls to the FTGL functions that change the resolution of the font glyph images that are loaded. This has the same effect on the glyph images used by the 3D fonts.&lt;br /&gt;
&lt;br /&gt;
The scale of the Bitmap fonts is determined by the particular font face (&amp;lt;code&amp;gt;struct BMF_Font*&amp;lt;/code&amp;gt;) that is passed as the first argument to &amp;lt;code&amp;gt;BIF_DrawString(...)&amp;lt;/code&amp;gt;. At the moment three different built-in fonts are used for different sizes, and are available through the Global struct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct Global {&lt;br /&gt;
...&lt;br /&gt;
	/* fonts, allocated global data */&lt;br /&gt;
	struct BMF_Font *font, *fonts, *fontss;&lt;br /&gt;
...&lt;br /&gt;
} Global;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Their values are set as:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	G.font= BMF_GetFont(BMF_kHelvetica12);&lt;br /&gt;
	G.fonts= BMF_GetFont(BMF_kHelvetica10);&lt;br /&gt;
	G.fontss= BMF_GetFont(BMF_kHelveticaBold8);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script]]&lt;br /&gt;
&lt;br /&gt;
===3D===&lt;br /&gt;
FTGL draws text strings in texture mode starting at the origin, and then moves in the positive x direction at one texel per pixel.&lt;br /&gt;
&lt;br /&gt;
The funtion &amp;lt;code&amp;gt;BIF_RasterPos(float x, float y);&amp;lt;/code&amp;gt; sets an additional x and y offset for the texture fonts, it effectively results in a call to &amp;lt;code&amp;gt;glTranslatef(x, y, 0)&amp;lt;/code&amp;gt; before the drawing of each string. This is useful, because since the raster position is transformed by openGL just like a 3D vertex coordinate, provided the matrices are left unchanged between calls, a call to BIF_RasterPos has the same effect for texture fonts that a call to glRasterPos has for bitmap and pixmap fonts.&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;BIF_SetScale(float aspect)&amp;lt;/code&amp;gt; that is used to select the resolution of the fonts also sets a scaling factor for texture fonts in order to assure that the text is drawn at one texel per pixel. The calls that result are essentially:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
FTF_SetScale(float s) -&amp;gt;&lt;br /&gt;
FTF_TTFont::SetScale(float s) -&amp;gt;&lt;br /&gt;
... -&amp;gt;&lt;br /&gt;
glscalef(fsize, fsize , 1)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This compensates for the increased resolution of the glyph images being drawn into the textures [[#2D|see 2D section]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Script]]&lt;br /&gt;
&lt;br /&gt;
===Setting up for drawing fonts===&lt;br /&gt;
In order for fonts drawn by BIF_DrawString to work (ie appear in the same place and at the same scale), the following is a rough guide to the calls that should be made.&lt;br /&gt;
''TODO: add more detail here''&lt;br /&gt;
&lt;br /&gt;
*Setting up a matrix for drawing 3D fonts&lt;br /&gt;
''TODO: this section''&lt;br /&gt;
**The offset of the transformation matrix is not important - since any call to set the openGl raster position is subject to the same matrix as vertices. However, &amp;lt;code&amp;gt;BIF_RasterPos()&amp;lt;/code&amp;gt; must be called with the same coordinates as &amp;lt;code&amp;gt;glRasterPos()&amp;lt;/code&amp;gt;.&lt;br /&gt;
**The scale ?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
uiPanelPush(block); // push matrix onto the stack&lt;br /&gt;
...&lt;br /&gt;
uiPanelPop(block); // restore previous matrix&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
glRasterPos&lt;br /&gt;
BIF_Rasterpos&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
the function &amp;lt;code&amp;gt;void ui_rasterpos_safe(float x, float y, float aspect);&amp;lt;/code&amp;gt; essentially calls both of the above, setting up the 2D raster position for bitmap/pixmap fonts, and the BIF_Rasterpos offset for the 3D fonts&lt;br /&gt;
&lt;br /&gt;
[[Category:Script]]&lt;br /&gt;
&lt;br /&gt;
=Current Limitations=&lt;br /&gt;
*Only a single font can be used at any time.&lt;br /&gt;
**Font previews in menus are impossible&lt;br /&gt;
**The same font must be used for the whole interface&lt;br /&gt;
&lt;br /&gt;
*There is poor support for anti-aliasing, making blenders fonts particularly ugly:&lt;br /&gt;
**Hinting is currently turned off.&lt;br /&gt;
**There is no support for sub pixel hinting.&lt;br /&gt;
&lt;br /&gt;
*There is a large amount of redundancy in interfaces and ways of doing things:&lt;br /&gt;
**There are three different ways of rendering fonts.&lt;br /&gt;
**The bitmap font is still used when in international mode for views other than the buttons or nodes.&lt;br /&gt;
*:This includes the 3DView, file browsers, Text Editor and many others; the strings in these windows can not be translated, ugly aliased fonts are always used.&lt;br /&gt;
&lt;br /&gt;
*Restricted range of font sizes.&lt;br /&gt;
*:As panels are scaled, the font size is picked from one of three distinct sizes, and three fonts are loaded at any time.&lt;br /&gt;
&lt;br /&gt;
[[Category:The Rube Goldberg Internals of Blender]] [[Category:API's]] [[Category:Interface]] [[Category:Development]] [[Category:Architecture]]&lt;br /&gt;
[[Category:Script]]&lt;/div&gt;</summary>
		<author><name>wiki&gt;Mindrones</name></author>
		
	</entry>
</feed>