GNU Unifont 17.0.01
Pan-Unicode font with complete Unicode Plane 0 coverage and partial coverage of higher planes
|
Functions for converting Hangul letters into syllables. More...
Go to the source code of this file.
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 | cho_variation (int choseong, int jungseong, int jongseong) |
Return the Johab 6/3/1 choseong variation for a syllable. | |
int | is_wide_vowel (int vowel) |
Whether vowel has rightmost vertical stroke to the right. | |
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 | 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. | |
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. | |
Functions for converting Hangul letters into syllables.
This file contains functions for reading in Hangul letters arranged in a Johab 6/3/1 pattern and composing syllables with them. One function maps an iniital letter (choseong), medial letter (jungseong), and final letter (jongseong) into the Hangul Syllables Unicode block, U+AC00..U+D7A3. Other functions allow formation of glyphs that include the ancient Hangul letters that Hanterm supported. More can be added if desired, with appropriate changes to start positions and lengths defined in "hangul.h".
Definition in file unihangul-support.c.
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.