亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? usplib.c

?? 支持Unicode及Uniscribe的多語言輸入的文本編輯器源碼。
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
//
//	UspLib.c
//
//	USPLIB is a Unicode text-display support library. It is a wrapper
//	around the low-level Uniscribe API and provides routines
//	used to display Unicode text with the ability to
//	apply styles (colours/fonts etc) with a user-supplied attribute-run-list 
//	
//	UspAllocate
//	UspFree
//	UspAnalyze
//
//	UspApplySelection
//	UspApplyAttributes
//	
//	Written by J Brown 2006 Freeware
//	www.catch22.net
//

#define _WIN32_WINNT 0x501

#ifndef _UNICODE
#define _UNICODE
#endif

#ifndef UNICODE
#define UNICODE
#endif

#define STRICT
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <usp10.h>
#include <tchar.h>
#include <stdlib.h>
#include <malloc.h>
#include "usplib.h"

// UspCtrl.c
int  CtrlCharWidth(USPFONT *uspFont, HDC hdc, ULONG chValue);

//
//	Return an item-run based on visual-order
//
ITEM_RUN *GetItemRun(USPDATA *uspData, int visualIdx)
{
	int logicalIdx = uspData->visualToLogicalList[visualIdx];
	return &uspData->itemRunList[logicalIdx];
}

//
//	Locate tabs in the original character array, and then modify the
//	corresponding glyph-width (which will be zero) to a value reflecting
//	the size of the tab in pixels. This is all that is required to support
//	tabs, the mouse+drawing routines just treat them as regular glyphs
//	after this.
//
static 
BOOL ExpandTabs(USPDATA *uspData, WCHAR *wstr, int wlen, SCRIPT_TABDEF *tabdef)
{
	int i;
	int xpos	 = tabdef->iTabOrigin;
	int tabidx   = 0;
	int tabWidth;
	int tab;

	// calculate average character-width
	int charWidth = uspData->uspFontList ? uspData->uspFontList[0].tm.tmAveCharWidth :
										   uspData->defaultFont.tm.tmAveCharWidth; 

 	// validate the SCRIPT_TABDEF structure
	if(tabdef->cTabStops != 0 && tabdef->pTabStops == 0 || tabdef->cTabStops < 0)
		return FALSE;

	// All tab-stops are the length of the first entry in pTabStops
	if(tabdef->cTabStops == 1)
	{
		tabWidth = tabdef->pTabStops[0];
	}
	// Tab-stops occur every eight average-character widths
	else
	{
		tabWidth = charWidth;
	}

	// Do the scaling
	if(tabdef->iScale != 0)
	{
		xpos	 *= tabdef->iScale / 4;
		tabWidth *= tabdef->iScale / 4;
	}
	else
	{
		xpos	 *= charWidth;
		tabWidth *= charWidth;
	}

	// scan item-runs in *visual* order (think this is right!)
	for(i = 0; i < uspData->itemRunCount; i++)
	{
		ITEM_RUN *itemRun = GetItemRun(uspData, i);

		// match tabs
		if(wstr[itemRun->charPos] == '\t')
		{
			// calculate distance to next tab-stop position
			if(tabdef->cTabStops <= 1)
			{
				tab = tabWidth - (xpos % tabWidth);
			}
			else 
			{
				// search for the next tab-stop position
				for( ; tabidx < tabdef->cTabStops; tabidx++)
				{
					if(xpos > tabdef->pTabStops[tabidx])
					{
						tab = 0; 
						break;
					}
				}

				//tab = uspData->
			}

			uspData->widthList[itemRun->glyphPos] = tab;
			itemRun->width	= tab;
			itemRun->tab	= TRUE;
		}

		xpos += itemRun->width;
	}

	return TRUE;
}

//
//	Non-complex scripts can be merged into a single item
//
static
int MergeSimpleScripts(SCRIPT_ITEM *itemList, int itemCount)
{
	// global script-table, used for merging non-complex runs together :)
	SCRIPT_PROPERTIES **propList;
	int					propCount;
	int					i;

	// get pointer to the global script table
	ScriptGetProperties(&propList, &propCount);

	//	coalesce item-runs that are based on simple-scripts
	for(i = 0; i < itemCount - 1; i++)
	{
		// use each item-run's SCRIPT_ANALYSIS::eScript member to lookup the
		// appropriate script in the global-table
		if(propList[itemList[i+0].a.eScript]->fComplex == FALSE && 
		   propList[itemList[i+1].a.eScript]->fComplex == FALSE)
		{
			// be careful which SCRIPT_ITEM we overwrite as we need to
			// maintain correct iCharPos members
			memmove(&itemList[i+1], &itemList[i+2], (itemCount-i-1) * sizeof(SCRIPT_ITEM));
			itemCount--;

			itemList[i].a.eScript = SCRIPT_UNDEFINED;
		}
	}

	return itemCount;
}

//	
//	Wrapper around ScriptItemize. Merges the results of ScriptItemize with
//  "application-defined style runs". In our case, we take the ATTR[] array 
//  of runs and inspect the font and control-character flags *only* - colours
//  and selection flags are *not* used to split the runs.
//
//	Note that for scripts that do *not* have the fComplex property set, (obtained
//  via ScriptGetProperties) we can merge item-runs together to form a single
//	run with SCRIPT_UNDEFINED...this makes text-display *much* faster for simple
//  scripts such as english.
//
static 
BOOL BuildMergedItemRunList (
		USPDATA			* uspData, 
		WCHAR			* wstr, 
		int				  wlen, 
		ATTR			* attrList,
		SCRIPT_CONTROL	* scriptControl,
		SCRIPT_STATE	* scriptState
	)
{
	// attribute-list index+position
	int				  a = 0;
	int				  attrPos = 0;
	int				  attrLen = 0;
	ATTR			  attr = attrList[0];

	// item-list index+position (only needed in this function)
	int				  i = 0;
	int				  itemPos;
	int				  itemLen;
	int				  itemCount;
	SCRIPT_ITEM		* itemList		 = uspData->tempItemList;
	int				  allocLen		 = max(uspData->tempItemAllocLen, 16);

	// merged-list index+position
	int				  m = 0;
	int				  mergePos		 = 0;
	ITEM_RUN		* mergedList	 = uspData->itemRunList;
	int				  mergedAllocLen = uspData->itemRunAllocLen;

	HRESULT			  hr;

	//	Create the Uniscribe SCRIPT_ITEM list which just describes
	//  the spans of plain unicode text (grouped by script)
	do
	{
		// allocate memory for SCRIPT_ITEM list
		if(uspData->tempItemAllocLen < allocLen)
		{
			itemList = realloc(itemList, allocLen * sizeof(SCRIPT_ITEM));
			
			if(itemList == 0)
				return FALSE;

			// store this temporary-item list so we don't have to free/alloc all the time
			uspData->tempItemAllocLen	= allocLen;
			uspData->tempItemList		= itemList;
		}

		hr = ScriptItemize(
				wstr, 
				wlen, 
				allocLen, 
				scriptControl, 
				scriptState, 
				itemList, 
				&itemCount
			);

		if(hr != S_OK && hr != E_OUTOFMEMORY)
			return FALSE;

		allocLen *= 2;
	}
	while(hr != S_OK);

	// any non-complex scripts can be merged into a single item
	// itemCount could be decremented after this call
	itemCount = MergeSimpleScripts(itemList, itemCount);

	//
	//	Merge SCRIPT_ITEMs with the ATTR runlist to produce finer-grained 
	//  item-runs which describes spans of text *and* style 
	//
	while(i < itemCount)
	{
		if(attrPos + attrLen < wlen)
			attr = attrList[a];

		// grow the merge-list if necessary
		if(m >= mergedAllocLen)
		{
			mergedAllocLen += 16;
			mergedList = realloc(mergedList, mergedAllocLen * sizeof(ITEM_RUN));
		}

		// build an ITEM_RUN with default settings
		ZeroMemory(&mergedList[m], sizeof(ITEM_RUN));
		mergedList[m].analysis		= itemList[i].a;
		mergedList[m].font			= attr.font;
		mergedList[m].ctrl			= attr.ctrl;
		mergedList[m].eol			= attr.eol;

		// control-characters have their Unicode code-point stored in the item-run
		// (there will always be 1 ctrlchar per run)
		if(mergedList[m].ctrl)
			mergedList[m].chcode = wstr[mergePos];

		// safeguard against incorrect font usage when the user didn't specify a font-list
		if(uspData->uspFontList == &uspData->defaultFont)
			mergedList[m].font = 0;

		itemPos = itemList[i].iCharPos;
		itemLen = itemList[i+1].iCharPos - itemPos;

		//
		// coalesce identical attribute cells into one contiguous run. Ignore all style 
		// attributes except the ::font flags so even ATTR with different colours 
		// will be merged together if they share the same font. 
		//
		// However, any ATTR with the ::ctrl  flag set will be isolated as a single 
		// ITEM_RUN representing one control-character exactly.
		//
		if(attrLen == 0)
		{
			while(attrPos + attrLen < wlen)
			{
				attrLen += attrList[a].len;		

				if(attrPos + attrLen < wlen &&
				  (attrList[a].font != attrList[a+1].font ||
				   attrList[a].ctrl != attrList[a+1].ctrl ||
				   attrList[a].eol  != attrList[a+1].eol  ||
				   attrList[a].ctrl ||
				   attrList[a].eol)
				  ) 
				   break;

				// skip to next (coalesce)
				a++;
			} 
		}

		//	Detect overlapping run boundaries 
		if(attrPos+attrLen < itemPos+itemLen)
		{
			mergedList[m].charPos	= mergePos;
			mergedList[m].len		= (attrPos+attrLen) - mergePos;

			attrPos += attrLen;
			attrLen = 0;
			a++;
		}
		else if(attrPos+attrLen >= itemPos+itemLen)
		{
			mergedList[m].charPos	= mergePos;
			mergedList[m].len		= (itemPos+itemLen) - mergePos;
			i++;

			if(attrPos+attrLen == itemPos+itemLen)
			{
				attrPos += attrLen;
				attrLen = 0;
				a++;
			}
		}

		// advance position in merge-list
		mergePos += mergedList[m].len;
		m++;
	}

	// store the results
	uspData->itemRunList	   = mergedList;
	uspData->itemRunCount	   = m;
	uspData->itemRunAllocLen   = mergedAllocLen;

	return TRUE;
}

static 
BOOL BuildVisualMapping (
		ITEM_RUN *	mergedRunList, 
		int			mergedRunCount, 
		BYTE		bidiLevels[], 
		int			visualToLogicalList[]
	)
{
	int		i;

	//	Manually extract bidi-embedding-levels ready for ScriptLayout
	for(i = 0; i < mergedRunCount; i++)
		bidiLevels[i] = (BYTE)mergedRunList[i].analysis.s.uBidiLevel;

	//	Build a visual-to-logical mapping order
	ScriptLayout(
			mergedRunCount,
			bidiLevels,
			visualToLogicalList,
			0
		);

	return TRUE;
}

/*
// 
//	Reverse logical-cluster array, and the clusters within the array
//	For RTL runs, this changes the logical-cluster list to visual-order 
//
//	Unused but left just in-case I need it again
//
static
void ReverseClusterRun(WORD *sourceList, WORD *destList, int runLen)
{
	int i, lasti;

	for(i = runLen - 1, lasti = i; i >= -1; i--)
	{
		if(i == -1 || sourceList[i] != sourceList[lasti])
		{
			int clusterlen = lasti - i;
			int pos = sourceList[lasti] - (clusterlen - 1);

			while(clusterlen--)
				*destList++ = pos;

			lasti = i;
		}
	}
}*/

//
//	Call ScriptShape and ScriptPlace to return glyph information
//	for the specified run of text. 
//
static 
BOOL ShapeAndPlaceItemRun(USPDATA *uspData, ITEM_RUN *itemRun, HDC hdc, WCHAR *wrunstr)
{
	ABC			abc;
	HRESULT		hr;
	USPFONT   *	uspFont		= 0;
	HANDLE		holdFont	= 0;
	int			reallocSize = 0;
	
	// select the appropriate font
	uspFont  = &uspData->uspFontList[itemRun->font];
	holdFont = SelectObject(hdc, uspFont->hFont);

	// glyph data for this run is appended to the end 
	itemRun->glyphPos = uspData->glyphCount;

	//
	// Generate glyph information for each character in the run
	// keep looping until we find a buffer big enough
	//
	do
	{
		// guess at 1.5x the run-length
		reallocSize += itemRun->len * 3 / 2;

		// perform memory allocations. Let ScriptShape catch any alloc-failures
		if(uspData->glyphCount + reallocSize >= uspData->glyphAllocLen)
		{
			uspData->glyphAllocLen += reallocSize;

			uspData->glyphList	 = realloc(uspData->glyphList,	 uspData->glyphAllocLen * sizeof(WORD));
			uspData->offsetList  = realloc(uspData->offsetList,  uspData->glyphAllocLen * sizeof(GOFFSET));

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
97se亚洲国产综合自在线| 日韩欧美国产1| 91丨九色丨黑人外教| av亚洲精华国产精华精| 成人午夜碰碰视频| 成人av高清在线| eeuss鲁片一区二区三区在线看| 大白屁股一区二区视频| www.av亚洲| av男人天堂一区| 91蜜桃传媒精品久久久一区二区| eeuss国产一区二区三区| 26uuu欧美| 精品国产乱码久久久久久牛牛 | 亚洲免费在线观看| 亚洲欧美一区二区不卡| 亚洲免费资源在线播放| 亚洲福利一区二区三区| 日韩专区欧美专区| 韩国v欧美v亚洲v日本v| 国产精品18久久久久久久久久久久| 国产精品一二三区在线| av一区二区三区黑人| 91日韩精品一区| 欧美日韩美少妇| 精品免费视频.| 中文字幕av一区 二区| 亚洲免费成人av| 青青青爽久久午夜综合久久午夜| 久久成人免费网站| 成人免费av资源| 欧美丝袜第三区| 精品日韩在线观看| 自拍av一区二区三区| 偷拍日韩校园综合在线| 国产综合久久久久久久久久久久 | 欧美精品一区二区三区视频| 国产丝袜美腿一区二区三区| 亚洲天堂网中文字| 欧美三级中文字幕| 精品国产乱码久久久久久图片| 日本一区二区三区高清不卡| 一区二区三区蜜桃| 韩国理伦片一区二区三区在线播放| 福利电影一区二区三区| 欧美日韩一区二区三区在线看| 日韩欧美国产三级电影视频| 国产精品美女久久久久av爽李琼 | 国产主播一区二区三区| 99在线精品一区二区三区| 欧美性感一类影片在线播放| 精品国产三级电影在线观看| 亚洲婷婷在线视频| 韩国精品一区二区| 欧美视频第二页| 国产午夜精品一区二区三区四区| 亚洲一二三四在线观看| 国产美女视频91| 欧美日本视频在线| 国产精品三级av在线播放| 日韩av不卡一区二区| 97se亚洲国产综合自在线不卡| 日韩三级在线观看| 尤物av一区二区| 国产乱码精品一区二区三区五月婷| 在线看一区二区| 国产精品视频在线看| 日韩高清一级片| 91在线云播放| 国产亚洲欧美在线| 蜜桃视频在线观看一区| 欧美伊人久久大香线蕉综合69| 国产亚洲一区二区三区四区| 日韩高清国产一区在线| 日本道精品一区二区三区| 国产欧美日韩麻豆91| 久久精品国产澳门| 欧美无乱码久久久免费午夜一区| 国产精品无码永久免费888| 麻豆91精品视频| 欧美日韩精品欧美日韩精品| 成人精品免费网站| 2021中文字幕一区亚洲| 日韩精品成人一区二区三区| 99国产精品一区| 久久久综合视频| 日本不卡一区二区| 欧美军同video69gay| 亚洲男人电影天堂| 99精品久久久久久| 日本一区二区三区dvd视频在线| 久久精品免费看| 欧美一区2区视频在线观看| 性做久久久久久免费观看欧美| 91色视频在线| 亚洲色图欧洲色图| 不卡的av电影在线观看| 国产性色一区二区| 国产成人鲁色资源国产91色综| 精品国产乱码久久久久久老虎| 奇米888四色在线精品| 欧美群妇大交群中文字幕| 亚洲高清在线视频| 欧美亚洲一区二区三区四区| 一区二区三区在线免费播放| 91网站在线观看视频| 亚洲人精品午夜| 91福利在线播放| 亚洲国产va精品久久久不卡综合| 欧美视频一区在线| 日韩电影免费一区| 日韩一区二区在线看片| 久久99精品国产麻豆婷婷| 欧美成人猛片aaaaaaa| 国产综合色视频| 国产精品私人影院| 91美女片黄在线观看| 亚洲综合一区在线| 欧美一区二区三区人| 久久精品国产精品青草| 国产人久久人人人人爽| 99精品久久久久久| 一区二区三区四区在线| 欧美老人xxxx18| 另类成人小视频在线| 久久久久久97三级| 91在线观看视频| 亚洲bdsm女犯bdsm网站| 欧美mv和日韩mv国产网站| 国产福利一区二区三区视频| 亚洲国产精品t66y| 91福利资源站| 久久99国内精品| 国产精品国产三级国产普通话三级| 97超碰欧美中文字幕| 午夜国产精品影院在线观看| 日韩精品专区在线影院重磅| 粉嫩欧美一区二区三区高清影视| 亚洲天堂福利av| 69p69国产精品| 风流少妇一区二区| 亚洲一级二级在线| 久久久久97国产精华液好用吗| av成人免费在线| 日韩avvvv在线播放| 欧美经典三级视频一区二区三区| 在线观看网站黄不卡| 久久激情五月婷婷| 亚洲人成小说网站色在线| 欧美高清视频www夜色资源网| 国产一区二区三区四| 一区二区三区国产精品| 日韩和欧美一区二区| 中文字幕成人在线观看| 欧美欧美午夜aⅴ在线观看| 国产高清成人在线| 五月天婷婷综合| 国产精品人妖ts系列视频| 欧美猛男男办公室激情| 成人综合婷婷国产精品久久蜜臀| 亚洲一区二区三区四区不卡| 国产视频视频一区| 在线播放日韩导航| 91丨国产丨九色丨pron| 久久99热99| 亚洲成人动漫在线免费观看| 欧美极品少妇xxxxⅹ高跟鞋| 欧美日韩成人综合在线一区二区| 成av人片一区二区| 久久99精品国产.久久久久| 亚洲影院免费观看| 欧美国产激情二区三区 | 欧美激情资源网| 欧美一区二区高清| 欧美午夜一区二区三区| 高清久久久久久| 久久精品国产在热久久| 亚洲一区二区3| 亚洲日本丝袜连裤袜办公室| 久久人人超碰精品| 欧美一卡在线观看| 欧美日韩一区二区三区四区| 99久久精品国产一区| 国产v日产∨综合v精品视频| 美女在线观看视频一区二区| 亚洲国产欧美日韩另类综合 | 激情国产一区二区| 日韩av在线免费观看不卡| 一区二区三区在线播放| 中文成人av在线| 国产亚洲欧洲997久久综合 | 日韩午夜精品视频| 欧美色倩网站大全免费| 日本韩国欧美国产| 色呦呦一区二区三区| 99视频超级精品| 94色蜜桃网一区二区三区| 成人激情电影免费在线观看| 黄色资源网久久资源365| 美女在线一区二区|