📄 usp10.h
字号:
// the logically first codepoint in a cluster, and fTrailing is either
// zero, or the number of codepoints in the cluster.
//
// Thus the appropriate cursor position for a mouse hit is always the
// returned CP plus the value of fTrailing.
//
// If the X positition passed is not in the item at all, the resulting
// position will be the trailing edge of character -1 (for X positions
// before the item), or the leading edge of character 'cChars' (for
// X positions following the item).
HRESULT WINAPI ScriptXtoCP(
int iX, // In X offset from left of run
int cChars, // In Count of logical codepoints in run
int cGlyphs, // In Count of glyphs in run
const WORD *pwLogClust, // In Logical clusters
const SCRIPT_VISATTR *psva, // In Visual glyph attributes
const int *piAdvance, // In Advance widths
const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
int *piCP, // Out Resulting character position
int *piTrailing); // Out Leading or trailing half flag
///// Relationship between caret positions, justifications points and clusters
//
//
//t Job | Uniscribe support
//t -------------------------------- | --------------------------------------------------------
//t Caret move by character cluster | LogClust or VISATTR.fClusterStart or LOGATTR.fCharStop
//t Line breaking between characters | LogClust or VISATTR.fClusterStart or LOGATTR.fCharStop
//t Caret move by word | LOGATTR.fWordStop
//t Line breaking between words | LOGATTR.fWordStop
//t Justification | VISATTR.uJustification
//
//
//
///// Character clusters
//
// Character clusters are glyph sequences that cannot be split between
// lines.
//
// Some languages (e.g. Thai, Indic) restrict caret placement to points
// betwen clusters. This applies both to keyboard initiated caret
// movement (e.g. cursor keys) and pointing and clicking with the mouse
// (hit testing).
//
// Uniscribe provides cluster information in both the visual and logical
// attributes. If you've called ScriptShape you'll find the cluster
// information represented both by sequences of the same value in the
// pwLogClust array, and by the fClusterStart flag in the psva
// SCRIPT_VISATTR array.
//
// ScriptBreak also returns the fCharStop flag in the SCRIPT_LOGATTR
// array to identify cluster positions.
//
//
//
///// Word break points
//
// Valid positions for moving the caret when moving in whole words are
// marked by the fWordStop flag returned by ScriptBreak.
//
// Valid positions for breaking lines between words are marked by the
// fSoftBreak flag returned by ScriptBreak.
//
//
//
///// Justification
//
// Justification space or kashida should be inserted where identified by
// the uJustificaion field of the SCRIPT_VISATTR.
//
// When performing inter-character justification, insert extra space
// only after glyphs marked with uJustify == SCRIPT_JUSTIFY_CHARACTER.
//
//
//
///// Script specific processing
//
// Uniscribe provides information about special processing for each
// script in the SCRIPT_PROPERTIES array.
//
// Use the following code during initialisation to get a pointer to
// the SCRIPT_PROPERTIES array:
//
//c const SCRIPT_PROPERTIES **g_ppScriptProperties; // Array of pointers to properties
//c int iMaxScript;
//c HRESULT hr;
//
//c hr = ScriptGetProperties(&g_ppScriptProperties, &g_iMaxScript);
//
// Then inspect the properties of the script of an item 'iItem' as follows:
//
//c hr = ScriptItemize( ... , pItems, ... );
//c ...
//c if (g_ppScriptProperties[pItems[iItem].a.eScript]->fNeedsCaretInfo) {
//c // Use ScriptBreak to restrict the caret from entering clusters (for example).
//c }
//
//
// SCRIPT_PROPERTIES.fNeedsCaretInfo
//
// Caret placement should be restricted to cluster
// edges for scripts such as Thai and Indian. The fNeedsCaretInfo flag
// in SCRIPT_PROPERTIES identifies such languages.
//
// Note that ScriptXtoCP and ScriptCPtoX automatically apply caret
// placement restictions.
//
//
// SCRIPT_PROPERTIES.fNeedsWordBreaking
//
// For most scripts, word break placement may be
// identified by scanning for characters marked as fWhiteSpace in
// SCRIPT_LOGATTR, or for glyphs marked as uJustify ==
// SCRIPT_JUSTIFY_BLANK or SCRIPT_JUSTIFY_ARABIC_BLANK in SCRIPT_VISATTR.
//
// For languages such as Thai, it is also necessary to call ScriptBreak,
// and include character positions marked as fWordStop in SCRIPT_LOGATTR.
// Such scripts are marked as fNeedsWordbreaking in SCRIPT_PROPERTIES.
//
//
// SCRIPT_PROPERTIES.fNeedsCharacterJustify
//
// Languages such as Thai also require inter-character spacing when
// justifying (where uJustify == SCRIPT_JUSTIFY_CHARACTER in the
// SCRIPT_VISATTR). Such languages are marked as fNeedsCharacterJustify
// in SCRIPT_PROPERTIES.
//
//
// SCRIPT_PROPERTIES.fAmbiguousCharSet
//
// Many Uniscribe scripts do not correspond directly to 8 bit character
// sets. For example Unicode characters in the range U+100 through U+024F
// represent extended latin shapes used for many languages, including
// those supported by EASTEUROPE_CHARSET, TURKISH_CHARSET and
// VIETNAMESE_CHARSET. However many of these characters are supported by
// more han one of thsese charsets.
// fAmbiguousCharset is set for any script token which could contain
// characters from a number of these charsets. In these cases the bCharSet
// field may contain ANSI_CHARSET or DEFAULT_CHARSET. The Uniscribe client
// will generally need to apply futher processing to determine which charset
// to use when requesting a font suitable for this run. For example it
// determine that the run consists of multiple languages and split it up
// to use a different font for each language.
///// Notes on ScriptXtoCP and ScriptCPtoX
//
// Both functions work only within runs and require the results of a
// previous ScriptShape call.
//
// The client must establish which run a given cursor offset or x
// position is within before passing it to ScriptCPtoX or ScriptXtoCP.
//
// Cluster information in the logical cluster array is used to share
// the width of a cluster of glyphs equally among the logical characters
// they represent.
//
// For example, the lam alif glyph is divided into four areas: the
// leading half of the lam, the trailing half of the lam, the leading
// half of the alif and the trailing half of the alif.
//
// ScriptXtoCP Understands the caret position conventions of each script.
// For Indian and Thai, caret positions are snapped to cluster boundaries,
// for Arabic and Hebrew, caret positions are interpolated within clusters.
//
//
///// Translating mouse hit 'x' offset to caret position
//
// Conventionally, caret position 'cp' may be selected by clicking either
// on the trailing half of character 'cp-1' or on the leading half of
// character 'cp'. This may easily be implemented as follows:
//
//c int iCharPos;
//c int iCaretPos
//c int fTrailing;
//
//c ScriptXtoCP(iMouseX, ..., &iCharPos, &fTrailing);
//c iCaretPos = iCharPos + fTrailing;
//
// For scripts that snap the caret to cluster boundaries, ScriptXtoCP
// returns ftrailing set to either 0, or the width of the cluster in
// codepoints. Thus the above code correctly returns only valid
// caret positions.
//
//
///// Displaying the caret in bidi strings
//
// In unidirectional text, the leading edge of a character is at the same
// place as the trailing edge of the previous character, so there is no
// ambiguity in placing the caret between characters.
//
// In bidirectional text, the caret position between runs of opposing
// direction may be ambiguous.
//
// For example in the left to right paragraph 'helloMAALAS', the last
// letter of 'hello' immediately preceeds the first letter of 'salaam'.
// The best position to display the caret depends on whether it is
// considered to follow the 'o' of 'hello', or to preceed the 's' of
// 'salaam'.
//
///// Commonly used caret positioning conventions
//
//t Situation | Visual caret placement
//t --------- | -------------------------------------------
//t Typing | Trailing edge of last character typed
//t Pasting | Trailing edge of last character pasted
//t Caret advancing | Trailing edge of last character passed over
//t Caret retiring | Leading edge of last character passed over
//t Home | Leading edge of line
//t End | Trailing edge of line
//
// The caret may be positioned as follows:
//
//c if (advancing) {
//c ScriptCPtoX(iCharPos-1, TRUE, ..., &iCaretX);
//c } else {
//c ScriptCPtoX(iCharPos, FALSE, ..., &iCaretX);
//c }
//
// Or, more simply, given an fAdvancing BOOL restricted to TRUE or FALSE:
//
//c ScriptCPtoX(iCharPos-fAdvancing, fAdvancing, ..., &iCaretX);
//
// ScriptCPtoX handles out of range positions logically: it returns the
// leading edge of the run for iCharPos <0, and the trailing edge of the
// run for iCharPos >=length.
///// ScriptGetLogicalWidths
//
// Converts visual withs in piAdvance into logical widths,
// one per original character, in logical order.
//
// Ligature glyphs widths are divided evenly amongst the characters
// they represent.
HRESULT WINAPI ScriptGetLogicalWidths(
const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
int cChars, // In Count of logical codepoints in run
int cGlyphs, // In Count of glyphs in run
const int *piGlyphWidth, // In Advance widths
const WORD *pwLogClust, // In Logical clusters
const SCRIPT_VISATTR *psva, // In Visual glyph attributes
int *piDx); // Out Logical widths
/////
// ScriptGetLogicalWidths is useful for recording widths in a
// font independant manner. By passing the recorded logical widths
// to ScriptApplyLogicalWidths, a block of text can be replayed in the
// same boundaries with acceptable loss of quality even when the original
// font is not available.
///// ScriptApplyLogicalWidth
//
// Accepts an array of advance widths in logical order, corresponding
// one to one with codepoints, and generates an array of glyph widths
// suitable for passing to the piJustify parameter of ScriptTextOut.
//
// ScriptApplyLogicalWidth may be used to reapply logical widths
// obtained with ScriptGetLogicalWidths. It may be useful in situations
// such as metafiling, where it is necessary to record and reapply
// advance width information in a font independant manner.
HRESULT WINAPI ScriptApplyLogicalWidth(
const int *piDx, // In Logical dx array to apply
int cChars, // In Count of logical codepoints in run
int cGlyphs, // In Glyph count
const WORD *pwLogClust, // In Logical clusters
const SCRIPT_VISATTR *psva, // In Visual attributes from ScriptShape/Place
const int *piAdvance, // In Glyph advance widths from ScriptPlace
const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
ABC *pABC, // InOut Updated item ABC width (optional)
int *piJustify); // Out Resulting glyph advance widths for ScriptTextOut
/////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -