GNU Unifont 17.0.01
Pan-Unicode font with complete Unicode Plane 0 coverage and partial coverage of higher planes
|
Define constants and function prototypes for using Hangul glyphs. More...
#include <stdlib.h>
Go to the source code of this file.
Macros | |
#define | MAXLINE 256 |
Length of maximum file input line. | |
#define | EXTENDED_HANGUL /* Use rare Hangul code points beyond U+1100 */ |
#define | PUA_START 0xE000 |
#define | PUA_END 0xE8FF |
#define | MAX_GLYPHS (PUA_END - PUA_START + 1) /* Maximum .hex file glyphs */ |
#define | CHO_UNICODE_START 0x1100 |
Modern Hangul choseong start. | |
#define | CHO_UNICODE_END 0x115E |
Hangul Jamo choseong end. | |
#define | CHO_EXTA_UNICODE_START 0xA960 |
Hangul Extended-A choseong start. | |
#define | CHO_EXTA_UNICODE_END 0xA97C |
Hangul Extended-A choseong end. | |
#define | JUNG_UNICODE_START 0x1161 |
Modern Hangul jungseong start. | |
#define | JUNG_UNICODE_END 0x11A7 |
Modern Hangul jungseong end. | |
#define | JUNG_EXTB_UNICODE_START 0xD7B0 |
Hangul Extended-B jungseong start. | |
#define | JUNG_EXTB_UNICODE_END 0xD7C6 |
Hangul Extended-B jungseong end. | |
#define | JONG_UNICODE_START 0x11A8 |
Modern Hangul jongseong start. | |
#define | JONG_UNICODE_END 0x11FF |
Modern Hangul jongseong end. | |
#define | JONG_EXTB_UNICODE_START 0xD7CB |
Hangul Extended-B jongseong start. | |
#define | JONG_EXTB_UNICODE_END 0xD7FB |
Hangul Extended-B jongseong end. | |
#define | NCHO_MODERN 19 |
19 modern Hangul Jamo choseong | |
#define | NCHO_ANCIENT 76 |
ancient Hangul Jamo choseong | |
#define | NCHO_EXTA 29 |
Hangul Extended-A choseong. | |
#define | NCHO_EXTA_RSRVD 3 |
Reserved at end of Extended-A choseong. | |
#define | NJUNG_MODERN 21 |
21 modern Hangul Jamo jungseong | |
#define | NJUNG_ANCIENT 50 |
ancient Hangul Jamo jungseong | |
#define | NJUNG_EXTB 23 |
Hangul Extended-B jungseong. | |
#define | NJUNG_EXTB_RSRVD 4 |
Reserved at end of Extended-B junseong. | |
#define | NJONG_MODERN 27 |
28 modern Hangul Jamo jongseong | |
#define | NJONG_ANCIENT 61 |
ancient Hangul Jamo jongseong | |
#define | NJONG_EXTB 49 |
Hangul Extended-B jongseong. | |
#define | NJONG_EXTB_RSRVD 4 |
Reserved at end of Extended-B jonseong. | |
#define | CHO_VARIATIONS 6 |
6 choseong variations | |
#define | JUNG_VARIATIONS 3 |
3 jungseong variations | |
#define | JONG_VARIATIONS 1 |
1 jongseong variation | |
#define | CHO_HEX 0x0001 |
Location of first choseong (location 0x0000 is a blank glyph) | |
#define | CHO_ANCIENT_HEX (CHO_HEX + CHO_VARIATIONS * NCHO_MODERN) |
Location of first ancient choseong. | |
#define | CHO_EXTA_HEX (CHO_ANCIENT_HEX + CHO_VARIATIONS * NCHO_ANCIENT) |
U+A960 Extended-A choseong. | |
#define | CHO_LAST_HEX (CHO_EXTA_HEX + CHO_VARIATIONS * (NCHO_EXTA + NCHO_EXTA_RSRVD) - 1) |
U+A97F Extended-A last location in .hex file, including reserved Unicode code points at end. | |
#define | JUNG_HEX (CHO_LAST_HEX + 1) |
Location of first jungseong (will be 0x2FB) | |
#define | JUNG_ANCIENT_HEX (JUNG_HEX + JUNG_VARIATIONS * NJUNG_MODERN) |
Location of first ancient jungseong. | |
#define | JUNG_EXTB_HEX (JUNG_ANCIENT_HEX + JUNG_VARIATIONS * NJUNG_ANCIENT) |
U+D7B0 Extended-B jungseong. | |
#define | JUNG_LAST_HEX (JUNG_EXTB_HEX + JUNG_VARIATIONS * (NJUNG_EXTB + NJUNG_EXTB_RSRVD) - 1) |
U+D7CA Extended-B last location in .hex file, including reserved Unicode code points at end. | |
#define | JONG_HEX (JUNG_LAST_HEX + 1) |
Location of first jongseong (will be 0x421) | |
#define | JONG_ANCIENT_HEX (JONG_HEX + JONG_VARIATIONS * NJONG_MODERN) |
Location of first ancient jongseong. | |
#define | JONG_EXTB_HEX (JONG_ANCIENT_HEX + JONG_VARIATIONS * NJONG_ANCIENT) |
U+D7CB Extended-B jongseong. | |
#define | JONG_LAST_HEX (JONG_EXTB_HEX + JONG_VARIATIONS * (NJONG_EXTB + NJONG_EXTB_RSRVD) - 1) |
U+D7FF Extended-B last location in .hex file, including reserved Unicode code points at end. | |
#define | JAMO_HEX 0x0500 |
Start of U+1100..U+11FF glyphs. | |
#define | JAMO_END 0x05FF |
End of U+1100..U+11FF glyphs. | |
#define | JAMO_EXTA_HEX 0x0600 |
Start of U+A960..U+A97F glyphs. | |
#define | JAMO_EXTA_END 0x061F |
End of U+A960..U+A97F glyphs. | |
#define | JAMO_EXTB_HEX 0x0620 |
Start of U+D7B0..U+D7FF glyphs. | |
#define | JAMO_EXTB_END 0x066F |
End of U+D7B0..U+D7FF glyphs. | |
#define | TOTAL_CHO (NCHO_MODERN + NCHO_ANCIENT + NCHO_EXTA ) |
#define | TOTAL_JUNG (NJUNG_MODERN + NJUNG_ANCIENT + NJUNG_EXTB) |
#define | TOTAL_JONG (NJONG_MODERN + NJONG_ANCIENT + NJONG_EXTB) |
Functions | |
unsigned | hangul_read_base8 (FILE *infp, unsigned char base[][32]) |
Read hangul-base.hex file into a unsigned char array. | |
unsigned | hangul_read_base16 (FILE *infp, unsigned base[][16]) |
Read hangul-base.hex file into a unsigned array. | |
void | hangul_decompose (unsigned codept, int *initial, int *medial, int *final) |
Decompose a Hangul Syllables code point into three letters. | |
unsigned | hangul_compose (int initial, int medial, int final) |
Compose a Hangul syllable into a code point, or 0 if none exists. | |
void | hangul_hex_indices (int choseong, int jungseong, int jongseong, int *cho_index, int *jung_index, int *jong_index) |
Determine index values to the bitmaps for a syllable's components. | |
void | hangul_variations (int choseong, int jungseong, int jongseong, int *cho_var, int *jung_var, int *jong_var) |
Determine the variations of each letter in a Hangul syllable. | |
int | is_wide_vowel (int vowel) |
Whether vowel has rightmost vertical stroke to the right. | |
int | cho_variation (int choseong, int jungseong, int jongseong) |
Return the Johab 6/3/1 choseong variation for a syllable. | |
int | jung_variation (int choseong, int jungseong, int jongseong) |
Return the Johab 6/3/1 jungseong variation. | |
int | jong_variation (int choseong, int jungseong, int jongseong) |
Return the Johab 6/3/1 jongseong variation. | |
void | hangul_syllable (int choseong, int jungseong, int jongseong, unsigned char hangul_base[][32], unsigned char *syllable) |
Given letters in a Hangul syllable, return a glyph. | |
int | glyph_overlap (unsigned *glyph1, unsigned *glyph2) |
See if two glyphs overlap. | |
void | combine_glyphs (unsigned *glyph1, unsigned *glyph2, unsigned *combined_glyph) |
Combine two glyphs into one glyph. | |
void | one_jamo (unsigned glyph_table[MAX_GLYPHS][16], unsigned jamo, unsigned *jamo_glyph) |
Convert Hangul Jamo choseong, jungseong, and jongseong into a glyph. | |
void | combined_jamo (unsigned glyph_table[MAX_GLYPHS][16], unsigned cho, unsigned jung, unsigned jong, unsigned *combined_glyph) |
Convert Hangul Jamo choseong, jungseong, and jongseong into a glyph. | |
void | print_glyph_txt (FILE *fp, unsigned codept, unsigned *this_glyph) |
Print one glyph in Unifont hexdraw plain text style. | |
void | print_glyph_hex (FILE *fp, unsigned codept, unsigned *this_glyph) |
Print one glyph in Unifont hexdraw hexadecimal string style. | |
Define constants and function prototypes for using Hangul glyphs.
Definition in file hangul.h.
#define CHO_ANCIENT_HEX (CHO_HEX + CHO_VARIATIONS * NCHO_MODERN) |
#define CHO_EXTA_HEX (CHO_ANCIENT_HEX + CHO_VARIATIONS * NCHO_ANCIENT) |
#define CHO_EXTA_UNICODE_END 0xA97C |
#define CHO_EXTA_UNICODE_START 0xA960 |
#define CHO_HEX 0x0001 |
#define CHO_LAST_HEX (CHO_EXTA_HEX + CHO_VARIATIONS * (NCHO_EXTA + NCHO_EXTA_RSRVD) - 1) |
#define CHO_UNICODE_START 0x1100 |
#define EXTENDED_HANGUL /* Use rare Hangul code points beyond U+1100 */ |
#define JAMO_EXTA_HEX 0x0600 |
#define JAMO_EXTB_HEX 0x0620 |
#define JONG_ANCIENT_HEX (JONG_HEX + JONG_VARIATIONS * NJONG_MODERN) |
#define JONG_EXTB_HEX (JONG_ANCIENT_HEX + JONG_VARIATIONS * NJONG_ANCIENT) |
#define JONG_EXTB_UNICODE_END 0xD7FB |
#define JONG_EXTB_UNICODE_START 0xD7CB |
#define JONG_HEX (JUNG_LAST_HEX + 1) |
#define JONG_LAST_HEX (JONG_EXTB_HEX + JONG_VARIATIONS * (NJONG_EXTB + NJONG_EXTB_RSRVD) - 1) |
#define JONG_UNICODE_END 0x11FF |
#define JONG_UNICODE_START 0x11A8 |
#define JUNG_ANCIENT_HEX (JUNG_HEX + JUNG_VARIATIONS * NJUNG_MODERN) |
#define JUNG_EXTB_HEX (JUNG_ANCIENT_HEX + JUNG_VARIATIONS * NJUNG_ANCIENT) |
#define JUNG_EXTB_UNICODE_END 0xD7C6 |
#define JUNG_EXTB_UNICODE_START 0xD7B0 |
#define JUNG_HEX (CHO_LAST_HEX + 1) |
#define JUNG_LAST_HEX (JUNG_EXTB_HEX + JUNG_VARIATIONS * (NJUNG_EXTB + NJUNG_EXTB_RSRVD) - 1) |
#define JUNG_UNICODE_END 0x11A7 |
#define JUNG_UNICODE_START 0x1161 |
#define MAX_GLYPHS (PUA_END - PUA_START + 1) /* Maximum .hex file glyphs */ |
#define NCHO_EXTA_RSRVD 3 |
#define NJONG_EXTB_RSRVD 4 |
#define NJUNG_EXTB_RSRVD 4 |
#define TOTAL_CHO (NCHO_MODERN + NCHO_ANCIENT + NCHO_EXTA ) |
#define TOTAL_JONG (NJONG_MODERN + NJONG_ANCIENT + NJONG_EXTB) |
#define TOTAL_JUNG (NJUNG_MODERN + NJUNG_ANCIENT + NJUNG_EXTB) |
int cho_variation | ( | int | choseong, |
int | jungseong, | ||
int | jongseong | ||
) |
Return the Johab 6/3/1 choseong variation for a syllable.
This function takes the two or three (if jongseong is included) letters that comprise a syllable and determine the variation of the initial consonant (choseong).
Each choseong has 6 variations:
Variation Occurrence
0 Choseong with a vertical vowel such as "A". 1 Choseong with a horizontal vowel such as "O". 2 Choseong with a vertical and horizontal vowel such as "WA". 3 Same as variation 0, but with jongseong (final consonant). 4 Same as variation 1, but with jongseong (final consonant). Also a horizontal vowel pointing down, such as U and YU. 5 Same as variation 2, but with jongseong (final consonant). Also a horizontal vowel pointing down with vertical element, such as WEO, WE, and WI.
In addition, if the vowel is horizontal and a downward-pointing stroke as in the modern letters U, WEO, WE, WI, and YU, and in archaic letters YU-YEO, YU-YE, YU-I, araea, and araea-i, then 3 is added to the initial variation of 0 to 2, resulting in a choseong variation of 3 to 5, respectively.
[in] | choseong | The 1st letter in the syllable. |
[in] | jungseong | The 2nd letter in the syllable. |
[in] | jongseong | The 3rd letter in the syllable. |
Definition at line 350 of file unihangul-support.c.
void combine_glyphs | ( | unsigned * | glyph1, |
unsigned * | glyph2, | ||
unsigned * | combined_glyph | ||
) |
Combine two glyphs into one glyph.
[in] | glyph1 | The first glyph to overlap. |
[in] | glyph2 | The second glyph to overlap. |
[out] | combined_glyph | The returned combination glyph. |
Definition at line 637 of file unihangul-support.c.
void combined_jamo | ( | unsigned | glyph_table[MAX_GLYPHS][16], |
unsigned | cho, | ||
unsigned | jung, | ||
unsigned | jong, | ||
unsigned * | combined_glyph | ||
) |
Convert Hangul Jamo choseong, jungseong, and jongseong into a glyph.
This function converts input Hangul choseong, jungseong, and jongseong Unicode code triplets into a Hangul syllable. Any of those with an out of range code point are assigned a blank glyph for combining.
This function performs the following steps:
1) Determine the sequence number of choseong, jungseong, and jongseong, from 0 to the total number of choseong, jungseong, or jongseong, respectively, minus one. The sequence for each is as follows: a) Choseong: Unicode code points of U+1100..U+115E and then U+A960..U+A97C. b) Jungseong: Unicode code points of U+1161..U+11A7 and then U+D7B0..U+D7C6. c) Jongseong: Unicode code points of U+11A8..U+11FF and then U+D7CB..U+D7FB. 2) From the choseong, jungseong, and jongseong sequence number, determine the variation of choseong and jungseong (there is only one jongseong variation, although it is shifted right by one column for some vowels with a pair of long vertical strokes on the right side). 3) Convert the variation numbers for the three syllable components to index locations in the glyph array. 4) Combine the glyph array glyphs into a syllable.
[in] | glyph_table | The collection of all jamo glyphs. |
[in] | cho | The choseong Unicode code point, 0 or 0x1100..0x115F. |
[in] | jung | The jungseong Unicode code point, 0 or 0x1160..0x11A7. |
[in] | jong | The jongseong Unicode code point, 0 or 0x11A8..0x11FF. |
[out] | combined_glyph | The output glyph, 16 columns in each of 16 rows. |
Definition at line 787 of file unihangul-support.c.
int glyph_overlap | ( | unsigned * | glyph1, |
unsigned * | glyph2 | ||
) |
See if two glyphs overlap.
[in] | glyph1 | The first glyph, as a 16-row bitmap. |
[in] | glyph2 | The second glyph, as a 16-row bitmap. |
Definition at line 613 of file unihangul-support.c.
unsigned hangul_compose | ( | int | initial, |
int | medial, | ||
int | final | ||
) |
Compose a Hangul syllable into a code point, or 0 if none exists.
This function takes three letters that can form a modern Hangul syllable and returns the corresponding Unicode Hangul Syllables code point in the range 0xAC00 to 0xD7A3.
If a three-letter combination includes one or more archaic letters, it will not map into the Hangul Syllables range. In that case, the returned code point will be 0 to indicate that no valid Hangul Syllables code point exists.
[in] | initial | The first letter (choseong), 0 to 18. |
[in] | medial | The second letter (jungseong), 0 to 20. |
[in] | final | The third letter (jongseong), 0 to 26 or -1 if none. |
Definition at line 201 of file unihangul-support.c.
void hangul_decompose | ( | unsigned | codept, |
int * | initial, | ||
int * | medial, | ||
int * | final | ||
) |
Decompose a Hangul Syllables code point into three letters.
Decompose a Hangul Syllables code point (U+AC00..U+D7A3) into:
All letter values are set to -1 if the letters do not form a syllable in the Hangul Syllables range. This function only handles modern Hangul, because that is all that is in the Hangul Syllables range.
[in] | codept | The Unicode code point to decode, from 0xAC00 to 0xD7A3. |
[out] | initial | The 1st letter (choseong) in the syllable. |
[out] | initial | The 2nd letter (jungseong) in the syllable. |
[out] | initial | The 3rd letter (jongseong) in the syllable. |
Definition at line 167 of file unihangul-support.c.
void hangul_hex_indices | ( | int | choseong, |
int | jungseong, | ||
int | jongseong, | ||
int * | cho_index, | ||
int * | jung_index, | ||
int * | jong_index | ||
) |
Determine index values to the bitmaps for a syllable's components.
This function reads these input values for modern and ancient Hangul letters:
It then determines the variation of each letter given the combination with the other two letters (or just choseong and jungseong if the jongseong value is -1).
These variations are then converted into index locations within the glyph array that was read in from the hangul-base.hex file. Those index locations can then be used to form a composite syllable.
There is no restriction to only use the modern Hangul letters.
[in] | choseong | The 1st letter in the syllable. |
[in] | jungseong | The 2nd letter in the syllable. |
[in] | jongseong | The 3rd letter in the syllable, or -1 if none. |
[out] | cho_index | Index location to the 1st letter variation from the hangul-base.hex file. |
[out] | jung_index | Index location to the 2nd letter variation from the hangul-base.hex file. |
[out] | jong_index | Index location to the 3rd letter variation from the hangul-base.hex file. |
Definition at line 249 of file unihangul-support.c.
unsigned hangul_read_base16 | ( | FILE * | infp, |
unsigned | base[][16] | ||
) |
Read hangul-base.hex file into a unsigned array.
Read a Hangul base .hex file with separate choseong, jungseong, and jongseong glyphs for syllable formation. The order is:
The letters are arranged with all variations for one letter before continuing to the next letter. In the current encoding, there are 6 variations of choseong, 3 of jungseong, and 1 of jongseong per letter.
[in] | Input | file pointer; can be stdin. |
[out] | Array | of bit patterns, with 16 16-bit values per letter. |
Definition at line 116 of file unihangul-support.c.
unsigned hangul_read_base8 | ( | FILE * | infp, |
unsigned char | base[][32] | ||
) |
Read hangul-base.hex file into a unsigned char array.
Read a Hangul base .hex file with separate choseong, jungseong, and jongseong glyphs for syllable formation. The order is:
The letters are arranged with all variations for one letter before continuing to the next letter. In the current encoding, there are 6 variations of choseong, 3 of jungseong, and 1 of jongseong per letter.
[in] | Input | file pointer; can be stdin. |
[out] | Array | of bit patterns, with 32 8-bit values per letter. |
Definition at line 63 of file unihangul-support.c.
void hangul_syllable | ( | int | choseong, |
int | jungseong, | ||
int | jongseong, | ||
unsigned char | hangul_base[][32], | ||
unsigned char * | syllable | ||
) |
Given letters in a Hangul syllable, return a glyph.
This function returns a glyph bitmap comprising up to three Hangul letters that form a syllable. It reads the three component letters (choseong, jungseong, and jungseong), then calls a function that determines the appropriate variation of each letter, returning the letter bitmap locations in the glyph array. Then these letter bitmaps are combined with a logical OR operation to produce a final bitmap, which forms a 16 row by 16 column bitmap glyph.
[in] | choseong | The 1st letter in the composite glyph. |
[in] | jungseong | The 2nd letter in the composite glyph. |
[in] | jongseong | The 3rd letter in the composite glyph. |
[in] | hangul_base | The glyphs read from the "hangul_base.hex" file. |
Definition at line 583 of file unihangul-support.c.
void hangul_variations | ( | int | choseong, |
int | jungseong, | ||
int | jongseong, | ||
int * | cho_var, | ||
int * | jung_var, | ||
int * | jong_var | ||
) |
Determine the variations of each letter in a Hangul syllable.
Given the three letters that will form a syllable, return the variation of each letter used to form the composite glyph.
This function can determine variations for both modern and archaic Hangul letters; it is not limited to only the letters combinations that comprise the Unicode Hangul Syllables range.
This function reads these input values for modern and ancient Hangul letters:
It then determines the variation of each letter given the combination with the other two letters (or just choseong and jungseong if the jongseong value is -1).
[in] | choseong | The 1st letter in the syllable. |
[in] | jungseong | The 2nd letter in the syllable. |
[in] | jongseong | The 3rd letter in the syllable, or -1 if none. |
[out] | cho_var | Variation of the 1st letter from the hangul-base.hex file. |
[out] | jung_var | Variation of the 2nd letter from the hangul-base.hex file. |
[out] | jong_var | Variation of the 3rd letter from the hangul-base.hex file. |
Definition at line 298 of file unihangul-support.c.
int is_wide_vowel | ( | int | vowel | ) |
Whether vowel has rightmost vertical stroke to the right.
[in] | vowel | Vowel number, from 0 to TOTAL_JUNG - 1. |
Definition at line 434 of file unihangul-support.c.
|
inline |
Return the Johab 6/3/1 jongseong variation.
There is only one jongseong variation, so this function always returns 0. It is a placeholder function for possible future adaptation to other johab encodings.
[in] | choseong | The 1st letter in the syllable. |
[in] | jungseong | The 2nd letter in the syllable. |
[in] | jongseong | The 3rd letter in the syllable. |
Definition at line 558 of file unihangul-support.c.
|
inline |
Return the Johab 6/3/1 jungseong variation.
This function takes the two or three (if jongseong is included) letters that comprise a syllable and determine the variation of the vowel (jungseong).
Each jungseong has 3 variations:
Variation Occurrence
0 Jungseong with only chungseong (no jungseong). 1 Jungseong with chungseong and jungseong (except nieun). 2 Jungseong with chungseong and jungseong nieun.
[in] | choseong | The 1st letter in the syllable. |
[in] | jungseong | The 2nd letter in the syllable. |
[in] | jongseong | The 3rd letter in the syllable. |
Definition at line 524 of file unihangul-support.c.
void one_jamo | ( | unsigned | glyph_table[MAX_GLYPHS][16], |
unsigned | jamo, | ||
unsigned * | jamo_glyph | ||
) |
Convert Hangul Jamo choseong, jungseong, and jongseong into a glyph.
[in] | glyph_table | The collection of all jamo glyphs. |
[in] | jamo | The Unicode code point, 0 or 0x1100..0x115F. |
[out] | jamo_glyph | The output glyph, 16 columns in each of 16 rows. |
Definition at line 717 of file unihangul-support.c.
void print_glyph_hex | ( | FILE * | fp, |
unsigned | codept, | ||
unsigned * | this_glyph | ||
) |
Print one glyph in Unifont hexdraw hexadecimal string style.
[in] | fp | The file pointer for output. |
[in] | codept | The Unicode code point to print with the glyph. |
[in] | this_glyph | The 16-row by 16-column glyph to print. |
Definition at line 692 of file unihangul-support.c.
void print_glyph_txt | ( | FILE * | fp, |
unsigned | codept, | ||
unsigned * | this_glyph | ||
) |
Print one glyph in Unifont hexdraw plain text style.
[in] | fp | The file pointer for output. |
[in] | codept | The Unicode code point to print with the glyph. |
[in] | this_glyph | The 16-row by 16-column glyph to print. |
Definition at line 656 of file unihangul-support.c.