のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

pango_script_iter_next

251 gboolean
252 pango_script_iter_next (PangoScriptIter *iter)
253 {
254     int start_sp;
255
256     if (iter->script_end == iter->text_end)
257         return FALSE;
258
259     start_sp = iter->paren_sp;
260     iter->script_code = PANGO_SCRIPT_COMMON;
261     iter->script_start = iter->script_end;
262
263     for (; iter->script_end < iter->text_end; iter->script_end = g_utf8_next_char (iter->script_end))
264     {
265         gunichar ch = g_utf8_get_char (iter->script_end);
266         PangoScript sc;
267         int pair_index;
268
269         sc = pango_script_for_unichar (ch);
270         if (sc != PANGO_SCRIPT_COMMON)
271             pair_index = -1;
272         else
273	           pair_index = get_pair_index (ch);
274
275          /*
276         * Paired character handling:
277         *
278         * if it's an open character, push it onto the stack.
279         * if it's a close character, find the matching open on the
280         * stack, and use that script code. Any non-matching open
281          * characters above it on the stack will be poped.
282         */
283         if (pair_index >= 0)
284	        {
285	             if (IS_OPEN (pair_index))
286	             {
287	                 /*
288	                  * If the paren stack is full, empty it. This
289	                  * means that deeply nested paired punctuation
290	                  * characters will be ignored, but that's an unusual
291	                  * case, and it's better to ignore them than to
292	                  * write off the end of the stack...
293	                  */
294	                 if (++iter->paren_sp >= PAREN_STACK_DEPTH)
295		             iter->paren_sp = 0;
296
297	                 iter->paren_stack[iter->paren_sp].pair_index = pair_index;
298	                 iter->paren_stack[iter->paren_sp].script_code = iter->script_code;
299	             }
300	             else if (iter->paren_sp >= 0)
301	             {
302	                 int pi = pair_index & ~1;
303
304	                 while (iter->paren_sp >= 0 && iter->paren_stack[iter->paren_sp].pair_index != pi)
305		             iter->paren_sp--;
306
307	                 if (iter->paren_sp < start_sp)
308		             start_sp = iter->paren_sp;
309
310	                 if (iter->paren_sp >= 0)
311		             sc = iter->paren_stack[iter->paren_sp].script_code;
312	             }
313          }
314
315          if (SAME_SCRIPT (iter->script_code, sc))
316	        {
317	            if (!REAL_SCRIPT (iter->script_code) && REAL_SCRIPT (sc))
318	            {
319	                iter->script_code = sc;
320
321	               /*
322	                * now that we have a final script code, fix any open
323	                * characters we pushed before we knew the script code.
324	                */
325	              while (start_sp < iter->paren_sp)
326	                  iter->paren_stack[++start_sp].script_code = iter->script_code;
327	            }
328
329	            /*
330	             * if this character is a close paired character,
331	             * pop it from the stack
332	             */
333	            if (pair_index >= 0 && !IS_OPEN (pair_index) && iter->paren_sp >= 0)
334	            {
335	                iter->paren_sp--;
336
337	                if (iter->paren_sp < start_sp)
338		            start_sp = iter->paren_sp;
339	            }
340	        }
341          else
342	        {
343	            /* Different script, we're done */
344	            break;
345	        }
346     }
347
348     return TRUE;
349 }
pango-view Default [C/C++ Application]	
	pango-view [62369] [cores: 0]	
		Thread #1 [pango-view] 62369 [core: 0] (Suspended : Step)	
			pango_script_iter_next() at pango-script.c:270 0x7ffff7bb7c49	
			_pango_script_iter_init() at pango-script.c:113 0x7ffff7bb7e3a	
			itemize_state_init() at pango-context.c:977 0x7ffff7ba8c20	
			pango_itemize_with_base_dir() at pango-context.c:1,607 0x7ffff7ba9067	
			pango_layout_check_lines() at pango-layout.c:3,998 0x7ffff7bb0100	
			pango_layout_get_extents_internal() at pango-layout.c:2,587 0x7ffff7bb1eb8	
			pango_layout_get_pixel_extents() at pango-layout.c:2,808 0x7ffff7bb22e6	
			output_body() at viewer-render.c:214 0x4044e5	
			do_output() at viewer-render.c:312 0x404fd6	
			pangocairo_view_render() at viewer-pangocairo.c:338 0x406ce7	
			<...more frames...>	
	gdb (7.7.1)