> ## Content Index
> Fetch the complete content index at: https://sudormrf.run/llms.txt
> Use this file to discover other available public pages before exploring further.

# Uniscribe
- URL: https://sudormrf.run/2017/06/13/uniscribe/
- Published: 2017-06-13T09:24:46.000Z
- Updated: 2017-06-15T11:40:21.000Z
- Author: park jong hyun
- Tags: font, #Import 2026-10-24 03:36

Uniscribe는 복잡한 언어를 처리하고, 글씨를 아주 잘 (high degree of control) 조절할 수 있는 API 모음이다.

#### Layout Text with Uniscribe

( [MSDN page](https://msdn.microsoft.com/ko-kr/library/windows/desktop/dd317792%28v=vs.85%29.aspx?ref=sudormrf.run)의 내용을 번역. )

아래의 순서대로 uniscribe call들을 사용하면 layout 이 가능하다. 문단은 run들로 이미 나눠져있다고 가정하고.

1. 첫 시작이나 `WM_SETTINGCHANGE `메세지를 받았을 때, `ScriptRecordDigitSubstitution `호출.
2. (Optional) complex processing 이 필요한지 확인하기 위해 `ScriptIsComplex `호출.
3. (Optional) bidirectional text 나 digit substitution을 처리할 때, `ScriptApplyDigitSubstitution`를 호출하여 `SCRIPT_CONTROL `과 `SCRIPT_STATE `구조체를 `ScriptItemize`의 입력으로 넣을 수 있게 준비.
4. paragraph를 item들로 나누기 위해 `ScriptItemize` 호출.

> \[참고\] 대부분 left-to-right scripts 와 digit substitution이 없는 경우, `SCRIPT_CONTROL` 와 `SCRIPT_STATE` 구조체는 null 포인터 임.

1. range를 만들기위해, item 정보와 run 정보를 합침.
2. cluster들을 확인하고, glyph들을 만들기위해 `ScriptShape` 호출.
3. `ScriptShape` 가 missing glyphs를 포함한채로 `USP_E_SCRIPT_NOT_IN_FONT` 나 `S_OK` 를 반환하면, 다른 font에서 글자를 찾음. [Using Font Fallback](https://msdn.microsoft.com/ko-kr/library/windows/desktop/dd374105%28v=vs.85%29.aspx?ref=sudormrf.run) 참조
4. 연이은 range에 있는 glyph의 advance widths 와 x, y positions을 만들기 위해 `ScriptPlace` 호출. text의 사이즈가 고려되기 시작하는 첫 단계이다.
5. Line이 overflow되기 전까지 range들의 크기를 합한다.
6. logical attributes의 `fSoftBreak `and `fWhiteSpace` 멤버들을 사용해서, word boundary에 있는 range를 break한다. To break a single character cluster off the run, `ScriptBreak`호출에서 반환되는 정보를 사용하자.

> \[참고\] Decide if the first code point of a range should be a word break point because the last character of the previous range requires it. For example, if one range ends in a comma, consider the first character of the next range to be a word break point.

1. 6 \~ 10 단계를 매 line마다 반복. line의 마지막 run을 break 하면, `ScriptShape`를 호출해서 run 의 남은 부분이고, 다음 line의 첫 run인 부분을 reshape한다.

#### Uniscribe Glossary

[MSDN page](https://msdn.microsoft.com/ko-kr/library/windows/desktop/dd374094%28v=vs.85%29.aspx?ref=sudormrf.run)의 내용을 번역.

###### ABC width

GDI ABC structure 에 정의되어있는 character 혹은 run의 width 값들. (MSDN page의 그림 참조, 전체 width랑 삐져나온 width들이다.)

###### advance width

glyph의 rendering 시작점부터 다음 glyph의 rendering 시작점.

###### bidirectional stack

5-bit integer 로 LTR 인지 RTL 인지 기록해둠. LTR을 나타내는 0에서 시작하기 때문에, 짝수는 LTR 이고 RTL은 홀수. uBidiLevel이라는 멤버로 SCRIPT\_STATE structure 안에 있음.

###### bidirectional text

양방향 글씨, 보통 LTR 이기 때문에 RTL을 지칭하기도 함. RTL 언어는 bidirectional stack 이 필요함.

###### cell width

양쪽 정렬 (justification)을 위해서 조절 가능한 glyph의 넓이. 양쪽 정렬이 안된 (unjustified) 글에 대해서는 cell width가 advance width랑 똑같음.

###### cluster

shaped 가능한 가장 작은 linguistic 단위. Arabic이나 Indic 언어에서는 각 글자 (unicode code point)는 주변의 code points 들에 따라 달라지고, 이것들이 cluster.  
자세한 내용은 [Microsoft Glyph Processing](https://www.microsoft.com/typography/Glyph%20Processing/overview.mspx?ref=sudormrf.run) 페이지 참조.

###### complex script

다음의 특징을 하나라도 가지는 script(문자를 기준으로 한 언어, ex. latin script.)

- Bidirectional rendering
- Has contextual Shaping
- Has combining characters
- Has specialized word-breaking and justification rules
- Filters out illegal charater combinations
- Is not supported in the core Windows fonts and therefore might require font fallback

###### embedding level

bidirectional stack의 index.

###### font fallback

사용자가 설정한 font말고 다른 font가 자동으로 설정되는 것. ScriptStringAnalyse 에서 되고, 일부 텍스트에서 사용자가 선택한 font가 지원불가능한 경우 발생.

###### glyph

Display 되는 하나의 단위 (보통은 글자 한개). OpenType 기준으로는 outline으로 정의되고, 나머지 fonts에서는 bitmap이나 graphic command 모음으로 정의됨. 특정 경우에는 보통 한 글자가 아닌 경우가 있음 (출처 참조).

###### item

하나의 script와 direction. run 일 필요는 없음. 여러 스타일의 글자들을 포함.

###### LRM

Left-To-Right Mark.

###### LTR

Left-To-Right

###### range

run의 special case. 하나의 item이 하나의 run으로 잘리면 그 run이 range 임.

###### RLM

Right-To-Left Mark.

###### RTL

Right-To-Left

###### run

Uniscribe에서 렌더하기 위한 text들. 하나의 스타일, 글꼴, 사이즈, 색깔을 가져야함. script는 다양할 수 있고, LTR, RTL이 동시에 있을 수 있음.

###### overhang

glyph의 잉크 중에서 advance width를 넘어가는 부분. italic "f" 가 overhang 이 있는 glyph의 대표적인 예.

###### underhang (=padding)

overhang의 반대로 넘어가지 않고, 남은 white space 의 width.

###### script

system of written language. 언어의 글자 세트. Latin script, arabic script 가 그 예. 하나의 script는 여러 언어를 나타낼 수 있음.