2007-01-16 Behdad Esfahbod <behdad@gnome.org>
+ *.c, *.h: Replace preceding sequences of 8 spaces with tabs.
+
+2007-01-16 Behdad Esfahbod <behdad@gnome.org>
+
* examples/pangowin32tobmp.c (SaveBitmap):
* modules/tibetan/tibetan-fc.c:
Replace C++-style // comments with C-style /* */ ones.
parametrization_t *parametrization = param->parametrization;
for (i=0; i + path->data[i].header.length < path->num_data &&
- (d > parametrization[i] ||
+ (d > parametrization[i] ||
path->data[i].header.type == CAIRO_PATH_MOVE_TO);
i += path->data[i].header.length) {
d -= parametrization[i];
case CAIRO_PATH_CURVE_TO:
ratio = d / parametrization[i];
*x = current_point.point.x * (1 - ratio) * (1 - ratio) * (1 - ratio)
- + 3 * data[1].point.x * (1 - ratio) * (1 - ratio) * ratio
- + 3 * data[2].point.x * (1 - ratio) * ratio * ratio
- + data[3].point.x * ratio * ratio * ratio;
+ + 3 * data[1].point.x * (1 - ratio) * (1 - ratio) * ratio
+ + 3 * data[2].point.x * (1 - ratio) * ratio * ratio
+ + data[3].point.x * ratio * ratio * ratio;
*y = current_point.point.y * (1 - ratio) * (1 - ratio) * (1 - ratio)
- + 3 * data[1].point.y * (1 - ratio) * (1 - ratio) * ratio
- + 3 * data[2].point.y * (1 - ratio) * ratio * ratio
- + data[3].point.y * ratio * ratio * ratio;
+ + 3 * data[1].point.y * (1 - ratio) * (1 - ratio) * ratio
+ + 3 * data[2].point.y * (1 - ratio) * ratio * ratio
+ + data[3].point.y * ratio * ratio * ratio;
dx =-3 * current_point.point.x * (1 - ratio) * (1 - ratio)
- + 3 * data[1].point.x * (1 - 4 * ratio + 3 * ratio * ratio)
- + 3 * data[2].point.x * ( 2 * ratio - 3 * ratio * ratio)
- + 3 * data[3].point.x * ratio * ratio;
+ + 3 * data[1].point.x * (1 - 4 * ratio + 3 * ratio * ratio)
+ + 3 * data[2].point.x * ( 2 * ratio - 3 * ratio * ratio)
+ + 3 * data[3].point.x * ratio * ratio;
dy =-3 * current_point.point.y * (1 - ratio) * (1 - ratio)
- + 3 * data[1].point.y * (1 - 4 * ratio + 3 * ratio * ratio)
- + 3 * data[2].point.y * ( 2 * ratio - 3 * ratio * ratio)
- + 3 * data[3].point.y * ratio * ratio;
+ + 3 * data[1].point.y * (1 - 4 * ratio + 3 * ratio * ratio)
+ + 3 * data[2].point.y * ( 2 * ratio - 3 * ratio * ratio)
+ + 3 * data[3].point.y * ratio * ratio;
d = oldy;
ratio = d / sqrt (dx * dx + dy * dy);
calc_duration (GTimeVal *tv1, GTimeVal *tv0)
{
return ( ((float)tv1->tv_sec - tv0->tv_sec)
- + (tv1->tv_usec - tv0->tv_usec) / 1000000.0);
+ + (tv1->tv_usec - tv0->tv_usec) / 1000000.0);
}
static int
compare_font_family (PangoFontFamily** a,
- PangoFontFamily** b)
+ PangoFontFamily** b)
{
return strcmp (pango_font_family_get_name (*a), pango_font_family_get_name (*b));
}
/* try to load some fonts often hardcoded */
for (i = 0; i < G_N_ELEMENTS (std_fonts); i++)
- {
- PangoFontDescription *desc = pango_font_description_from_string(std_fonts[i]);
+ {
+ PangoFontDescription *desc = pango_font_description_from_string(std_fonts[i]);
- /* spits warnings if font cannot be loaded */
- font = pango_font_map_load_font (fontmap, context, desc);
+ /* spits warnings if font cannot be loaded */
+ font = pango_font_map_load_font (fontmap, context, desc);
- g_object_unref (font);
- }
+ g_object_unref (font);
+ }
}
else
{
s = g_string_new (argv[1]);
for (i = 2; i < argc; i++)
- {
- s = g_string_append_c (s, ' ');
- s = g_string_append (s, argv[i]);
+ {
+ s = g_string_append_c (s, ' ');
+ s = g_string_append (s, argv[i]);
- if (0 != atoi (argv[i]))
- my_font_size = atoi (argv[i]);
- }
+ if (0 != atoi (argv[i]))
+ my_font_size = atoi (argv[i]);
+ }
desc = pango_font_description_from_string(s->str);
family_name = g_strdup (pango_font_description_get_family (desc));
{
/* Get on the family faces. No simple way ? */
for (i = 0; i < nb; i++)
- {
- if (0 == g_ascii_strcasecmp (pango_font_family_get_name (families[i]), family_name))
- {
- pango_font_family_list_faces (families[i], &faces, &nb);
- /* now nb is the number of faces */
- break;
- }
- }
+ {
+ if (0 == g_ascii_strcasecmp (pango_font_family_get_name (families[i]), family_name))
+ {
+ pango_font_family_list_faces (families[i], &faces, &nb);
+ /* now nb is the number of faces */
+ break;
+ }
+ }
g_free (families);
families = NULL;
g_free (family_name);
PangoStyle style;
if (families)
- {
- desc = pango_font_description_new ();
+ {
+ desc = pango_font_description_new ();
- f_name = pango_font_family_get_name (families[i]);
- pango_font_description_set_family (desc, f_name);
- }
+ f_name = pango_font_family_get_name (families[i]);
+ pango_font_description_set_family (desc, f_name);
+ }
else
- {
- desc = pango_font_face_describe (faces[i]);
- /* this is _not_ the family name from above */
- f_name = pango_font_description_get_family (desc);
- }
+ {
+ desc = pango_font_face_describe (faces[i]);
+ /* this is _not_ the family name from above */
+ f_name = pango_font_description_get_family (desc);
+ }
weight = pango_font_description_get_weight (desc);
style = pango_font_description_get_style (desc);
g_print ("%s; Style: %d; Weight: %d\n",
- f_name, style, weight);
+ f_name, style, weight);
/* give it an arbitray size to load it */
pango_font_description_set_size (desc, my_font_size * PANGO_SCALE);
g_print ("\tpango_font_map_load_font took %.3f sec\n", calc_duration (&tv1, &tv0));
if (font)
- {
- PangoItem *item;
- PangoGlyphString * glyphs;
- char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "1234567890 -+*/!\xc2\xa7$%&()[]{}<>|#=?@";
-
- g_get_current_time (&tv0);
- coverage = pango_font_get_coverage (font, lang);
- g_get_current_time (&tv1);
- g_print ("\tpango_font_get_coverage took %.3f sec\n", calc_duration (&tv1, &tv0));
-
- /* ... */
- pango_context_set_language (context, lang);
- pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
- pango_context_set_font_description (context, desc);
-
- glyphs = pango_glyph_string_new ();
- item = pango_item_new ();
-
- item->analysis.shape_engine = pango_font_find_shaper (font, lang, s[0]);
- item->analysis.font = g_object_ref (font);
- pango_shape ( s, sizeof(s), &(item->analysis), glyphs);
-
- if (hdc)
- {
- /* the positioning isn't correct */
- char* name = g_strdup_printf ("%s (%s%s)",
- f_name,
- weight == PANGO_WEIGHT_NORMAL ? "n" :
- (weight == PANGO_WEIGHT_HEAVY ? "h" :
- (weight > PANGO_WEIGHT_NORMAL ? "b" : "l")),
- style == PANGO_STYLE_OBLIQUE ? "o" :
- (style == PANGO_STYLE_ITALIC ? "i" : "n"));
-
- TextOut (hdc, 0, line, name, strlen(name));
- g_get_current_time (&tv0);
- pango_win32_render (hdc, font, glyphs, 200, line);
- g_get_current_time (&tv1);
- g_print ("\tpango_win32_render took %.3f sec\n",
- calc_duration (&tv1, &tv0));
- line += (3 * my_font_size / 2);
- g_free(name);
- }
-
- /* free glyphs, ... */
- pango_glyph_string_free (glyphs);
- pango_item_free (item);
-
- pango_coverage_unref (coverage);
- g_object_unref (font);
- }
+ {
+ PangoItem *item;
+ PangoGlyphString * glyphs;
+ char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "1234567890 -+*/!\xc2\xa7$%&()[]{}<>|#=?@";
+
+ g_get_current_time (&tv0);
+ coverage = pango_font_get_coverage (font, lang);
+ g_get_current_time (&tv1);
+ g_print ("\tpango_font_get_coverage took %.3f sec\n", calc_duration (&tv1, &tv0));
+
+ /* ... */
+ pango_context_set_language (context, lang);
+ pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
+ pango_context_set_font_description (context, desc);
+
+ glyphs = pango_glyph_string_new ();
+ item = pango_item_new ();
+
+ item->analysis.shape_engine = pango_font_find_shaper (font, lang, s[0]);
+ item->analysis.font = g_object_ref (font);
+ pango_shape ( s, sizeof(s), &(item->analysis), glyphs);
+
+ if (hdc)
+ {
+ /* the positioning isn't correct */
+ char* name = g_strdup_printf ("%s (%s%s)",
+ f_name,
+ weight == PANGO_WEIGHT_NORMAL ? "n" :
+ (weight == PANGO_WEIGHT_HEAVY ? "h" :
+ (weight > PANGO_WEIGHT_NORMAL ? "b" : "l")),
+ style == PANGO_STYLE_OBLIQUE ? "o" :
+ (style == PANGO_STYLE_ITALIC ? "i" : "n"));
+
+ TextOut (hdc, 0, line, name, strlen(name));
+ g_get_current_time (&tv0);
+ pango_win32_render (hdc, font, glyphs, 200, line);
+ g_get_current_time (&tv1);
+ g_print ("\tpango_win32_render took %.3f sec\n",
+ calc_duration (&tv1, &tv0));
+ line += (3 * my_font_size / 2);
+ g_free(name);
+ }
+
+ /* free glyphs, ... */
+ pango_glyph_string_free (glyphs);
+ pango_item_free (item);
+
+ pango_coverage_unref (coverage);
+ g_object_unref (font);
+ }
pango_font_description_free (desc);
}
*/
hDC = CreateCompatibleDC(NULL);
if (!GetDIBits(hDC, hBmp, 0, (WORD) pbih->biHeight,
- lpBits, pbmi, DIB_RGB_COLORS))
+ lpBits, pbmi, DIB_RGB_COLORS))
return FALSE;
/* Create the .BMP file. */
hf = CreateFile (pszFile,
hdr.bfType = 0x4d42; /* 0x42 = "B" 0x4d = "M" */
/* Compute the size of the entire file. */
hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER)
- + pbih->biSize + pbih->biClrUsed
+ + pbih->biSize + pbih->biClrUsed
* sizeof(RGBQUAD) + pbih->biSizeImage);
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
/* Compute the offset to the array of color indices. */
hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER)
- + pbih->biSize + pbih->biClrUsed
+ + pbih->biSize + pbih->biClrUsed
* sizeof (RGBQUAD);
/* Copy the BITMAPFILEHEADER into the .BMP file. */
if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),
return FALSE;
/* Copy the BITMAPINFOHEADER and RGBQUAD array into the file. */
if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER)
- + pbih->biClrUsed * sizeof (RGBQUAD),
+ + pbih->biClrUsed * sizeof (RGBQUAD),
(LPDWORD) &dwTmp, (LPOVERLAPPED) NULL))
return FALSE;
/* Copy the array of color indices into the .BMP file. */
dwTotal = cb = pbih->biSizeImage;
if (!WriteFile(hf, (LPSTR) lpBits, (int) cb,
- (LPDWORD) &dwTotal, (LPOVERLAPPED) NULL))
+ (LPDWORD) &dwTotal, (LPOVERLAPPED) NULL))
return FALSE;
/* Close the .BMP file. */
(prev_wc == ALEF && IS_COMPOSITE_WITH_ALEF (this_wc)) ||
(this_wc == HAMZA_ABOVE && (prev_wc == WAW || prev_wc == YEH))
))
- attrs[i+1].backspace_deletes_character = FALSE;
+ attrs[i+1].backspace_deletes_character = FALSE;
}
}
MARK_GLYPH : SIMPLE_GLYPH;
Arabic[j].glyph_index = TT_Char_Index (char_map, i);
if (Arabic[j].glyph_index)
- j++;
+ j++;
}
num_glyphs = j;
classes[j] = Arabic[i].class;
if (glyph_indices[j - 1] != glyph_indices[j])
- j++;
+ j++;
}
num_glyphs = j;
while (1)
{
if (pos == 0 && direction < 0)
- return none;
+ return none;
pos += direction;
if (pos >= length)
- return none;
+ return none;
if (string[pos] >= 0x0620 &&
- string[pos] < 0x0700)
- j = arabic[string[pos] - 0x0620];
+ string[pos] < 0x0700)
+ j = arabic[string[pos] - 0x0620];
else if (string[pos] >= 0x0750 &&
- string[pos] < 0x0780)
- j = arabic_supplement[string[pos] - 0x0750];
+ string[pos] < 0x0780)
+ j = arabic_supplement[string[pos] - 0x0750];
else if (string[pos] == 0x200D)
- return causing;
+ return causing;
else
- return none;
+ return none;
if (!direction || j != transparent)
- return j;
+ return j;
}
}
if (previous == causing ||
previous == left ||
previous == dual )
- if (current == right)
+ if (current == right)
{
properties[i] |= final_p;
continue;
/* R3 */
if (current == left)
- if (next == causing ||
+ if (next == causing ||
next == right ||
next == dual )
{
if (previous == causing ||
previous == left ||
previous == dual )
- if (current == dual)
- if (next == causing ||
+ if (current == dual)
+ if (next == causing ||
next == right ||
next == dual )
{
if (previous == causing ||
previous == left ||
previous == dual )
- if (current == dual)
- if (!(next == causing ||
+ if (current == dual)
+ if (!(next == causing ||
next == right ||
next == dual ))
{
if (!(previous == causing ||
previous == left ||
previous == dual ))
- if (current == dual)
- if (next == causing ||
+ if (current == dual)
+ if (next == causing ||
next == right ||
next == dual )
{
static PangoEngineInfo script_engines[] = {
{
- "ArabicScriptEngineX",
- PANGO_ENGINE_TYPE_SHAPE,
- PANGO_RENDER_TYPE_X,
- arabic_range, G_N_ELEMENTS(arabic_range)
+ "ArabicScriptEngineX",
+ PANGO_ENGINE_TYPE_SHAPE,
+ PANGO_RENDER_TYPE_X,
+ arabic_range, G_N_ELEMENTS(arabic_range)
}
};
ArabicFontInfo *fs = NULL;
if (subfont != 0)
- {
- if ( pango_x_has_glyph /* Alif-Madda */
- (font,PANGO_X_MAKE_GLYPH(subfont,0xFE81)))
- {
- fs = g_new (ArabicFontInfo,1);
- fs->level = ar_standard | ar_unifont;
- fs->subfonts[0] = subfont;
-
- if ( pango_x_has_glyph /* Shadda+Kasra */
- (font,PANGO_X_MAKE_GLYPH(subfont,0xFC62)))
- {
- fs->level |= ar_composedtashkeel;
- /* extra vowels in font, hopefully */
- }
- if ( pango_x_has_glyph /* Lam-Min alone */
- (font,PANGO_X_MAKE_GLYPH(subfont,0xFC42)))
- {
- fs->level |= ar_lig;
- /* extra ligatures in font, hopefully */
- }
- }
- }
+ {
+ if ( pango_x_has_glyph /* Alif-Madda */
+ (font,PANGO_X_MAKE_GLYPH(subfont,0xFE81)))
+ {
+ fs = g_new (ArabicFontInfo,1);
+ fs->level = ar_standard | ar_unifont;
+ fs->subfonts[0] = subfont;
+
+ if ( pango_x_has_glyph /* Shadda+Kasra */
+ (font,PANGO_X_MAKE_GLYPH(subfont,0xFC62)))
+ {
+ fs->level |= ar_composedtashkeel;
+ /* extra vowels in font, hopefully */
+ }
+ if ( pango_x_has_glyph /* Lam-Min alone */
+ (font,PANGO_X_MAKE_GLYPH(subfont,0xFC42)))
+ {
+ fs->level |= ar_lig;
+ /* extra ligatures in font, hopefully */
+ }
+ }
+ }
return fs;
}
find_unic_font (PangoFont *font)
{
static char *charsets[] = {
- "iso10646-1",
- "iso8859-6.8x",
- "mulearabic-2",
+ "iso10646-1",
+ "iso8859-6.8x",
+ "mulearabic-2",
"urdunaqsh-0",
/* "symbol-0" */
};
if (fs) return fs;
n_subfonts = pango_x_list_subfonts (font, charsets, 4,
- &subfonts, &subfont_charsets);
+ &subfonts, &subfont_charsets);
for (i=0; i < n_subfonts; i++)
- {
- if ( !strcmp (charsets[subfont_charsets[i]], "mulearabic-2"))
- {
+ {
+ if ( !strcmp (charsets[subfont_charsets[i]], "mulearabic-2"))
+ {
#ifdef DEBUG
- if (getenv("PANGO_AR_NOMULEFONT") == NULL )
+ if (getenv("PANGO_AR_NOMULEFONT") == NULL )
#endif
- fs = arabic_muleinit(font);
- }
- else if ( !strcmp (charsets[subfont_charsets[i]], "iso8859-6.8x"))
- {
+ fs = arabic_muleinit(font);
+ }
+ else if ( !strcmp (charsets[subfont_charsets[i]], "iso8859-6.8x"))
+ {
#ifdef DEBUG
- if (getenv("PANGO_AR_NOLBOXFONT") == NULL )
+ if (getenv("PANGO_AR_NOLBOXFONT") == NULL )
#endif
- fs = arabic_lboxinit(font);
- }
- else if ( !strcmp (charsets[subfont_charsets[i]], "urdunaqsh-0"))
- {
+ fs = arabic_lboxinit(font);
+ }
+ else if ( !strcmp (charsets[subfont_charsets[i]], "urdunaqsh-0"))
+ {
#ifdef DEBUG
- if (getenv("PANGO_AR_NONQFONT") == NULL )
+ if (getenv("PANGO_AR_NONQFONT") == NULL )
#endif
- fs = urdu_naqshinit(font);
- }
- else
- {
+ fs = urdu_naqshinit(font);
+ }
+ else
+ {
#ifdef DEBUG
- if (getenv("PANGO_AR_NOUNIFONT") == NULL )
+ if (getenv("PANGO_AR_NOUNIFONT") == NULL )
#endif
- fs = arabic_unicodeinit(font,subfonts[i]);
- }
- if (fs){
- g_object_set_qdata_full (G_OBJECT (font), info_id,
- fs, (GDestroyNotify)g_free);
- break;
- }
- }
+ fs = arabic_unicodeinit(font,subfonts[i]);
+ }
+ if (fs){
+ g_object_set_qdata_full (G_OBJECT (font), info_id,
+ fs, (GDestroyNotify)g_free);
+ break;
+ }
+ }
g_free (subfonts);
g_free (subfont_charsets);
static void
set_glyph (PangoGlyphString *glyphs,
- PangoFont *font, PangoXSubfont subfont,
- int i, int cluster_start, int glyph, int is_vowel)
+ PangoFont *font, PangoXSubfont subfont,
+ int i, int cluster_start, int glyph, int is_vowel)
{
PangoRectangle logical_rect;
pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
glyphs->log_clusters[i] = cluster_start;
if (is_vowel)
- {
- glyphs->glyphs[i].geometry.width = 0;
- }
+ {
+ glyphs->glyphs[i].geometry.width = 0;
+ }
else
- {
- glyphs->glyphs[i].geometry.width = logical_rect.width;
- }
+ {
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
+ }
}
static void
arabic_engine_shape (PangoFont *font,
- const char *text,
- int length,
- PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+ const char *text,
+ int length,
+ PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
{
PangoXSubfont subfont;
int n_chars;
*/
if (! (fs = find_unic_font (font)) )
- {
+ {
- PangoGlyph unknown_glyph = pango_x_get_unknown_glyph (font);
+ PangoGlyph unknown_glyph = pango_x_get_unknown_glyph (font);
- n_chars = g_utf8_strlen(text,length);
- pango_glyph_string_set_size (glyphs, n_chars);
+ n_chars = g_utf8_strlen(text,length);
+ pango_glyph_string_set_size (glyphs, n_chars);
- p = text;
- for (i=0; i<n_chars; i++)
- {
- set_glyph (glyphs, font,
- PANGO_X_GLYPH_SUBFONT (unknown_glyph), i,
- p - text, PANGO_X_GLYPH_INDEX (unknown_glyph),0);
- p = g_utf8_next_char (p);
- }
- return;
- }
+ p = text;
+ for (i=0; i<n_chars; i++)
+ {
+ set_glyph (glyphs, font,
+ PANGO_X_GLYPH_SUBFONT (unknown_glyph), i,
+ p - text, PANGO_X_GLYPH_INDEX (unknown_glyph),0);
+ p = g_utf8_next_char (p);
+ }
+ return;
+ }
p = text;
if (analysis->level % 2 == 0)
- {
- wc = g_utf8_to_ucs4_fast(text,length,&n_chars);
- /* We were called on a LTR directional run (e.g. some numbers);
- fallback as simple as possible */
- pango_glyph_string_set_size (glyphs, n_chars);
+ {
+ wc = g_utf8_to_ucs4_fast(text,length,&n_chars);
+ /* We were called on a LTR directional run (e.g. some numbers);
+ fallback as simple as possible */
+ pango_glyph_string_set_size (glyphs, n_chars);
- }
+ }
else
- {
- wc = (gunichar *)g_malloc(sizeof(gunichar)* (length) ); /* length is succicient: all arabic chars use at
+ {
+ wc = (gunichar *)g_malloc(sizeof(gunichar)* (length) ); /* length is succicient: all arabic chars use at
least 2 bytes in utf-8 encoding */
- n_chars = length;
- arabic_reshape(&n_chars,text,wc,fs->level);
- pango_glyph_string_set_size (glyphs, n_chars);
- };
+ n_chars = length;
+ arabic_reshape(&n_chars,text,wc,fs->level);
+ pango_glyph_string_set_size (glyphs, n_chars);
+ };
p = text;
subfont = fs->subfonts[0];
while(i < n_chars)
- {
- if (wc[i] == 0)
- {
- p = g_utf8_next_char (p);
+ {
+ if (wc[i] == 0)
+ {
+ p = g_utf8_next_char (p);
#ifdef DEBUG
- fprintf(stderr,"NULL-character detected in generated string.!");
+ fprintf(stderr,"NULL-character detected in generated string.!");
#endif
- i++;
- }
- else
- {
- int cluster_start ;
- int is_vowel = arabic_isvowel(wc[i]);
- cluster_start = is_vowel ? pold - text : p - text;
-
- if ( fs->level & ar_mulefont )
- {
- arabic_mule_recode(&subfont,&(wc[i]),
- fs->subfonts);
- }
- else if ( fs->level & ar_lboxfont )
- {
- if (( i < n_chars-1 )&&(wc[i+1] == 0))
- {
- arabic_lbox_recode(&subfont,&(wc[i]),
- &(wc[i+1]),
- fs->subfonts);
- }
- else
- arabic_lbox_recode(&subfont,&(wc[i]),NULL,
- fs->subfonts);
- }
- else if ( fs->level & ar_naqshfont )
- {
- if (( i < n_chars-1 )&&(wc[i+1] == 0))
- {
- urdu_naqsh_recode(&subfont,&(wc[i]),
- &(wc[i+1]),
- fs->subfonts);
- }
- else
- urdu_naqsh_recode(&subfont,&(wc[i]),NULL,
- fs->subfonts);
- }
-
- set_glyph(glyphs, font, subfont, n_chars - i - 1,
- cluster_start, wc[i], is_vowel);
-
- pold = p;
- p = g_utf8_next_char (p);
- i++;
- }
- }
+ i++;
+ }
+ else
+ {
+ int cluster_start ;
+ int is_vowel = arabic_isvowel(wc[i]);
+ cluster_start = is_vowel ? pold - text : p - text;
+
+ if ( fs->level & ar_mulefont )
+ {
+ arabic_mule_recode(&subfont,&(wc[i]),
+ fs->subfonts);
+ }
+ else if ( fs->level & ar_lboxfont )
+ {
+ if (( i < n_chars-1 )&&(wc[i+1] == 0))
+ {
+ arabic_lbox_recode(&subfont,&(wc[i]),
+ &(wc[i+1]),
+ fs->subfonts);
+ }
+ else
+ arabic_lbox_recode(&subfont,&(wc[i]),NULL,
+ fs->subfonts);
+ }
+ else if ( fs->level & ar_naqshfont )
+ {
+ if (( i < n_chars-1 )&&(wc[i+1] == 0))
+ {
+ urdu_naqsh_recode(&subfont,&(wc[i]),
+ &(wc[i+1]),
+ fs->subfonts);
+ }
+ else
+ urdu_naqsh_recode(&subfont,&(wc[i]),NULL,
+ fs->subfonts);
+ }
+
+ set_glyph(glyphs, font, subfont, n_chars - i - 1,
+ cluster_start, wc[i], is_vowel);
+
+ pold = p;
+ p = g_utf8_next_char (p);
+ i++;
+ }
+ }
g_free(wc);
}
static PangoCoverage *
arabic_engine_get_coverage (PangoFont *font,
- const char *lang)
+ const char *lang)
{
gunichar i;
PangoCoverage *result = pango_coverage_new ();
for (i = 0x60B; i <= 0x66D; i++)
- pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
for (i = 0x670; i <= 0x6D3; i++)
- pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
return result;
}
index = pango_fc_font_get_glyph (fc_font, wc);
if (!index)
- {
+ {
index = PANGO_GET_UNKNOWN_GLYPH ( wc);
- set_glyph (font, glyphs, i, p - text, index);
+ set_glyph (font, glyphs, i, p - text, index);
}
else
{
for (i = 0; i < G_N_ELEMENTS (scripts); i++)
{
- PangoOTTag script_tag = FT_MAKE_TAG (scripts[i][0], scripts[i][1], scripts[i][2], scripts[i][3]);
- guint script_index;
+ PangoOTTag script_tag = FT_MAKE_TAG (scripts[i][0], scripts[i][1], scripts[i][2], scripts[i][3]);
+ guint script_index;
- if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS, script_tag, &script_index))
- for (j = 0; j < G_N_ELEMENTS (gpos_features); j++)
+ if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS, script_tag, &script_index))
+ for (j = 0; j < G_N_ELEMENTS (gpos_features); j++)
{
- PangoOTTag feature_tag = FT_MAKE_TAG (gpos_features[j][0], gpos_features[j][1],
- gpos_features[j][2], gpos_features[j][3]);
- guint feature_index;
-
- /* 0xffff means default language */
- if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GPOS, feature_tag, script_index, 0xffff,&feature_index))
- {
- pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index, 0xffff);
+ PangoOTTag feature_tag = FT_MAKE_TAG (gpos_features[j][0], gpos_features[j][1],
+ gpos_features[j][2], gpos_features[j][3]);
+ guint feature_index;
+
+ /* 0xffff means default language */
+ if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GPOS, feature_tag, script_index, 0xffff,&feature_index))
+ {
+ pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index, 0xffff);
}
}
- if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB, script_tag, &script_index))
- for (j = 0; j < G_N_ELEMENTS (gsub_features); j++)
- {
- PangoOTTag feature_tag = FT_MAKE_TAG (gsub_features[j][0], gsub_features[j][1],
- gsub_features[j][2], gsub_features[j][3]);
- guint feature_index;
-
- /* 0xffff means default language */
- if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GSUB, feature_tag,
- script_index, 0xffff, &feature_index))
- {
- pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GSUB, feature_index, 0xffff);
- }
- }
+ if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB, script_tag, &script_index))
+ for (j = 0; j < G_N_ELEMENTS (gsub_features); j++)
+ {
+ PangoOTTag feature_tag = FT_MAKE_TAG (gsub_features[j][0], gsub_features[j][1],
+ gsub_features[j][2], gsub_features[j][3]);
+ guint feature_index;
+
+ /* 0xffff means default language */
+ if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GSUB, feature_tag,
+ script_index, 0xffff, &feature_index))
+ {
+ pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GSUB, feature_index, 0xffff);
+ }
+ }
}
g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, (GDestroyNotify) g_object_unref);
pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, unknown_property, p - text);
}
else
- {
+ {
index = pango_fc_font_get_glyph (fc_font, wc);
if (!index)
static PangoGlyph
conv_16bit_MSB_on (CharCache *cache,
- GIConv cd,
- const char *input)
+ GIConv cd,
+ const char *input)
{
char outbuf[2];
static void
set_glyph_tone (PangoFont *font, PangoGlyphString *glyphs, int i,
- int offset, PangoGlyph glyph)
+ int offset, PangoGlyph glyph)
{
PangoRectangle logical_rect, ink_rect;
PangoRectangle logical_rect_cluster;
if (logical_rect.width)
{
glyphs->glyphs[i].geometry.x_offset -= ink_rect.width;
- glyphs->glyphs[j + 1].geometry.width += ink_rect.width;
- glyphs->glyphs[j + 1].geometry.x_offset += ink_rect.width;
+ glyphs->glyphs[j + 1].geometry.width += ink_rect.width;
+ glyphs->glyphs[j + 1].geometry.x_offset += ink_rect.width;
}
}
static void
render_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs,
- int *n_glyphs, int cluster_offset)
+ int *n_glyphs, int cluster_offset)
{
int index;
/* fall back : HTONE1(0x302e) => middle-dot, HTONE2(0x302f) => colon */
index = find_char (font, tone == HTONE1 ? 0x00b7 : 0x003a);
if (index)
- {
- set_glyph_tone (font, glyphs, *n_glyphs, cluster_offset, index);
- }
+ {
+ set_glyph_tone (font, glyphs, *n_glyphs, cluster_offset, index);
+ }
else
- set_glyph (font, glyphs, *n_glyphs, cluster_offset,
+ set_glyph (font, glyphs, *n_glyphs, cluster_offset,
PANGO_GET_UNKNOWN_GLYPH (tone));
}
(*n_glyphs)++;
continue;
}
else if (IS_S(wc))
- {
+ {
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (font, glyphs, *n_glyphs, cluster_offset,
PANGO_GET_UNKNOWN_GLYPH (wc));
if (pango_is_zero_width (wc))
glyph_num[i] = PANGO_GLYPH_EMPTY;
else
- {
+ {
glyph_num[i] = pango_fc_font_get_glyph ((PangoFcFont *)font, wc);
if (!glyph_num[i])
/* 0, 1, 2, 3, 4, 5, 6, 7 */
/*00*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
+ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
/*10*/ _ND, _NS, _NS, _NS, _NS, _NS, _NS, _NS,
- _NS, _NS, _NS, _NS, _NS, _NS, _NS, _NS,
+ _NS, _NS, _NS, _NS, _NS, _NS, _NS, _NS,
/*20*/ _NS, _NS, _ND, _NS, _NS, _NS, _NS, _NS,
- _NS, _NS, _NS, _NS, _NS, _NS, _NS, _NS,
+ _NS, _NS, _NS, _NS, _NS, _NS, _NS, _NS,
/*30*/ _NS, _NS, _NS, _NS, _NS, _NS, _NS, _NS,
- _NS, _NS, _ND, _NS, _DA, _NS, _SP, _NS,
+ _NS, _NS, _ND, _NS, _DA, _NS, _SP, _NS,
/*40*/ _SP, _NS, _NS, _SP, _NS, _ND, _ND, _ND,
- _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
+ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
/*50*/ _SP, _SP, _SP, _SP, _SP, _SP, _SP, _SP,
- _SP, _SP, _SP, _SP, _SP, _SP, _SP, _SP,
+ _SP, _SP, _SP, _SP, _SP, _SP, _SP, _SP,
/*60*/ _SP, _SP, _SP, _SP, _SP, _SP, _SP, _SP,
- _SP, _SP, _SP, _ND, _ND, _ND, _ND, _ND,
+ _SP, _SP, _SP, _ND, _ND, _ND, _ND, _ND,
/*70*/ _SP, _SP, _SP, _SP, _SP, _ND, _ND, _ND,
_ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
};
/* 0, 1, 2, 3, 4, 5, 6, 7 */
/*00*/ __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
- __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
+ __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
/*10*/ __ND, __NS, __NS, __NS, __NS, __NS, __NS, __NS,
- __NS, __NS, __NS, __NS, __NS, __NS, __NS, __NS,
+ __NS, __NS, __NS, __NS, __NS, __NS, __NS, __NS,
/*20*/ __NS, __NS, __ND, __NS, __NS, __NS, __NS, __NS,
- __NS, __NS, __NS, __NS, __NS, __NS, __NS, __NS,
+ __NS, __NS, __NS, __NS, __NS, __NS, __NS, __NS,
/*30*/ __NS, __NS, __NS, __NS, __NS, __NS, __NS, __NS,
- __NS, __NS, __ND, __NS, __DA, __NS, __SP, __NS,
+ __NS, __NS, __ND, __NS, __DA, __NS, __SP, __NS,
/*40*/ __SP, __NS, __NS, __SP, __NS, __ND, __ND, __ND,
- __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
+ __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
/*50*/ __SP, __SP, __SP, __SP, __SP, __SP, __SP, __SP,
- __SP, __SP, __SP, __SP, __SP, __SP, __SP, __SP,
+ __SP, __SP, __SP, __SP, __SP, __SP, __SP, __SP,
/*60*/ __SP, __SP, __SP, __SP, __SP, __SP, __SP, __SP,
- __SP, __SP, __SP, __ND, __ND, __ND, __ND, __ND,
+ __SP, __SP, __SP, __ND, __ND, __ND, __ND, __ND,
/*70*/ __SP, __SP, __SP, __SP, __SP, __ND, __ND, __ND,
__ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
};
static void
maybe_add_GPOS_feature (PangoOTRuleset *ruleset,
- PangoOTInfo *info,
+ PangoOTInfo *info,
guint script_index,
PangoOTTag feature_tag,
gulong property_bit)
(!process_zwj || wcs[i] != 0x200D))
glyph = PANGO_GLYPH_EMPTY;
else
- {
+ {
glyph = pango_fc_font_get_glyph (fc_font, wcs[i]);
if (!glyph)
attrs[i].is_mandatory_break = FALSE;
}
else if (prev_wc != 0 && (this_wc == 0x200D || this_wc == 0x200C))
- {
- if (next_wc != 0)
- {
- if (next_next_wc == 0)
- {
- attrs[i].is_cursor_position = FALSE;
- attrs[i].is_char_break = FALSE;
- attrs[i].is_line_break = FALSE;
- attrs[i].is_mandatory_break = FALSE;
-
- i++;
-
- attrs[i].is_cursor_position = FALSE;
- attrs[i].is_char_break = FALSE;
- attrs[i].is_line_break = FALSE;
- attrs[i].is_mandatory_break = FALSE;
- }
- else if ((next_next_wc != 0) &&
- (next_wc == 0x09CD || /* Bengali */
- next_wc == 0x0ACD || /* Gujarati */
- next_wc == 0x094D || /* Hindi */
- next_wc == 0x0CCD || /* Kannada */
- next_wc == 0x0D4D || /* Malayalam */
- next_wc == 0x0B4D || /* Oriya */
- next_wc == 0x0A4D || /* Punjabi */
- next_wc == 0x0BCD || /* Tamil */
- next_wc == 0x0C4D || /* Telugu */
- next_wc == 0x0DCA)) /*Sinhala*/
- {
- attrs[i].is_cursor_position = FALSE;
- attrs[i].is_char_break = FALSE;
- attrs[i].is_line_break = FALSE;
- attrs[i].is_mandatory_break = FALSE;
-
- i++;
-
- attrs[i].is_cursor_position = FALSE;
- attrs[i].is_char_break = FALSE;
- attrs[i].is_line_break = FALSE;
- attrs[i].is_mandatory_break = FALSE;
-
- i++;
- attrs[i].is_cursor_position = FALSE;
- }
- }
- else
- {
- attrs[i].is_cursor_position = FALSE;
+ {
+ if (next_wc != 0)
+ {
+ if (next_next_wc == 0)
+ {
+ attrs[i].is_cursor_position = FALSE;
+ attrs[i].is_char_break = FALSE;
+ attrs[i].is_line_break = FALSE;
+ attrs[i].is_mandatory_break = FALSE;
+
+ i++;
+
+ attrs[i].is_cursor_position = FALSE;
+ attrs[i].is_char_break = FALSE;
+ attrs[i].is_line_break = FALSE;
+ attrs[i].is_mandatory_break = FALSE;
+ }
+ else if ((next_next_wc != 0) &&
+ (next_wc == 0x09CD || /* Bengali */
+ next_wc == 0x0ACD || /* Gujarati */
+ next_wc == 0x094D || /* Hindi */
+ next_wc == 0x0CCD || /* Kannada */
+ next_wc == 0x0D4D || /* Malayalam */
+ next_wc == 0x0B4D || /* Oriya */
+ next_wc == 0x0A4D || /* Punjabi */
+ next_wc == 0x0BCD || /* Tamil */
+ next_wc == 0x0C4D || /* Telugu */
+ next_wc == 0x0DCA)) /*Sinhala*/
+ {
+ attrs[i].is_cursor_position = FALSE;
+ attrs[i].is_char_break = FALSE;
+ attrs[i].is_line_break = FALSE;
+ attrs[i].is_mandatory_break = FALSE;
+
+ i++;
+
+ attrs[i].is_cursor_position = FALSE;
+ attrs[i].is_char_break = FALSE;
+ attrs[i].is_line_break = FALSE;
+ attrs[i].is_mandatory_break = FALSE;
+
+ i++;
+ attrs[i].is_cursor_position = FALSE;
+ }
+ }
+ else
+ {
+ attrs[i].is_cursor_position = FALSE;
attrs[i].is_char_break = FALSE;
attrs[i].is_line_break = FALSE;
attrs[i].is_mandatory_break = FALSE;
- }
+ }
}
}
}
static const IndicOTSplitMatra teluSplitTable[] = {{0x0C46, 0x0C56}};
static const IndicOTSplitMatra kndaSplitTable[] = {{0x0CBF, 0x0CD5}, {0x0CC6, 0x0CD5}, {0x0CC6, 0x0CD6}, {0x0CC6, 0x0CC2},
- {0x0CC6, 0x0CC2, 0x0CD5}};
+ {0x0CC6, 0x0CC2, 0x0CD5}};
static const IndicOTSplitMatra mlymSplitTable[] = {{0x0D46, 0x0D3E}, {0x0D47, 0x0D3E}, {0x0D46, 0x0D57}};
/* Add a little macro to compute lastChar based on size of the charClasses * table */
#define INDIC_OT_CLASS_TABLE_DEFINE(name, firstChar, worstCaseExpansion, scriptFlags, charClasses, splitMatraTable) \
const IndicOTClassTable name = {firstChar, firstChar + G_N_ELEMENTS (charClasses) - 1, \
- worstCaseExpansion, scriptFlags, charClasses, splitMatraTable}
+ worstCaseExpansion, scriptFlags, charClasses, splitMatraTable}
INDIC_OT_CLASS_TABLE_DEFINE (deva_class_table, 0x0900, 2, DEVA_SCRIPT_FLAGS, devaCharClasses, NULL);
INDIC_OT_CLASS_TABLE_DEFINE (beng_class_table, 0x0980, 3, BENG_SCRIPT_FLAGS, bengCharClasses, bengSplitTable);
INDIC_OT_CLASS_TABLE_DEFINE (guru_class_table, 0x0A00, 2, GURU_SCRIPT_FLAGS, guruCharClasses, NULL);
IndicOTCharClass indic_ot_get_char_class(const IndicOTClassTable *class_table, gunichar ch)
{
if (ch == C_SIGN_ZWJ) {
- return CF_CONSONANT | CC_ZERO_WIDTH_MARK;
+ return CF_CONSONANT | CC_ZERO_WIDTH_MARK;
}
if (ch == C_SIGN_ZWNJ) {
- return CC_ZERO_WIDTH_MARK;
+ return CC_ZERO_WIDTH_MARK;
}
if (ch < class_table->firstChar || ch > class_table->lastChar) {
- return CC_RESERVED;
+ return CC_RESERVED;
}
return class_table->charClasses[ch - class_table->firstChar];
gint8 state = 0;
while (cursor < char_count) {
- IndicOTCharClass char_class = indic_ot_get_char_class(class_table, chars[cursor]);
+ IndicOTCharClass char_class = indic_ot_get_char_class(class_table, chars[cursor]);
- state = stateTable[state][char_class & CF_CLASS_MASK];
+ state = stateTable[state][char_class & CF_CLASS_MASK];
- /*for the components of split matra*/
+ /*for the components of split matra*/
if ((char_count >= cursor + 3) &&
(chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DCF && chars[cursor + 2] == 0x0DCA)) { /*for 3 split matra of Sinhala*/
return cursor + 3;
}
else if ((char_count >= cursor + 3) &&
- (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CC2 && chars[cursor + 2] == 0x0CD5)) { /*for 3 split matra of Kannada*/
+ (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CC2 && chars[cursor + 2] == 0x0CD5)) { /*for 3 split matra of Kannada*/
return cursor + 3;
}
- /*for 2 split matra*/
+ /*for 2 split matra*/
else if (char_count >= cursor + 2) {
- /*for Bengali*/
- if ((chars[cursor] == 0x09C7 && chars[cursor + 1] == 0x09BE) ||
- (chars[cursor] == 0x09C7 && chars[cursor + 1] == 0x09D7) ||
- /*for Oriya*/
- (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B3E) ||
- (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B56) ||
- (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B57) ||
- /*for Tamil*/
- (chars[cursor] == 0x0BC6 && chars[cursor + 1] == 0x0BBE) ||
- (chars[cursor] == 0x0BC6 && chars[cursor + 1] == 0x0BD7) ||
- (chars[cursor] == 0x0BC7 && chars[cursor + 1] == 0x0BBE) ||
- /*for Malayalam*/
- (chars[cursor] == 0x0D46 && chars[cursor + 1] == 0x0D3E) ||
- (chars[cursor] == 0x0D46 && chars[cursor + 1] == 0x0D57) ||
- (chars[cursor] == 0x0D47 && chars[cursor + 1] == 0x0D3E) ||
- /*for Sinhala*/
- (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DCA) ||
- (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DCF) ||
- (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DDF) ||
- (chars[cursor] == 0x0DDC && chars[cursor + 1] == 0x0DCA) ||
- /*for Telugu*/
- (chars[cursor] == 0x0C46 && chars[cursor + 1] == 0x0C56) ||
- /*for Kannada*/
- (chars[cursor] == 0x0CBF && chars[cursor + 1] == 0x0CD5) ||
- (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CD5) ||
- (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CD6) ||
- (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CC2) ||
- (chars[cursor] == 0x0CCA && chars[cursor + 1] == 0x0CD5))
+ /*for Bengali*/
+ if ((chars[cursor] == 0x09C7 && chars[cursor + 1] == 0x09BE) ||
+ (chars[cursor] == 0x09C7 && chars[cursor + 1] == 0x09D7) ||
+ /*for Oriya*/
+ (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B3E) ||
+ (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B56) ||
+ (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B57) ||
+ /*for Tamil*/
+ (chars[cursor] == 0x0BC6 && chars[cursor + 1] == 0x0BBE) ||
+ (chars[cursor] == 0x0BC6 && chars[cursor + 1] == 0x0BD7) ||
+ (chars[cursor] == 0x0BC7 && chars[cursor + 1] == 0x0BBE) ||
+ /*for Malayalam*/
+ (chars[cursor] == 0x0D46 && chars[cursor + 1] == 0x0D3E) ||
+ (chars[cursor] == 0x0D46 && chars[cursor + 1] == 0x0D57) ||
+ (chars[cursor] == 0x0D47 && chars[cursor + 1] == 0x0D3E) ||
+ /*for Sinhala*/
+ (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DCA) ||
+ (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DCF) ||
+ (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DDF) ||
+ (chars[cursor] == 0x0DDC && chars[cursor + 1] == 0x0DCA) ||
+ /*for Telugu*/
+ (chars[cursor] == 0x0C46 && chars[cursor + 1] == 0x0C56) ||
+ /*for Kannada*/
+ (chars[cursor] == 0x0CBF && chars[cursor + 1] == 0x0CD5) ||
+ (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CD5) ||
+ (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CD6) ||
+ (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CC2) ||
+ (chars[cursor] == 0x0CCA && chars[cursor + 1] == 0x0CD5))
return cursor + 2;
}
- if (state < 0) {
- break;
- }
+ if (state < 0) {
+ break;
+ }
- cursor += 1;
+ cursor += 1;
}
return cursor;
{
/* FIXME: check if already set, or if not a matra... */
if (IS_M_PRE(matraClass)) {
- output->fMpre = matra;
+ output->fMpre = matra;
} else if (IS_M_BELOW(matraClass)) {
- output->fMbelow = matra;
+ output->fMbelow = matra;
} else if (IS_M_ABOVE(matraClass)) {
- output->fMabove = matra;
+ output->fMabove = matra;
} else if (IS_M_POST(matraClass)) {
- output->fMpost = matra;
+ output->fMpost = matra;
} else if (IS_LENGTH_MARK(matraClass)) {
- output->fLengthMark = matra;
+ output->fLengthMark = matra;
} else if (IS_AL_LAKUNA(matraClass)) {
- output->fAlLakuna = matra;
+ output->fAlLakuna = matra;
}
}
IndicOTCharClass matraClass = indic_ot_get_char_class(classTable, matra);
if (IS_MATRA(matraClass)) {
- if (IS_SPLIT_MATRA(matraClass)) {
- const IndicOTSplitMatra *splitMatra = indic_ot_get_split_matra(classTable, matraClass);
- int i;
+ if (IS_SPLIT_MATRA(matraClass)) {
+ const IndicOTSplitMatra *splitMatra = indic_ot_get_split_matra(classTable, matraClass);
+ int i;
- for (i = 0; i < 3 && (*splitMatra)[i] != 0; i += 1) {
- gunichar piece = (*splitMatra)[i];
- IndicOTCharClass pieceClass = indic_ot_get_char_class(classTable, piece);
+ for (i = 0; i < 3 && (*splitMatra)[i] != 0; i += 1) {
+ gunichar piece = (*splitMatra)[i];
+ IndicOTCharClass pieceClass = indic_ot_get_char_class(classTable, piece);
- saveMatra(output, piece, pieceClass);
- }
- } else {
- saveMatra(output, matra, matraClass);
- }
+ saveMatra(output, piece, pieceClass);
+ }
+ } else {
+ saveMatra(output, matra, matraClass);
+ }
return TRUE;
} else
static void noteBaseConsonant(Output *output)
{
if (output->fMPreFixups && output->fMPreOutIndex >= 0) {
- indic_mprefixups_add(output->fMPreFixups, output->fOutIndex, output->fMPreOutIndex);
+ indic_mprefixups_add(output->fMPreFixups, output->fOutIndex, output->fMPreOutIndex);
}
}
static void writeChar(Output *output, gunichar ch, guint32 charIndex, gulong charTags)
{
if (output->fOutChars != NULL) {
- output->fOutChars[output->fOutIndex] = ch;
- output->fCharIndices[output->fOutIndex] = output->fOriginalOffsets[charIndex];
- output->fCharTags[output->fOutIndex] = charTags;
+ output->fOutChars[output->fOutIndex] = ch;
+ output->fCharIndices[output->fOutIndex] = output->fOriginalOffsets[charIndex];
+ output->fCharTags[output->fOutIndex] = charTags;
}
output->fOutIndex += 1;
static void writeMpre(Output *output)
{
if (output->fMpre != 0) {
- gulong tags = output->fMatraTags;
+ gulong tags = output->fMatraTags;
if (output->fMatraWordStart)
tags &= ~init;
- output->fMPreOutIndex = output->fOutIndex;
- writeChar(output, output->fMpre, output->fMatraIndex, tags);
+ output->fMPreOutIndex = output->fOutIndex;
+ writeChar(output, output->fMpre, output->fMatraIndex, tags);
}
}
static void writeMbelow(Output *output)
{
if (output->fMbelow != 0) {
- writeChar(output, output->fMbelow, output->fMatraIndex, output->fMatraTags);
+ writeChar(output, output->fMbelow, output->fMatraIndex, output->fMatraTags);
}
}
static void writeMabove(Output *output)
{
if (output->fMabove != 0) {
- writeChar(output, output->fMabove, output->fMatraIndex, output->fMatraTags);
+ writeChar(output, output->fMabove, output->fMatraIndex, output->fMatraTags);
}
}
static void writeMpost(Output *output)
{
if (output->fMpost != 0) {
- writeChar(output, output->fMpost, output->fMatraIndex, output->fMatraTags);
+ writeChar(output, output->fMpost, output->fMatraIndex, output->fMatraTags);
}
}
static void writeLengthMark(Output *output)
{
if (output->fLengthMark != 0) {
- writeChar(output, output->fLengthMark, output->fMatraIndex, output->fMatraTags);
+ writeChar(output, output->fLengthMark, output->fMatraIndex, output->fMatraTags);
}
}
static void writeAlLakuna(Output *output)
{
if (output->fAlLakuna != 0) {
- writeChar(output, output->fAlLakuna, output->fMatraIndex, output->fMatraTags);
+ writeChar(output, output->fAlLakuna, output->fMatraIndex, output->fMatraTags);
}
}
initOutput(&output, utf8_offsets, out_chars, char_indices, char_tags, mpreFixups);
while (prev < char_count) {
- glong syllable = indic_ot_find_syllable(class_table, chars, prev, char_count);
- glong matra, vmabove, vmpost = syllable;
+ glong syllable = indic_ot_find_syllable(class_table, chars, prev, char_count);
+ glong matra, vmabove, vmpost = syllable;
- while (vmpost > prev && indic_ot_is_vm_post(class_table, chars[vmpost - 1])) {
- vmpost -= 1;
- }
+ while (vmpost > prev && indic_ot_is_vm_post(class_table, chars[vmpost - 1])) {
+ vmpost -= 1;
+ }
- vmabove = vmpost;
- while (vmabove > prev && indic_ot_is_vm_above(class_table, chars[vmabove - 1])) {
- vmabove -= 1;
- }
+ vmabove = vmpost;
+ while (vmabove > prev && indic_ot_is_vm_above(class_table, chars[vmabove - 1])) {
+ vmabove -= 1;
+ }
- matra = vmabove - 1;
+ matra = vmabove - 1;
initMatra(&output, prev, blwf_p, !last_in_word);
- while (noteMatra(&output, class_table, chars[matra]) &&
- matra != prev)
- matra--;
+ while (noteMatra(&output, class_table, chars[matra]) &&
+ matra != prev)
+ matra--;
last_in_word = TRUE;
- switch (indic_ot_get_char_class(class_table, chars[prev]) & CF_CLASS_MASK) {
- case CC_RESERVED:
+ switch (indic_ot_get_char_class(class_table, chars[prev]) & CF_CLASS_MASK) {
+ case CC_RESERVED:
last_in_word = FALSE;
/* Fall through */
- case CC_INDEPENDENT_VOWEL:
- case CC_ZERO_WIDTH_MARK:
- for (i = prev; i < syllable; i += 1) {
- writeChar(&output, chars[i], /*i*/ prev, blwf_p);
- }
-
- break;
-
- case CC_MODIFYING_MARK_ABOVE:
- case CC_MODIFYING_MARK_POST:
- case CC_NUKTA:
- case CC_VIRAMA:
- case CC_AL_LAKUNA:
- writeChar(&output, C_DOTTED_CIRCLE, prev, blwf_p);
- writeChar(&output, chars[prev], prev, blwf_p);
- break;
-
- case CC_DEPENDENT_VOWEL:
- writeMpre(&output);
- writeChar(&output, C_DOTTED_CIRCLE, prev, blwf_p);
- writeMbelow(&output);
- writeMabove(&output);
- writeMpost(&output);
- writeLengthMark(&output);
- writeAlLakuna(&output);
- break;
-
- case CC_CONSONANT:
- case CC_CONSONANT_WITH_NUKTA:
- {
- guint32 length = vmabove - prev;
- glong lastConsonant = vmabove - 1;
- glong baseLimit = prev;
- glong baseConsonant, postBase, postBaseLimit;
+ case CC_INDEPENDENT_VOWEL:
+ case CC_ZERO_WIDTH_MARK:
+ for (i = prev; i < syllable; i += 1) {
+ writeChar(&output, chars[i], /*i*/ prev, blwf_p);
+ }
+
+ break;
+
+ case CC_MODIFYING_MARK_ABOVE:
+ case CC_MODIFYING_MARK_POST:
+ case CC_NUKTA:
+ case CC_VIRAMA:
+ case CC_AL_LAKUNA:
+ writeChar(&output, C_DOTTED_CIRCLE, prev, blwf_p);
+ writeChar(&output, chars[prev], prev, blwf_p);
+ break;
+
+ case CC_DEPENDENT_VOWEL:
+ writeMpre(&output);
+ writeChar(&output, C_DOTTED_CIRCLE, prev, blwf_p);
+ writeMbelow(&output);
+ writeMabove(&output);
+ writeMpost(&output);
+ writeLengthMark(&output);
+ writeAlLakuna(&output);
+ break;
+
+ case CC_CONSONANT:
+ case CC_CONSONANT_WITH_NUKTA:
+ {
+ guint32 length = vmabove - prev;
+ glong lastConsonant = vmabove - 1;
+ glong baseLimit = prev;
+ glong baseConsonant, postBase, postBaseLimit;
gboolean seenVattu, seenBelowBaseForm, supressVattu;
glong bcSpan;
- /* Check for REPH at front of syllable */
- if (length > 2 && indic_ot_is_reph(class_table, chars[prev]) && indic_ot_is_virama(class_table, chars[prev + 1])) {
- baseLimit += 2;
-
- /* Check for eyelash RA, if the script supports it */
- if ((class_table->scriptFlags & SF_EYELASH_RA) != 0 &&
- chars[baseLimit] == C_SIGN_ZWJ) {
- if (length > 3) {
- baseLimit += 1;
- } else {
- baseLimit -= 2;
- }
- }
- }
+ /* Check for REPH at front of syllable */
+ if (length > 2 && indic_ot_is_reph(class_table, chars[prev]) && indic_ot_is_virama(class_table, chars[prev + 1])) {
+ baseLimit += 2;
+
+ /* Check for eyelash RA, if the script supports it */
+ if ((class_table->scriptFlags & SF_EYELASH_RA) != 0 &&
+ chars[baseLimit] == C_SIGN_ZWJ) {
+ if (length > 3) {
+ baseLimit += 1;
+ } else {
+ baseLimit -= 2;
+ }
+ }
+ }
- while (lastConsonant > baseLimit && !indic_ot_is_consonant(class_table, chars[lastConsonant])) {
- lastConsonant -= 1;
- }
+ while (lastConsonant > baseLimit && !indic_ot_is_consonant(class_table, chars[lastConsonant])) {
+ lastConsonant -= 1;
+ }
- baseConsonant = lastConsonant;
- postBase = lastConsonant + 1;
+ baseConsonant = lastConsonant;
+ postBase = lastConsonant + 1;
postBaseLimit = class_table->scriptFlags & SF_POST_BASE_LIMIT_MASK;
seenVattu = false;
}
}
- /* note the base consonant for post-GSUB fixups */
+ /* note the base consonant for post-GSUB fixups */
noteBaseConsonant(&output);
/* write base consonant */
writeChar(&output, chars[i], /*i*/ prev, nukt_p);
}
- /* for the special conjuction of Cons+0x0d4d+0x0d31 or Cons+0x0d4d+0x0d30 of Malayalam */
+ /* for the special conjuction of Cons+0x0d4d+0x0d31 or Cons+0x0d4d+0x0d30 of Malayalam */
if ((baseConsonant - 2 >= 0) &&
(chars[baseConsonant - 1] == 0x0d4d) &&
((chars[baseConsonant] == 0x0d31) ||
(chars[baseConsonant - 2] <= 0x0d39))) {
swapChars (&output, -1, -3);
- if (mpreFixups) {
+ if (mpreFixups) {
if (mpreFixups->fFixupCount > 0) {
- mpreFixups->fFixupCount--;
+ mpreFixups->fFixupCount--;
}
- }
+ }
}
if ((class_table->scriptFlags & SF_MATRAS_AFTER_BASE) != 0) {
gboolean is_for_0C48 = FALSE;
- if (output.fOutChars != NULL) { /*for 0x0C48 of Telugu*/
+ if (output.fOutChars != NULL) { /*for 0x0C48 of Telugu*/
int t;
for (t = prev; t < syllable; t++) {
- if (chars[t] == 0x0C48) {
+ if (chars[t] == 0x0C48) {
writeMabove(&output);
writeMbelow(&output);
writeMpost(&output);
- is_for_0C48 = TRUE;
- break;
+ is_for_0C48 = TRUE;
+ break;
}
}
}
writeChar(&output, chars[i], /*i*/ prev, blwf_p);
}
- break;
- }
+ break;
+ }
- default:
- break;
- }
+ default:
+ break;
+ }
- prev = syllable;
+ prev = syllable;
}
if (outMPreFixups) {
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 1 - exit state (or sign to the right of the syllable) */
{-1, -1, -1, -1, 3, 4, 5, 6, 16, 17, 1, -1}, /* 2 - Base consonant */
{-1, -1, -1, -1, -1, 4, -1, -1, 16, -1, -1, -1}, /* 3 - First ZWNJ before a register shifter
- It can only be followed by a shifter or a vowel */
+ It can only be followed by a shifter or a vowel */
{-1, -1, -1, -1, 15, -1, -1, 6, 16, 17, 1, 14}, /* 4 - First register shifter */
{-1, -1, -1, -1, -1, -1, -1, -1, 20, -1, 1, -1}, /* 5 - Robat */
{-1, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1}, /* 6 - First Coeng */
static void
maybe_add_GSUB_feature (PangoOTRuleset *ruleset,
- PangoOTInfo *info,
- guint script_index,
- PangoOTTag tag,
- gulong property_bit)
+ PangoOTInfo *info,
+ guint script_index,
+ PangoOTTag tag,
+ gulong property_bit)
{
guint feature_index;
/* 0xffff == default language system */
if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GSUB,
- tag, script_index, 0xffff, &feature_index))
+ tag, script_index, 0xffff, &feature_index))
pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GSUB, feature_index,
- property_bit);
+ property_bit);
}
static void
maybe_add_GPOS_feature (PangoOTRuleset *ruleset,
- PangoOTInfo *info,
- guint script_index,
- PangoOTTag tag,
- gulong property_bit)
+ PangoOTInfo *info,
+ guint script_index,
+ PangoOTTag tag,
+ gulong property_bit)
{
guint feature_index;
/* 0xffff == default language system */
if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GPOS,
- tag, script_index, 0xffff, &feature_index))
+ tag, script_index, 0xffff, &feature_index))
pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index,
- property_bit);
+ property_bit);
}
ruleset = pango_ot_ruleset_new (info);
if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
- khmer_tag, &script_index))
- {
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','f'), pref);
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','f'), blwf);
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','f'), abvf);
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','f'), pstf);
-
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','s'), pres);
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','s'), blws);
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','s'), abvs);
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','s'), psts);
- maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('c','l','i','g'), clig);
- }
+ khmer_tag, &script_index))
+ {
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','f'), pref);
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','f'), blwf);
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','f'), abvf);
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','f'), pstf);
+
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','s'), pres);
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','s'), blws);
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','s'), abvs);
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','s'), psts);
+ maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('c','l','i','g'), clig);
+ }
if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
- khmer_tag, &script_index))
- {
- maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('d','i','s','t'), dist);
- maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','m'), blwm);
- maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','m'), abvm);
- maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','k','m','k'), mkmk);
- }
+ khmer_tag, &script_index))
+ {
+ maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('d','i','s','t'), dist);
+ maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','m'), blwm);
+ maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','m'), abvm);
+ maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','k','m','k'), mkmk);
+ }
g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
- (GDestroyNotify)g_object_unref);
+ (GDestroyNotify)g_object_unref);
}
return ruleset;
static void
khmer_engine_shape (PangoEngineShape *engine,
- PangoFont *font,
- const char *text,
- int length,
- const PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+ PangoFont *font,
+ const char *text,
+ int length,
+ const PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
{
PangoFcFont *fc_font;
FT_Face face;
syllable = find_syllable (wcs, cursor, n_chars);
for (i = cursor; i < syllable; i += 1)
- {
- charClass = get_char_class (wcs[i]);
-
- /* if a split vowel, write the pre part. In Khmer the pre part
- * is the same for all split vowels, same glyph as pre vowel C_VOWEL_E
- */
- if (charClass & CF_SPLIT_VOWEL)
- {
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_VOWEL_E), pref_p, p - text);
- break; /* there can be only one vowel */
- }
-
- /* if a vowel with pos before write it out */
- if (charClass & CF_POS_BEFORE)
- {
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pref_p, p - text);
- break; /* there can be only one vowel */
- }
-
- /* look for coeng + ro and remember position
- * works because coeng + ro is always in front of a vowel (if there is a vowel)
- * and because CC_CONSONANT2 is enough to identify it, as it is the only consonant
- * with this flag
- */
- if ((charClass & CF_COENG) && (i + 1 < syllable) &&
- ((get_char_class (wcs[i + 1]) & CF_CLASS_MASK) == CC_CONSONANT2))
- {
- coengRo = i;
- }
- }
+ {
+ charClass = get_char_class (wcs[i]);
+
+ /* if a split vowel, write the pre part. In Khmer the pre part
+ * is the same for all split vowels, same glyph as pre vowel C_VOWEL_E
+ */
+ if (charClass & CF_SPLIT_VOWEL)
+ {
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_VOWEL_E), pref_p, p - text);
+ break; /* there can be only one vowel */
+ }
+
+ /* if a vowel with pos before write it out */
+ if (charClass & CF_POS_BEFORE)
+ {
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pref_p, p - text);
+ break; /* there can be only one vowel */
+ }
+
+ /* look for coeng + ro and remember position
+ * works because coeng + ro is always in front of a vowel (if there is a vowel)
+ * and because CC_CONSONANT2 is enough to identify it, as it is the only consonant
+ * with this flag
+ */
+ if ((charClass & CF_COENG) && (i + 1 < syllable) &&
+ ((get_char_class (wcs[i + 1]) & CF_CLASS_MASK) == CC_CONSONANT2))
+ {
+ coengRo = i;
+ }
+ }
/* write coeng + ro if found */
if (coengRo > -1)
- {
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_COENG), pref_p, p - text);
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_RO), pref_p, p - text);
- }
+ {
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_COENG), pref_p, p - text);
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_RO), pref_p, p - text);
+ }
/* shall we add a dotted circle?
* If in the position in which the base should be (first char in the string) there is
* then write a dotted circle
*/
if (get_char_class (wcs[cursor]) & CF_DOTTED_CIRCLE)
- {
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_DOTTED_CIRCLE), default_p, p - text);
- }
+ {
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_DOTTED_CIRCLE), default_p, p - text);
+ }
/* copy what is left to the output, skipping before vowels and
* coeng Ro if they are present
*/
for (i = cursor; i < syllable; i += 1)
- {
- charClass = get_char_class (wcs[i]);
-
- /* skip a before vowel, it was already processed */
- if (charClass & CF_POS_BEFORE)
- {
- p = g_utf8_next_char (p);
- continue;
- }
-
- /* skip coeng + ro, it was already processed */
- if (i == coengRo)
- {
- p = g_utf8_next_char (p);
- i += 1;
- p = g_utf8_next_char (p);
- continue;
- }
-
- switch (charClass & CF_POS_MASK)
- {
- case CF_POS_ABOVE :
+ {
+ charClass = get_char_class (wcs[i]);
+
+ /* skip a before vowel, it was already processed */
+ if (charClass & CF_POS_BEFORE)
+ {
+ p = g_utf8_next_char (p);
+ continue;
+ }
+
+ /* skip coeng + ro, it was already processed */
+ if (i == coengRo)
+ {
+ p = g_utf8_next_char (p);
+ i += 1;
+ p = g_utf8_next_char (p);
+ continue;
+ }
+
+ switch (charClass & CF_POS_MASK)
+ {
+ case CF_POS_ABOVE :
pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), abvf_p, p - text);
break;
- case CF_POS_AFTER :
+ case CF_POS_AFTER :
pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pstf_p, p - text);
break;
- case CF_POS_BELOW :
+ case CF_POS_BELOW :
pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
break;
- default:
- /* assign the correct flags to a coeng consonant
- * Consonants of type 3 are taged as Post forms and those type 1 as below forms
- */
+ default:
+ /* assign the correct flags to a coeng consonant
+ * Consonants of type 3 are taged as Post forms and those type 1 as below forms
+ */
if ((charClass & CF_COENG) && i + 1 < syllable)
{
if ((get_char_class (wcs[i + 1]) & CF_CLASS_MASK) == CC_CONSONANT3)
}
}
- /* if a shifter is followed by an above vowel change the shifter to below form,
- * an above vowel can have two possible positions i + 1 or i + 3
- * (position i+1 corresponds to unicode 3, position i+3 to Unicode 4)
- * and there is an extra rule for C_VOWEL_AA + C_SIGN_NIKAHIT also for two
- * different positions, right after the shifter or after a vowel (Unicode 4)
- */
- if ((charClass & CF_SHIFTER) && (i + 1 < syllable))
- {
- if (get_char_class (wcs[i + 1]) & CF_ABOVE_VOWEL)
- {
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
- break;
- }
- if (i + 2 < syllable &&
- (wcs[i + 1] == C_VOWEL_AA) &&
- (wcs[i + 2] == C_SIGN_NIKAHIT) )
- {
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
- break;
- }
- if (i + 3 < syllable && (get_char_class (wcs[i + 3]) & CF_ABOVE_VOWEL) )
- {
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
- break;
- }
- if (i + 4 < syllable &&
- (wcs[i + 3] == C_VOWEL_AA) &&
- (wcs[i + 4] == C_SIGN_NIKAHIT) )
- {
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
- break;
- }
-
- }
-
- /* default - any other characters */
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), default_p, p - text);
- break;
- } /* switch */
- p = g_utf8_next_char (p);
- } /* for */
+ /* if a shifter is followed by an above vowel change the shifter to below form,
+ * an above vowel can have two possible positions i + 1 or i + 3
+ * (position i+1 corresponds to unicode 3, position i+3 to Unicode 4)
+ * and there is an extra rule for C_VOWEL_AA + C_SIGN_NIKAHIT also for two
+ * different positions, right after the shifter or after a vowel (Unicode 4)
+ */
+ if ((charClass & CF_SHIFTER) && (i + 1 < syllable))
+ {
+ if (get_char_class (wcs[i + 1]) & CF_ABOVE_VOWEL)
+ {
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
+ break;
+ }
+ if (i + 2 < syllable &&
+ (wcs[i + 1] == C_VOWEL_AA) &&
+ (wcs[i + 2] == C_SIGN_NIKAHIT) )
+ {
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
+ break;
+ }
+ if (i + 3 < syllable && (get_char_class (wcs[i + 3]) & CF_ABOVE_VOWEL) )
+ {
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
+ break;
+ }
+ if (i + 4 < syllable &&
+ (wcs[i + 3] == C_VOWEL_AA) &&
+ (wcs[i + 4] == C_SIGN_NIKAHIT) )
+ {
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
+ break;
+ }
+
+ }
+
+ /* default - any other characters */
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), default_p, p - text);
+ break;
+ } /* switch */
+ p = g_utf8_next_char (p);
+ } /* for */
cursor = syllable; /* move the pointer to the start of next syllable */
} /* while */
}
PANGO_ENGINE_SHAPE_DEFINE_TYPE (KhmerEngineFc, khmer_engine_fc,
- khmer_engine_fc_class_init, NULL)
+ khmer_engine_fc_class_init, NULL)
void
void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
- int *n_engines)
+ int *n_engines)
{
*engines = script_engines;
*n_engines = G_N_ELEMENTS (script_engines);
while (1)
{
if (pos == 0 && direction < 0)
- return none;
+ return none;
pos += direction;
if (pos >= length)
- return none;
+ return none;
if (string[pos] < 0x0700 ||
string[pos] >= 0x074F)
return none;
}
else
- j = syriac[string[pos] - 0x0700];
+ j = syriac[string[pos] - 0x0700];
if (!direction || j != transparent)
- return j;
+ return j;
}
}
/* R1 */
if (current == transparent)
- {
+ {
properties[i] |= isolated_p;
continue;
- }
+ }
/* R2 */
if (string[i] == 0x0722 ||
string[i] == 0x071F)
- if (previous == causing ||
- previous == right)
- if (!(next == causing ||
+ if (previous == causing ||
+ previous == right)
+ if (!(next == causing ||
next == right ||
next == dual))
- {
- properties[i] |= isolated_p;
- continue;
- }
+ {
+ properties[i] |= isolated_p;
+ continue;
+ }
/* R3 */
if (string[i] == 0x0710)
- if (previous == causing ||
- previous == right)
- if (!(string[i - 1] == 0x0715 ||
+ if (previous == causing ||
+ previous == right)
+ if (!(string[i - 1] == 0x0715 ||
string[i - 1] == 0x0716 ||
string[i - 1] == 0x072A))
- {
- properties[i] |= final2_p;
- continue;
- }
+ {
+ properties[i] |= final2_p;
+ continue;
+ }
/* R4 */
if (string[i] == 0x0710)
- if (previous == causing ||
- previous == right)
- if (string[i - 1] == 0x0715 ||
- string[i - 1] == 0x0716 ||
- string[i - 1] == 0x072A)
- {
- properties[i] |= final3_p;
- continue;
- }
+ if (previous == causing ||
+ previous == right)
+ if (string[i - 1] == 0x0715 ||
+ string[i - 1] == 0x0716 ||
+ string[i - 1] == 0x072A)
+ {
+ properties[i] |= final3_p;
+ continue;
+ }
/* R5 */
if (previous == causing ||
previous == right ||
previous == dual)
- if (current == right)
+ if (current == right)
{
properties[i] |= final_p;
continue;
/* R6 */
if (previous == causing ||
- previous == right ||
+ previous == right ||
previous == dual)
- if (current == dual)
- if (!(next == causing ||
+ if (current == dual)
+ if (!(next == causing ||
next == right ||
next == dual ))
{
- properties[i] |= final_p;
- continue;
+ properties[i] |= final_p;
+ continue;
}
/* R7 */
if (previous == causing ||
- previous == left ||
- previous == dual)
- if (current == dual)
- if (next == causing ||
- next == right ||
- next == dual )
+ previous == left ||
+ previous == dual)
+ if (current == dual)
+ if (next == causing ||
+ next == right ||
+ next == dual )
{
- properties[i] |= medial_p;
- continue;
+ properties[i] |= medial_p;
+ continue;
}
/* R8 */
if (string[i] == 0x0710)
- if (previous == causing ||
- previous == right)
- if (next == causing ||
- next == right ||
- next == dual)
- {
- properties[i] |= medial2_p;
- continue;
- }
+ if (previous == causing ||
+ previous == right)
+ if (next == causing ||
+ next == right ||
+ next == dual)
+ {
+ properties[i] |= medial2_p;
+ continue;
+ }
/* R9 */
if (current == left)
- if (next == causing ||
- next == right ||
- next == dual)
+ if (next == causing ||
+ next == right ||
+ next == dual)
{
properties[i] |= initial_p;
continue;
if (!(previous == causing ||
previous == left ||
previous == dual ))
- if (current == dual)
- if (next == causing ||
- next == right ||
- next == dual)
+ if (current == dual)
+ if (next == causing ||
+ next == right ||
+ next == dual)
{
- properties[i] |= initial_p;
- continue;
+ properties[i] |= initial_p;
+ continue;
}
/* R11 */
const gshort thai_char_type[256] = {
/* 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, A, B, C, D, E, F */
+ 8, 9, A, B, C, D, E, F */
- /* CL1 */
+ /* CL1 */
/*00*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
+ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
/*10*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
+ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- /* Lao zone: [U+0E80..U+0EDF] */
+ /* Lao zone: [U+0E80..U+0EDF] */
/*20*/ _ND, _NC, _NC, _ND, _NC, _ND, _ND, _NC,
- _NC, _ND, _NC, _ND, _ND, _NC, _ND, _ND,
+ _NC, _ND, _NC, _ND, _ND, _NC, _ND, _ND,
/*30*/ _ND, _ND, _ND, _ND, _NC, _NC, _NC, _NC,
- _ND, _NC, _NC, _UC, _NC, _UC, _NC, _UC,
+ _ND, _NC, _NC, _UC, _NC, _UC, _NC, _UC,
/*40*/ _ND, _NC, _UC, _NC, _ND, _NC, _ND, _NC,
- _ND, _ND, _NC, _NC, _ND, _NC, _NC, _ND,
+ _ND, _ND, _NC, _NC, _ND, _NC, _NC, _ND,
/*50*/ _ND, _AV, _ND, _AM, _AV, _AV, _AV, _AV,
- _BV, _BV, _ND, _AV, _BD, _NC, _ND, _ND,
+ _BV, _BV, _ND, _AV, _BD, _NC, _ND, _ND,
/*60*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _AD,
- _TN, _TN, _TN, _TN, _AD, _AD, _ND, _ND,
+ _TN, _TN, _TN, _TN, _AD, _AD, _ND, _ND,
/*70*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- _ND, _ND, _ND, _ND, _NC, _NC, _ND, _ND,
+ _ND, _ND, _ND, _ND, _NC, _NC, _ND, _ND,
- /* CL2 */
+ /* CL2 */
/*80*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
+ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
/*90*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
+ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- /* Thai zone: [U+0E00..U+0E5F] */
+ /* Thai zone: [U+0E00..U+0E5F] */
/*A0*/ _ND, _NC, _NC, _NC, _NC, _NC, _NC, _NC,
- _NC, _NC, _NC, _NC, _NC, _SC, _BC, _BC,
+ _NC, _NC, _NC, _NC, _NC, _SC, _BC, _BC,
/*B0*/ _SC, _NC, _NC, _NC, _NC, _NC, _NC, _NC,
- _NC, _NC, _NC, _UC, _NC, _UC, _NC, _UC,
+ _NC, _NC, _NC, _UC, _NC, _UC, _NC, _UC,
/*C0*/ _NC, _NC, _NC, _NC, _ND, _NC, _ND, _NC,
- _NC, _NC, _NC, _NC, _UC, _NC, _NC, _ND,
+ _NC, _NC, _NC, _NC, _UC, _NC, _NC, _ND,
/*D0*/ _ND, _AV, _ND, _AM, _AV, _AV, _AV, _AV,
- _BV, _BV, _BD, _ND, _ND, _ND, _ND, _ND,
+ _BV, _BV, _BD, _ND, _ND, _ND, _ND, _ND,
/*E0*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _AD,
- _TN, _TN, _TN, _TN, _AD, _AD, _AD, _ND,
+ _TN, _TN, _TN, _TN, _AD, _AD, _AD, _ND,
/*F0*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
- _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
+ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND,
};
const gshort thai_TAC_char_class[256] = {
/* 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, A, B, C, D, E, F */
+ 8, 9, A, B, C, D, E, F */
- /* CL1 */
+ /* CL1 */
/*00*/ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
- CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
+ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
/*10*/ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
- CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
+ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
- /* Lao zone: [U+0E80..U+0EDF] */
+ /* Lao zone: [U+0E80..U+0EDF] */
/*20*/ NON,CONS,CONS, NON,CONS, NON, NON,CONS,
- CONS, NON,CONS, NON, NON,CONS, NON, NON,
+ CONS, NON,CONS, NON, NON,CONS, NON, NON,
/*30*/ NON, NON, NON, NON,CONS,CONS,CONS,CONS,
- NON,CONS,CONS,CONS,CONS,CONS,CONS,CONS,
+ NON,CONS,CONS,CONS,CONS,CONS,CONS,CONS,
/*40*/ NON,CONS,CONS,CONS, NON,CONS, NON,CONS,
- NON, NON,CONS,CONS, NON,CONS,CONS, NON,
+ NON, NON,CONS,CONS, NON,CONS,CONS, NON,
/*50*/ FV1, AV2, FV1, AM, AV1, AV3, AV2, AV3,
- BV1, BV2, NON, AV2,BCON, FV3, NON, NON,
+ BV1, BV2, NON, AV2,BCON, FV3, NON, NON,
/*60*/ LV, LV, LV, LV, LV, NON, NON, NON,
- TONE,TONE,TONE,TONE, AD1, AD4, NON, NON,
+ TONE,TONE,TONE,TONE, AD1, AD4, NON, NON,
/*70*/ NON, NON, NON, NON, NON, NON, NON, NON,
- NON, NON, NON, NON,CONS,CONS, NON,CTRL,
+ NON, NON, NON, NON,CONS,CONS, NON,CTRL,
- /* CL2 */
+ /* CL2 */
/*80*/ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
- CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
+ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
/*90*/ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
- CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
+ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,
- /* Thai zone: [U+0E00..U+0E5F] */
+ /* Thai zone: [U+0E00..U+0E5F] */
/*A0*/ NON,CONS,CONS,CONS,CONS,CONS,CONS,CONS,
- CONS,CONS,CONS,CONS,CONS,CONS,CONS,CONS,
+ CONS,CONS,CONS,CONS,CONS,CONS,CONS,CONS,
/*B0*/ CONS,CONS,CONS,CONS,CONS,CONS,CONS,CONS,
- CONS,CONS,CONS,CONS,CONS,CONS,CONS,CONS,
+ CONS,CONS,CONS,CONS,CONS,CONS,CONS,CONS,
/*C0*/ CONS,CONS,CONS,CONS, FV3,CONS, FV3,CONS,
- CONS,CONS,CONS,CONS,CONS,CONS,CONS, NON,
+ CONS,CONS,CONS,CONS,CONS,CONS,CONS, NON,
/*D0*/ FV1, AV2, FV1, AM, AV1, AV3, AV2, AV3,
- BV1, BV2, BD, NON, NON, NON, NON, NON,
+ BV1, BV2, BD, NON, NON, NON, NON, NON,
/*E0*/ LV, LV, LV, LV, LV, FV2, NON, AD2,
- TONE,TONE,TONE,TONE, AD1, AD4, AD3, NON,
+ TONE,TONE,TONE,TONE, AD1, AD4, AD3, NON,
/*F0*/ NON, NON, NON, NON, NON, NON, NON, NON,
- NON, NON, NON, NON, NON, NON, NON,CTRL,
+ NON, NON, NON, NON, NON, NON, NON,CTRL,
};
const gchar thai_TAC_compose_input[20][20] = {
/*CTRL NON CONS LV FV1 FV2 FV3 AM BV1 BV2
* BD TONE AD1 AD2 AD3 AD4 AV1 AV2 AV3 BCON*/
/*CTRL*/{'X','A','A','A','A','A','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*NON */{'X','A','A','A','S','S','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*CONS*/{'X','A','A','A','A','S','A','C','C','C',
- 'C','C','C','C','C','C','C','C','C','C'},
+ 'C','C','C','C','C','C','C','C','C','C'},
/*LV */{'X','S','A','S','S','S','S','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*FV1 */{'X','A','A','A','A','S','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*FV2 */{'X','A','A','A','A','S','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*FV3 */{'X','A','A','A','S','A','S','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*AM */{'X','A','A','A','S','S','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*BV1 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','C','C','R','R','C','R','R','R','R'},
+ 'R','C','C','R','R','C','R','R','R','R'},
/*BV2 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','C','R','R','R','R','R','R','R','R'},
+ 'R','C','R','R','R','R','R','R','R','R'},
/*BD */{'X','A','A','A','S','S','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*TONE*/{'X','A','A','A','A','A','A','C','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*AD1 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*AD2 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*AD3 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','R','R','R','R','R','R','R','R','R'},
+ 'R','R','R','R','R','R','R','R','R','R'},
/*AD4 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','C','R','R','R','R','R','R','R','R'},
+ 'R','C','R','R','R','R','R','R','R','R'},
/*AV1 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','C','C','R','R','C','R','R','R','R'},
+ 'R','C','C','R','R','C','R','R','R','R'},
/*AV2 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','C','R','R','R','R','R','R','R','R'},
+ 'R','C','R','R','R','R','R','R','R','R'},
/*AV3 */{'X','A','A','A','S','S','A','R','R','R',
- 'R','C','R','C','R','R','R','R','R','R'},
+ 'R','C','R','C','R','R','R','R','R','R'},
/*BCON*/{'X','A','A','A','A','S','A','C','C','C',
- 'R','C','R','R','R','C','C','C','C','R'},
+ 'R','C','R','R','R','C','C','C','C','R'},
};
/**/ 0, 0, 0, 0, 0, 0, 0, 0,
0x0020, 0x0e81, 0x0e82, 0, 0x0e84, 0, 0, 0x0e87,
0x0e88, 0, 0x0e8a, 0, 0, 0x0e8d, 0, 0,
- 0, 0, 0, 0, 0x0e94, 0x0e95, 0x0e96, 0x0e97,
+ 0, 0, 0, 0, 0x0e94, 0x0e95, 0x0e96, 0x0e97,
/**/ 0, 0x0e99, 0x0e9a, 0x0e9b, 0x0e9c, 0x0e9d, 0x0e9e, 0x0e9f,
/**/ 0, 0x0ea1, 0x0ea2, 0x0ea3, 0, 0x0ea5, 0, 0x0ea7,
/**/ 0, 0, 0x0eaa, 0x0eab, 0, 0x0ead, 0x0eae, 0x0eaf,
for (c = 0; c < 0x80; c++)
{
if (glyph_map[c])
- {
+ {
if (!pango_fc_font_has_char (fc_font, glyph_map[c]))
- return 0;
- }
+ return 0;
+ }
}
return 1;
}
/* detect font set by determining availibility of OT ruleset & glyphs */
if (thai_ot_get_ruleset (font))
- font_info->font_set = THAI_FONT_TIS;
+ font_info->font_set = THAI_FONT_TIS;
else if (contain_glyphs(font, tis620_2))
- font_info->font_set = THAI_FONT_TIS_WIN;
+ font_info->font_set = THAI_FONT_TIS_WIN;
else if (contain_glyphs(font, tis620_1))
- font_info->font_set = THAI_FONT_TIS_MAC;
+ font_info->font_set = THAI_FONT_TIS_MAC;
else
- font_info->font_set = THAI_FONT_TIS;
+ font_info->font_set = THAI_FONT_TIS;
g_object_set_qdata_full (G_OBJECT (font), info_id, font_info, (GDestroyNotify)g_free);
}
static void
thai_engine_break (PangoEngineLang *engine,
- const char *text,
- int len,
- PangoAnalysis *analysis,
- PangoLogAttr *attrs,
- int attrs_len)
+ const char *text,
+ int len,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs,
+ int attrs_len)
{
thchar_t *tis_text;
/* find line break positions */
brk_n = th_brk (tis_text, brk_pnts, brk_len);
for (i = 0; i < brk_n; i++)
- {
- attrs[brk_pnts[i]].is_line_break = TRUE;
- attrs[brk_pnts[i]].is_word_start = TRUE;
- attrs[brk_pnts[i]].is_word_end = TRUE;
- }
+ {
+ attrs[brk_pnts[i]].is_line_break = TRUE;
+ attrs[brk_pnts[i]].is_word_start = TRUE;
+ attrs[brk_pnts[i]].is_word_end = TRUE;
+ }
g_free (brk_pnts);
g_free (tis_text);
}
PANGO_ENGINE_LANG_DEFINE_TYPE (ThaiEngineLang, thai_engine_lang,
- thai_engine_lang_class_init, NULL);
+ thai_engine_lang_class_init, NULL);
void
PANGO_MODULE_ENTRY(init) (GTypeModule *module)
static gint
maybe_add_gpos_feature (PangoOTRuleset *ruleset,
- PangoOTInfo *info,
+ PangoOTInfo *info,
guint script_index,
PangoOTTag feature_tag,
gulong property_bit)
static GQuark ruleset_quark = 0;
if (!ruleset_quark)
- ruleset_quark = g_quark_from_string ("thai-ot-ruleset");
+ ruleset_quark = g_quark_from_string ("thai-ot-ruleset");
ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark);
if (!ruleset)
- {
- PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i');
- guint script_index;
- gint n = 0;
+ {
+ PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i');
+ guint script_index;
+ gint n = 0;
- ruleset = pango_ot_ruleset_new (info);
+ ruleset = pango_ot_ruleset_new (info);
- if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
- thai_tag, &script_index))
+ if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
+ thai_tag, &script_index))
{
n += maybe_add_gsub_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('c','c','m','p'),
+ FT_MAKE_TAG ('c','c','m','p'),
0xFFFF);
n += maybe_add_gsub_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('l','i','g','a'),
+ FT_MAKE_TAG ('l','i','g','a'),
0xFFFF);
}
- if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
- thai_tag, &script_index))
+ if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
+ thai_tag, &script_index))
{
n += maybe_add_gpos_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('k','e','r','n'),
+ FT_MAKE_TAG ('k','e','r','n'),
0xFFFF);
n += maybe_add_gpos_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('m','a','r','k'),
+ FT_MAKE_TAG ('m','a','r','k'),
0xFFFF);
n += maybe_add_gpos_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('m','k','m','k'),
+ FT_MAKE_TAG ('m','k','m','k'),
0xFFFF);
}
if (n > 0)
- g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
+ g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
(GDestroyNotify)g_object_unref);
else
{
g_object_unref (ruleset);
ruleset = NULL;
}
- }
+ }
}
pango_fc_font_unlock_face (fc_font);
static GQuark ruleset_quark = 0;
if (!ruleset_quark)
- ruleset_quark = g_quark_from_string ("lao-ot-ruleset");
+ ruleset_quark = g_quark_from_string ("lao-ot-ruleset");
ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark);
if (!ruleset)
- {
- PangoOTTag thai_tag = FT_MAKE_TAG ('l', 'a', 'o', ' ');
- guint script_index;
- gint n = 0;
+ {
+ PangoOTTag thai_tag = FT_MAKE_TAG ('l', 'a', 'o', ' ');
+ guint script_index;
+ gint n = 0;
- ruleset = pango_ot_ruleset_new (info);
+ ruleset = pango_ot_ruleset_new (info);
- if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
- thai_tag, &script_index))
+ if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
+ thai_tag, &script_index))
{
n += maybe_add_gsub_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('c','c','m','p'),
+ FT_MAKE_TAG ('c','c','m','p'),
0xFFFF);
n += maybe_add_gsub_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('l','i','g','a'),
+ FT_MAKE_TAG ('l','i','g','a'),
0xFFFF);
}
- if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
- thai_tag, &script_index))
+ if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
+ thai_tag, &script_index))
{
n += maybe_add_gpos_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('k','e','r','n'),
+ FT_MAKE_TAG ('k','e','r','n'),
0xFFFF);
n += maybe_add_gpos_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('m','a','r','k'),
+ FT_MAKE_TAG ('m','a','r','k'),
0xFFFF);
n += maybe_add_gpos_feature (ruleset, info, script_index,
- FT_MAKE_TAG ('m','k','m','k'),
+ FT_MAKE_TAG ('m','k','m','k'),
0xFFFF);
}
if (n > 0)
- g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
+ g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
(GDestroyNotify)g_object_unref);
else
{
g_object_unref (ruleset);
ruleset = NULL;
}
- }
+ }
}
pango_fc_font_unlock_face (fc_font);
void
thai_ot_shape (PangoFont *font,
- PangoGlyphString *glyphs)
+ PangoGlyphString *glyphs)
{
PangoOTRuleset *th_ruleset;
PangoOTRuleset *lo_ruleset;
/* prepare ot buffer */
buffer = pango_ot_buffer_new (PANGO_FC_FONT (font));
for (i = 0; i < glyphs->num_glyphs; i++)
- {
- pango_ot_buffer_add_glyph (buffer,
+ {
+ pango_ot_buffer_add_glyph (buffer,
glyphs->glyphs[i].glyph,
0,
glyphs->log_clusters[i]);
- }
+ }
if (th_ruleset != NULL)
- {
- pango_ot_ruleset_substitute (th_ruleset, buffer);
- pango_ot_ruleset_position (th_ruleset, buffer);
- }
+ {
+ pango_ot_ruleset_substitute (th_ruleset, buffer);
+ pango_ot_ruleset_position (th_ruleset, buffer);
+ }
if (lo_ruleset != NULL)
- {
- pango_ot_ruleset_substitute (lo_ruleset, buffer);
- pango_ot_ruleset_position (lo_ruleset, buffer);
- }
+ {
+ pango_ot_ruleset_substitute (lo_ruleset, buffer);
+ pango_ot_ruleset_position (lo_ruleset, buffer);
+ }
pango_ot_buffer_output (buffer, glyphs);
pango_ot_buffer_destroy (buffer);
void
thai_ot_shape (PangoFont *font,
- PangoGlyphString *glyphs);
+ PangoGlyphString *glyphs);
#endif /* __THAI_OT_H__ */
switch (num_chrs)
{
case 1:
- if (is_char_type (cluster[0],
- BelowVowel|BelowDiac|AboveVowel|AboveDiac|Tone|SaraAm))
+ if (is_char_type (cluster[0],
+ BelowVowel|BelowDiac|AboveVowel|AboveDiac|Tone|SaraAm))
{
gint n;
glyph_lists[0] = get_null_base_glyph (font_info);
n = glyph_lists[0] ? 1 : 0;
- glyph_lists[n++] =
+ glyph_lists[n++] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
return n;
- }
+ }
else
{
glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
- return 1;
- }
- break;
+ return 1;
+ }
+ break;
case 2:
- if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) &&
- is_char_type (cluster[1], SaraAm))
+ if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) &&
+ is_char_type (cluster[1], SaraAm))
{
- glyph_lists[0] =
+ glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
- glyph_lists[1] = thai_make_glyph_tis (font_info, shaping_table->AmComp[0]);
- glyph_lists[2] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]);
- return 3;
- }
+ glyph_lists[1] = thai_make_glyph_tis (font_info, shaping_table->AmComp[0]);
+ glyph_lists[2] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]);
+ return 3;
+ }
else if (is_char_type (cluster[0], UpTailCons) &&
- is_char_type (cluster[1], SaraAm))
+ is_char_type (cluster[1], SaraAm))
{
glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
- glyph_lists[1] = thai_make_glyph_tis (font_info,
+ glyph_lists[1] = thai_make_glyph_tis (font_info,
shiftleft_tone_ad (shaping_table->AmComp[0], shaping_table));
- glyph_lists[2] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]);
- return 3;
- }
+ glyph_lists[2] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]);
+ return 3;
+ }
else if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) &&
- is_char_type (cluster[1], AboveVowel))
+ is_char_type (cluster[1], AboveVowel))
{
glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
glyph_lists[1] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[1]));
return 2;
- }
+ }
else if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) &&
- is_char_type (cluster[1], AboveDiac|Tone))
+ is_char_type (cluster[1], AboveDiac|Tone))
{
glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
return 2;
}
else if (is_char_type (cluster[0], UpTailCons) &&
- is_char_type (cluster[1], AboveVowel))
+ is_char_type (cluster[1], AboveVowel))
{
glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
glyph_lists[1] = thai_make_glyph_tis (font_info,
shiftleft_av (ucs2tis (cluster[1]), shaping_table));
return 2;
- }
+ }
else if (is_char_type (cluster[0], UpTailCons) &&
- is_char_type (cluster[1], AboveDiac|Tone))
+ is_char_type (cluster[1], AboveDiac|Tone))
{
glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
return 2;
}
else if (is_char_type (cluster[0], NoTailCons|UpTailCons) &&
- is_char_type (cluster[1], BelowVowel|BelowDiac))
+ is_char_type (cluster[1], BelowVowel|BelowDiac))
{
glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
glyph_lists[1] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[1]));
return 2;
- }
+ }
else if (is_char_type (cluster[0], BotTailCons) &&
is_char_type (cluster[1], BelowVowel|BelowDiac))
{
return 2;
}
else if (is_char_type (cluster[0], SpltTailCons) &&
- is_char_type (cluster[1], BelowVowel|BelowDiac))
+ is_char_type (cluster[1], BelowVowel|BelowDiac))
{
glyph_lists[0] = thai_make_glyph_tis (font_info,
tailcutcons (ucs2tis (cluster[0]), shaping_table));
thai_make_glyph_tis (font_info, ucs2tis (cluster[1]));
return n;
}
- break;
+ break;
case 3:
- if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) &&
- is_char_type (cluster[1], Tone) &&
- is_char_type (cluster[2], SaraAm))
+ if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) &&
+ is_char_type (cluster[1], Tone) &&
+ is_char_type (cluster[2], SaraAm))
{
- glyph_lists[0] =
+ glyph_lists[0] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[0]));
- glyph_lists[1] = thai_make_glyph_tis (font_info, shaping_table->AmComp[0]);
- glyph_lists[2] =
+ glyph_lists[1] = thai_make_glyph_tis (font_info, shaping_table->AmComp[0]);
+ glyph_lists[2] =
thai_make_glyph_tis (font_info, ucs2tis (cluster[1]));
- glyph_lists[3] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]);
- return 4;
- }
+ glyph_lists[3] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]);
+ return 4;
+ }
else if (is_char_type (cluster[0], UpTailCons) &&
is_char_type (cluster[1], Tone) &&
is_char_type (cluster[2], SaraAm))
break;
default: /* e.g. Lao cluster with below cons + upper/lower vowel + tone */
- {
- gint i;
- for (i = 0; i < num_chrs; i++)
- glyph_lists[i] = thai_make_glyph_tis (font_info, ucs2tis (cluster[i]));
- return num_chrs;
- }
+ {
+ gint i;
+ for (i = 0; i < num_chrs; i++)
+ glyph_lists[i] = thai_make_glyph_tis (font_info, ucs2tis (cluster[i]));
+ return num_chrs;
+ }
}
return 0;
switch (pango_script_for_unichar (cluster[0]))
{
case PANGO_SCRIPT_THAI:
- switch (font_info->font_set)
- {
- default:
- case THAI_FONT_NONE:
- for (i=0; i < num_chrs; i++)
- glyph_lists[i] = thai_make_unknown_glyph (font_info, cluster[i]);
- return num_chrs;
-
- case THAI_FONT_TIS:
+ switch (font_info->font_set)
+ {
+ default:
+ case THAI_FONT_NONE:
+ for (i=0; i < num_chrs; i++)
+ glyph_lists[i] = thai_make_unknown_glyph (font_info, cluster[i]);
+ return num_chrs;
+
+ case THAI_FONT_TIS:
/* TIS620-0 + Wtt2.0 Extension
*/
- return get_adjusted_glyphs_list (font_info, cluster,
+ return get_adjusted_glyphs_list (font_info, cluster,
num_chrs, glyph_lists, &tis620_0_shape_table);
- case THAI_FONT_TIS_MAC:
+ case THAI_FONT_TIS_MAC:
/* MacIntosh Extension
*/
- return get_adjusted_glyphs_list (font_info, cluster,
+ return get_adjusted_glyphs_list (font_info, cluster,
num_chrs, glyph_lists, &Mac_shape_table);
- case THAI_FONT_TIS_WIN:
+ case THAI_FONT_TIS_WIN:
/* Microsoft Extension
*/
- return get_adjusted_glyphs_list (font_info, cluster,
+ return get_adjusted_glyphs_list (font_info, cluster,
num_chrs, glyph_lists, &Win_shape_table);
- }
+ }
break;
case PANGO_SCRIPT_LAO:
- return get_adjusted_glyphs_list (font_info, cluster,
- num_chrs, glyph_lists, &Lao_shape_table);
+ return get_adjusted_glyphs_list (font_info, cluster,
+ num_chrs, glyph_lists, &Lao_shape_table);
default:
- for (i=0; i < num_chrs; i++)
+ for (i=0; i < num_chrs; i++)
glyph_lists[i] = thai_make_unknown_glyph (font_info, cluster[i]);
- return num_chrs;
+ return num_chrs;
}
return 0; /* Quiet GCC */
case 'S':
case 'R':
case 'X':
- return FALSE;
+ return FALSE;
case 'C':
- return TRUE;
+ return TRUE;
}
g_assert_not_reached ();
current = g_utf8_get_char (p);
cur_script = pango_script_for_unichar (current);
if (cluster_script == PANGO_SCRIPT_INVALID_CODE)
- cluster_script = cur_script;
+ cluster_script = cur_script;
if (cur_script != cluster_script ||
- (n_chars > 0 &&
- !is_wtt_composible (cluster[n_chars - 1], current)))
- break;
+ (n_chars > 0 &&
+ !is_wtt_composible (cluster[n_chars - 1], current)))
+ break;
cluster[n_chars++] = current;
}
void
thai_engine_shape (PangoEngineShape *engine,
PangoFont *font,
- const char *text,
- gint length,
- const PangoAnalysis *analysis,
- PangoGlyphString *glyphs);
+ const char *text,
+ gint length,
+ const PangoAnalysis *analysis,
+ PangoGlyphString *glyphs);
#endif /* __THAI_SHAPER_H__ */
static void
maybe_add_GSUB_feature (PangoOTRuleset *ruleset,
- PangoOTInfo *info,
- guint script_index,
- PangoOTTag tag,
- gulong property_bit)
+ PangoOTInfo *info,
+ guint script_index,
+ PangoOTTag tag,
+ gulong property_bit)
{
guint feature_index;
/* 0xffff == default language system */
if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GSUB,
- tag, script_index, 0xffff, &feature_index))
+ tag, script_index, 0xffff, &feature_index))
pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GSUB, feature_index,
- property_bit);
+ property_bit);
}
static void
maybe_add_GPOS_feature (PangoOTRuleset *ruleset,
- PangoOTInfo *info,
- guint script_index,
- PangoOTTag tag,
- gulong property_bit)
+ PangoOTInfo *info,
+ guint script_index,
+ PangoOTTag tag,
+ gulong property_bit)
{
guint feature_index;
/* 0xffff == default language system */
if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GPOS,
- tag, script_index, 0xffff, &feature_index))
+ tag, script_index, 0xffff, &feature_index))
pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index,
- property_bit);
+ property_bit);
}
/* Rules found in the Open type font features */
ruleset = pango_ot_ruleset_new (info);
if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
- tibetan_tag, &script_index))
+ tibetan_tag, &script_index))
{
maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','f'), pref);
maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','f'), blwf);
}
if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
- tibetan_tag, &script_index))
+ tibetan_tag, &script_index))
{
maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('d','i','s','t'), dist);
maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','m'), blwm);
}
g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
- (GDestroyNotify)g_object_unref);
+ (GDestroyNotify)g_object_unref);
}
return ruleset;
static void
tibetan_engine_shape (PangoEngineShape *engine,
- PangoFont *font,
- const char *text,
- int length,
- const PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+ PangoFont *font,
+ const char *text,
+ int length,
+ const PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
{
PangoFcFont *fc_font;
FT_Face face;
switch (charClass & CF_POS_MASK)
{
case CF_POS_ABOVE :
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), abvf_p, p - text);
- break;
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), abvf_p, p - text);
+ break;
case CF_POS_AFTER :
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pstf_p, p - text);
- break;
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pstf_p, p - text);
+ break;
case CF_POS_BELOW :
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
- break;
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);
+ break;
default:
- /* default - any other characters */
- pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), default_p, p - text);
- break;
+ /* default - any other characters */
+ pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), default_p, p - text);
+ break;
} /* switch */
}
}
PANGO_ENGINE_SHAPE_DEFINE_TYPE (TibetanEngineFc, tibetan_engine_fc,
- tibetan_engine_fc_class_init, NULL)
+ tibetan_engine_fc_class_init, NULL)
void
void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
- int *n_engines)
+ int *n_engines)
{
*engines = script_engines;
*n_engines = G_N_ELEMENTS (script_engines);
title = get_options_string ();
if (view->display)
- {
+ {
gpointer window = NULL;
gpointer state = NULL;
view->destroy_window (instance, window);
}
else
- {
+ {
int fd;
FILE *stream;
const gchar *display_argv[5] = {"display", "-title", "%s", "-"};
static gpointer
pangocairo_view_create_surface (gpointer instance,
- int width,
+ int width,
int height)
{
CairoViewer *c = (CairoViewer *) instance;
cairo_set_source_rgba (cr, 1.0, 0.5, 0.0, 0.5);
iter = pango_layout_get_iter (layout);
do
- {
+ {
PangoLayoutLine *line = pango_layout_iter_get_line (iter);
double width = (double)logical.width / PANGO_SCALE;
cairo_close_path (cr);
cairo_fill (cr);
cairo_restore (cr);
- }
+ }
while (pango_layout_iter_next_line (iter));
pango_layout_iter_free (iter);
cairo_restore (cr);
if (supports_matrix)
pango_matrix_rotate (&matrix, opt_rotate);
else
- g_printerr ("The backend does not support rotated text\n");
+ g_printerr ("The backend does not support rotated text\n");
}
pango_context_set_base_gravity (context, opt_gravity);
{
opt_viewer = *viewers;
if (!opt_viewer)
- fail ("No viewer backend found");
+ fail ("No viewer backend found");
}
/* if wrap mode is set then width must be set */
for (i = 0; i < n_families; i++)
{
if (0 == g_strcasecmp(pango_font_family_get_name(families[i]), family_name))
- {
+ {
family = families[i];
break;
}
extern const PangoViewer x_viewer;
void x_view_init (gpointer instance,
- const PangoViewer *klass);
+ const PangoViewer *klass);
gpointer x_view_create (const PangoViewer *klass);
void x_view_destroy (gpointer instance);
gpointer x_view_create_surface (gpointer instance,
- int width,
+ int width,
int height);
void x_view_destroy_surface (gpointer instance,
};
#define BREAK_TYPE_SAFE(btype) \
- (btype < G_N_ELEMENTS(line_break_indexes) ? btype : G_UNICODE_BREAK_UNKNOWN)
+ (btype < G_N_ELEMENTS(line_break_indexes) ? btype : G_UNICODE_BREAK_UNKNOWN)
#define BREAK_INDEX(btype) \
- (line_break_indexes[(btype)])
+ (line_break_indexes[(btype)])
#define BREAK_ROW(before_type) \
- (line_break_rows[BREAK_INDEX (before_type)])
+ (line_break_rows[BREAK_INDEX (before_type)])
#define BREAK_OP(before_type, after_type) \
- (BREAK_ROW (before_type)[BREAK_INDEX (after_type)])
+ (BREAK_ROW (before_type)[BREAK_INDEX (after_type)])
#define IN_BREAK_TABLE(btype) \
- (btype < G_N_ELEMENTS(line_break_indexes) && BREAK_INDEX(btype) < INDEX_END_OF_TABLE)
+ (btype < G_N_ELEMENTS(line_break_indexes) && BREAK_INDEX(btype) < INDEX_END_OF_TABLE)
*/
#define VIRAMA_SCRIPT(wc) ((wc) >= 0x0901 && (wc) <= 0x17FF)
#define VIRAMA(wc) ((wc) == 0x094D || \
- (wc) == 0x09CD || \
- (wc) == 0x0A4D || \
- (wc) == 0x0ACD || \
- (wc) == 0x0B4D || \
- (wc) == 0x0BCD || \
- (wc) == 0x0C4D || \
- (wc) == 0x0CCD || \
- (wc) == 0x0D4D || \
- (wc) == 0x0DCA || \
- (wc) == 0x0E3A || \
- (wc) == 0x0F84 || \
- (wc) == 0x1039 || \
- (wc) == 0x17D2)
+ (wc) == 0x09CD || \
+ (wc) == 0x0A4D || \
+ (wc) == 0x0ACD || \
+ (wc) == 0x0B4D || \
+ (wc) == 0x0BCD || \
+ (wc) == 0x0C4D || \
+ (wc) == 0x0CCD || \
+ (wc) == 0x0D4D || \
+ (wc) == 0x0DCA || \
+ (wc) == 0x0E3A || \
+ (wc) == 0x0F84 || \
+ (wc) == 0x1039 || \
+ (wc) == 0x17D2)
/* Types of Japanese characters */
#define JAPANESE(wc) ((wc) >= 0x2F00 && (wc) <= 0x30FF)
#define KANJI(wc) ((wc) >= 0x2F00 && (wc) <= 0x2FDF)
**/
void
pango_default_break (const gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoLogAttr *attrs,
- int attrs_len)
+ gint length,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs,
+ int attrs_len)
{
/* The rationale for all this is in section 5.15 of the Unicode 3.0 book,
* the line breaking stuff is also in TR14 on unicode.org
break_type = next_break_type;
if (almost_done)
- {
- /*
- * If we have already reached the end of @text g_utf8_next_char()
- * may not increment next
- */
- next_wc = 0;
+ {
+ /*
+ * If we have already reached the end of @text g_utf8_next_char()
+ * may not increment next
+ */
+ next_wc = 0;
next_break_type = G_UNICODE_BREAK_UNKNOWN;
done = TRUE;
- }
+ }
else
- {
- next = g_utf8_next_char (next);
+ {
+ next = g_utf8_next_char (next);
if ((length >= 0 && next >= text + length) || *next == '\0')
- {
- /* This is how we fill in the last element (end position) of the
- * attr array - assume there's a paragraph separators off the end
+ {
+ /* This is how we fill in the last element (end position) of the
+ * attr array - assume there's a paragraph separators off the end
* of @text.
- */
+ */
next_wc = PARAGRAPH_SEPARATOR;
almost_done = TRUE;
- }
- else
+ }
+ else
next_wc = g_utf8_get_char (next);
next_break_type = g_unichar_break_type (next_wc);
- next_break_type = BREAK_TYPE_SAFE (next_break_type);
- }
+ next_break_type = BREAK_TYPE_SAFE (next_break_type);
+ }
type = g_unichar_type (wc);
jamo = JAMO_TYPE (break_type);
/* Determine wheter this forms a Hangul syllable with prev. */
if (jamo == NO_JAMO)
- makes_hangul_syllable = FALSE;
+ makes_hangul_syllable = FALSE;
else
{
JamoType prev_end = HangulJamoProps[prev_jamo].end ;
/* ---- Cursor position breaks (Grapheme breaks) ---- */
if (wc == '\n')
- {
- /* Break before line feed unless prev char is a CR */
-
- if (prev_wc != '\r')
- attrs[i].is_cursor_position = TRUE;
- else
- attrs[i].is_cursor_position = FALSE;
- }
+ {
+ /* Break before line feed unless prev char is a CR */
+
+ if (prev_wc != '\r')
+ attrs[i].is_cursor_position = TRUE;
+ else
+ attrs[i].is_cursor_position = FALSE;
+ }
else if (i == 0 ||
- prev_type == G_UNICODE_CONTROL ||
- prev_type == G_UNICODE_FORMAT)
- {
- /* Break at first position (must be special cased, or if the
- * first char is say a combining mark there won't be a
- * cursor position at the start, which seems wrong to me
- * ???? - maybe it makes sense though, who knows)
- */
- /* break after all format or control characters */
- attrs[i].is_cursor_position = TRUE;
- }
+ prev_type == G_UNICODE_CONTROL ||
+ prev_type == G_UNICODE_FORMAT)
+ {
+ /* Break at first position (must be special cased, or if the
+ * first char is say a combining mark there won't be a
+ * cursor position at the start, which seems wrong to me
+ * ???? - maybe it makes sense though, who knows)
+ */
+ /* break after all format or control characters */
+ attrs[i].is_cursor_position = TRUE;
+ }
else
- {
- switch (type)
- {
- case G_UNICODE_CONTROL:
- case G_UNICODE_FORMAT:
- /* Break before all format or control characters */
- attrs[i].is_cursor_position = TRUE;
- break;
-
- case G_UNICODE_COMBINING_MARK:
- case G_UNICODE_ENCLOSING_MARK:
- case G_UNICODE_NON_SPACING_MARK:
- /* Unicode spec includes "Combining marks plus Tibetan
- * subjoined characters" as joining chars, but lists the
- * Tibetan subjoined characters as combining marks, and
- * g_unichar_type() returns NON_SPACING_MARK for the Tibetan
- * subjoined characters. So who knows, beats me.
- */
-
- /* It's a joining character, break only if preceded by
- * control or format; we already handled the case where
- * it was preceded earlier, so here we know it wasn't,
- * don't break
- */
- attrs[i].is_cursor_position = FALSE;
- break;
-
- case G_UNICODE_LOWERCASE_LETTER:
- case G_UNICODE_MODIFIER_LETTER:
- case G_UNICODE_OTHER_LETTER:
- case G_UNICODE_TITLECASE_LETTER:
- case G_UNICODE_UPPERCASE_LETTER:
+ {
+ switch (type)
+ {
+ case G_UNICODE_CONTROL:
+ case G_UNICODE_FORMAT:
+ /* Break before all format or control characters */
+ attrs[i].is_cursor_position = TRUE;
+ break;
+
+ case G_UNICODE_COMBINING_MARK:
+ case G_UNICODE_ENCLOSING_MARK:
+ case G_UNICODE_NON_SPACING_MARK:
+ /* Unicode spec includes "Combining marks plus Tibetan
+ * subjoined characters" as joining chars, but lists the
+ * Tibetan subjoined characters as combining marks, and
+ * g_unichar_type() returns NON_SPACING_MARK for the Tibetan
+ * subjoined characters. So who knows, beats me.
+ */
+
+ /* It's a joining character, break only if preceded by
+ * control or format; we already handled the case where
+ * it was preceded earlier, so here we know it wasn't,
+ * don't break
+ */
+ attrs[i].is_cursor_position = FALSE;
+ break;
+
+ case G_UNICODE_LOWERCASE_LETTER:
+ case G_UNICODE_MODIFIER_LETTER:
+ case G_UNICODE_OTHER_LETTER:
+ case G_UNICODE_TITLECASE_LETTER:
+ case G_UNICODE_UPPERCASE_LETTER:
if (makes_hangul_syllable)
- attrs[i].is_cursor_position = FALSE;
- else
- {
- /* Handle non-Hangul-syllable non-combining chars */
+ attrs[i].is_cursor_position = FALSE;
+ else
+ {
+ /* Handle non-Hangul-syllable non-combining chars */
- /* Break before Jamo if they are in a broken sequence or
- * next to non-Jamo; break if preceded by Jamo; don't
+ /* Break before Jamo if they are in a broken sequence or
+ * next to non-Jamo; break if preceded by Jamo; don't
* break if a letter is preceded by a virama; break in
* all other cases. No need to check whether we are or are
- * preceded by Jamo explicitly, since a Jamo is not
- * a virama, we just break in all cases where we
- * aren't a or preceded by a virama. Don't fool with
+ * preceded by Jamo explicitly, since a Jamo is not
+ * a virama, we just break in all cases where we
+ * aren't a or preceded by a virama. Don't fool with
* viramas if we aren't part of a script that uses them.
- */
-
- if (VIRAMA_SCRIPT (wc))
- {
- /* Check whether we're preceded by a virama; this
- * could use some optimization.
- */
- if (VIRAMA (prev_wc))
- attrs[i].is_cursor_position = FALSE;
- else
- attrs[i].is_cursor_position = TRUE;
- }
- else
- {
- attrs[i].is_cursor_position = TRUE;
- }
- }
- break;
-
- default:
- /* Some weirdo char, just break here, why not */
- attrs[i].is_cursor_position = TRUE;
- break;
- }
- }
+ */
+
+ if (VIRAMA_SCRIPT (wc))
+ {
+ /* Check whether we're preceded by a virama; this
+ * could use some optimization.
+ */
+ if (VIRAMA (prev_wc))
+ attrs[i].is_cursor_position = FALSE;
+ else
+ attrs[i].is_cursor_position = TRUE;
+ }
+ else
+ {
+ attrs[i].is_cursor_position = TRUE;
+ }
+ }
+ break;
+
+ default:
+ /* Some weirdo char, just break here, why not */
+ attrs[i].is_cursor_position = TRUE;
+ break;
+ }
+ }
/* If this is a grapheme boundary, we have to decide if backspace
* deletes a character or the whole grapheme cluster */
if (attrs[i].is_cursor_position)
- attrs[i].backspace_deletes_character = BACKSPACE_DELETES_CHARACTER (base_character);
+ attrs[i].backspace_deletes_character = BACKSPACE_DELETES_CHARACTER (base_character);
else
- attrs[i].backspace_deletes_character = FALSE;
+ attrs[i].backspace_deletes_character = FALSE;
/* ---- Line breaking ---- */
attrs[i].is_mandatory_break = FALSE;
if (attrs[i].is_cursor_position) /* If it's not a grapheme boundary,
- * it's not a line break either
- */
- {
+ * it's not a line break either
+ */
+ {
/* space followed by a combining mark is handled
* specially; (rule 7a from TR 14)
*/
next_break_type == G_UNICODE_BREAK_COMBINING_MARK)
break_type = G_UNICODE_BREAK_IDEOGRAPHIC;
- /* Unicode doesn't specify char wrap; we wrap around all chars
- * except where a line break is prohibited, which means we
- * effectively break everywhere except inside runs of spaces.
- */
- attrs[i].is_char_break = TRUE;
+ /* Unicode doesn't specify char wrap; we wrap around all chars
+ * except where a line break is prohibited, which means we
+ * effectively break everywhere except inside runs of spaces.
+ */
+ attrs[i].is_char_break = TRUE;
/* Make any necessary replacements first */
- switch (prev_break_type)
- {
+ switch (prev_break_type)
+ {
case G_UNICODE_BREAK_HANGUL_L_JAMO:
case G_UNICODE_BREAK_HANGUL_V_JAMO:
case G_UNICODE_BREAK_HANGUL_T_JAMO:
prev_break_type = G_UNICODE_BREAK_IDEOGRAPHIC;
break;
- case G_UNICODE_BREAK_AMBIGUOUS:
+ case G_UNICODE_BREAK_AMBIGUOUS:
/* FIXME
- * we need to resolve the East Asian width
- * to decide what to do here
+ * we need to resolve the East Asian width
+ * to decide what to do here
*/
- case G_UNICODE_BREAK_COMPLEX_CONTEXT:
+ case G_UNICODE_BREAK_COMPLEX_CONTEXT:
/* FIXME
- * language engines should handle this case...
+ * language engines should handle this case...
*/
- case G_UNICODE_BREAK_UNKNOWN:
+ case G_UNICODE_BREAK_UNKNOWN:
/* convert unknown, complex, ambiguous to ALPHABETIC
*/
prev_break_type = G_UNICODE_BREAK_ALPHABETIC;
;
}
- switch (prev_break_type)
- {
- case G_UNICODE_BREAK_MANDATORY:
- case G_UNICODE_BREAK_LINE_FEED:
- case G_UNICODE_BREAK_NEXT_LINE:
- attrs[i].is_line_break = TRUE;
- attrs[i].is_mandatory_break = TRUE;
- break;
-
- case G_UNICODE_BREAK_CARRIAGE_RETURN:
- if (wc != '\n')
- {
- attrs[i].is_line_break = TRUE;
- attrs[i].is_mandatory_break = TRUE;
- }
- break;
-
- case G_UNICODE_BREAK_CONTINGENT:
- /* can break after 0xFFFC by default, though we might want
- * to eventually have a PangoLayout setting or
- * PangoAttribute that disables this, if for some
- * application breaking after objects is not desired.
- */
- break_op = BREAK_ALLOWED;
- break;
-
- case G_UNICODE_BREAK_SURROGATE:
+ switch (prev_break_type)
+ {
+ case G_UNICODE_BREAK_MANDATORY:
+ case G_UNICODE_BREAK_LINE_FEED:
+ case G_UNICODE_BREAK_NEXT_LINE:
+ attrs[i].is_line_break = TRUE;
+ attrs[i].is_mandatory_break = TRUE;
+ break;
+
+ case G_UNICODE_BREAK_CARRIAGE_RETURN:
+ if (wc != '\n')
+ {
+ attrs[i].is_line_break = TRUE;
+ attrs[i].is_mandatory_break = TRUE;
+ }
+ break;
+
+ case G_UNICODE_BREAK_CONTINGENT:
+ /* can break after 0xFFFC by default, though we might want
+ * to eventually have a PangoLayout setting or
+ * PangoAttribute that disables this, if for some
+ * application breaking after objects is not desired.
+ */
+ break_op = BREAK_ALLOWED;
+ break;
+
+ case G_UNICODE_BREAK_SURROGATE:
g_assert_not_reached ();
- break;
-
- default:
- g_assert (IN_BREAK_TABLE (prev_break_type));
-
- /* Note that our table assumes that combining marks
- * are only applied to alphabetic characters;
- * tech report 14 explains how to remove this assumption
- * from the code, if anyone ever cares, but it shouldn't
- * be a problem. Also this issue sort of goes
- * away since we only look for breaks on grapheme
- * boundaries.
- */
-
- switch (break_type)
- {
- case G_UNICODE_BREAK_MANDATORY:
- case G_UNICODE_BREAK_LINE_FEED:
- case G_UNICODE_BREAK_CARRIAGE_RETURN:
- case G_UNICODE_BREAK_NEXT_LINE:
- case G_UNICODE_BREAK_SPACE:
- /* These types all "pile up" at the end of lines and
- * get elided.
- */
- break_op = BREAK_PROHIBITED;
- break;
-
- case G_UNICODE_BREAK_CONTINGENT:
- /* break before 0xFFFC by default, eventually
- * make this configurable?
- */
- break_op = BREAK_ALLOWED;
- break;
-
- case G_UNICODE_BREAK_SURROGATE:
+ break;
+
+ default:
+ g_assert (IN_BREAK_TABLE (prev_break_type));
+
+ /* Note that our table assumes that combining marks
+ * are only applied to alphabetic characters;
+ * tech report 14 explains how to remove this assumption
+ * from the code, if anyone ever cares, but it shouldn't
+ * be a problem. Also this issue sort of goes
+ * away since we only look for breaks on grapheme
+ * boundaries.
+ */
+
+ switch (break_type)
+ {
+ case G_UNICODE_BREAK_MANDATORY:
+ case G_UNICODE_BREAK_LINE_FEED:
+ case G_UNICODE_BREAK_CARRIAGE_RETURN:
+ case G_UNICODE_BREAK_NEXT_LINE:
+ case G_UNICODE_BREAK_SPACE:
+ /* These types all "pile up" at the end of lines and
+ * get elided.
+ */
+ break_op = BREAK_PROHIBITED;
+ break;
+
+ case G_UNICODE_BREAK_CONTINGENT:
+ /* break before 0xFFFC by default, eventually
+ * make this configurable?
+ */
+ break_op = BREAK_ALLOWED;
+ break;
+
+ case G_UNICODE_BREAK_SURROGATE:
g_assert_not_reached ();
- break;
+ break;
/* Hangul additions are from Unicode 4.1 UAX#14 */
case G_UNICODE_BREAK_HANGUL_L_JAMO:
case G_UNICODE_BREAK_HANGUL_T_JAMO:
case G_UNICODE_BREAK_HANGUL_LV_SYLLABLE:
case G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE:
- /* treat Jamo as IDEOGRAPHIC from now
+ /* treat Jamo as IDEOGRAPHIC from now
*/
- break_type = G_UNICODE_BREAK_IDEOGRAPHIC;
+ break_type = G_UNICODE_BREAK_IDEOGRAPHIC;
if (makes_hangul_syllable)
break_op = BREAK_IF_SPACES;
* language engines should handle this case...
*/
case G_UNICODE_BREAK_UNKNOWN:
- /* treat unknown, complex, and ambiguous like ALPHABETIC
+ /* treat unknown, complex, and ambiguous like ALPHABETIC
* for now
- */
- break_op = BREAK_OP (prev_break_type, G_UNICODE_BREAK_ALPHABETIC);
- break;
+ */
+ break_op = BREAK_OP (prev_break_type, G_UNICODE_BREAK_ALPHABETIC);
+ break;
default:
g_assert (IN_BREAK_TABLE (break_type));
- break_op = BREAK_OP (prev_break_type, break_type);
- break;
- }
- break;
- }
-
- if (break_op != BREAK_ALREADY_HANDLED)
- {
- switch (break_op)
- {
- case BREAK_PROHIBITED:
- /* can't break here */
- attrs[i].is_char_break = FALSE;
- break;
-
- case BREAK_IF_SPACES:
- /* break if prev char was space */
- if (prev_was_break_space)
- attrs[i].is_line_break = TRUE;
- break;
-
- case BREAK_ALLOWED:
- attrs[i].is_line_break = TRUE;
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
- }
- }
+ break_op = BREAK_OP (prev_break_type, break_type);
+ break;
+ }
+ break;
+ }
+
+ if (break_op != BREAK_ALREADY_HANDLED)
+ {
+ switch (break_op)
+ {
+ case BREAK_PROHIBITED:
+ /* can't break here */
+ attrs[i].is_char_break = FALSE;
+ break;
+
+ case BREAK_IF_SPACES:
+ /* break if prev char was space */
+ if (prev_was_break_space)
+ attrs[i].is_line_break = TRUE;
+ break;
+
+ case BREAK_ALLOWED:
+ attrs[i].is_line_break = TRUE;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+ }
if (break_type != G_UNICODE_BREAK_SPACE)
- {
- prev_break_type = break_type;
- prev_was_break_space = FALSE;
+ {
+ prev_break_type = break_type;
+ prev_was_break_space = FALSE;
prev_jamo = jamo;
- }
+ }
else
- prev_was_break_space = TRUE;
+ prev_was_break_space = TRUE;
/* ---- Word breaks ---- */
attrs[i].is_word_end = FALSE;
if (current_word_type != WordNone)
- {
- /* Check for a word end */
- switch (type)
- {
- case G_UNICODE_COMBINING_MARK:
- case G_UNICODE_ENCLOSING_MARK:
- case G_UNICODE_NON_SPACING_MARK:
+ {
+ /* Check for a word end */
+ switch (type)
+ {
+ case G_UNICODE_COMBINING_MARK:
+ case G_UNICODE_ENCLOSING_MARK:
+ case G_UNICODE_NON_SPACING_MARK:
case G_UNICODE_FORMAT:
- /* nothing, we just eat these up as part of the word */
- break;
-
- case G_UNICODE_LOWERCASE_LETTER:
- case G_UNICODE_MODIFIER_LETTER:
- case G_UNICODE_OTHER_LETTER:
- case G_UNICODE_TITLECASE_LETTER:
- case G_UNICODE_UPPERCASE_LETTER:
- if (current_word_type == WordLetters)
- {
- /* Japanese special cases for ending the word */
- if (JAPANESE (last_word_letter) ||
- JAPANESE (wc))
- {
- if ((HIRAGANA (last_word_letter) &&
- !HIRAGANA (wc)) ||
- (KATAKANA (last_word_letter) &&
- !(KATAKANA (wc) || HIRAGANA (wc))) ||
- (KANJI (last_word_letter) &&
- !(HIRAGANA (wc) || KANJI (wc))) ||
- (JAPANESE (last_word_letter) &&
- !JAPANESE (wc)) ||
- (!JAPANESE (last_word_letter) &&
- JAPANESE (wc)))
- attrs[i].is_word_end = TRUE;
- }
- }
- else
- {
- /* end the number word, start the letter word */
- attrs[i].is_word_end = TRUE;
- attrs[i].is_word_start = TRUE;
- current_word_type = WordLetters;
- }
-
- last_word_letter = wc;
- break;
-
- case G_UNICODE_DECIMAL_NUMBER:
- case G_UNICODE_LETTER_NUMBER:
- case G_UNICODE_OTHER_NUMBER:
- if (current_word_type != WordNumbers)
- {
- attrs[i].is_word_end = TRUE;
- attrs[i].is_word_start = TRUE;
- current_word_type = WordNumbers;
- }
-
- last_word_letter = wc;
- break;
-
- default:
- /* Punctuation, control/format chars, etc. all end a word. */
- attrs[i].is_word_end = TRUE;
+ /* nothing, we just eat these up as part of the word */
+ break;
+
+ case G_UNICODE_LOWERCASE_LETTER:
+ case G_UNICODE_MODIFIER_LETTER:
+ case G_UNICODE_OTHER_LETTER:
+ case G_UNICODE_TITLECASE_LETTER:
+ case G_UNICODE_UPPERCASE_LETTER:
+ if (current_word_type == WordLetters)
+ {
+ /* Japanese special cases for ending the word */
+ if (JAPANESE (last_word_letter) ||
+ JAPANESE (wc))
+ {
+ if ((HIRAGANA (last_word_letter) &&
+ !HIRAGANA (wc)) ||
+ (KATAKANA (last_word_letter) &&
+ !(KATAKANA (wc) || HIRAGANA (wc))) ||
+ (KANJI (last_word_letter) &&
+ !(HIRAGANA (wc) || KANJI (wc))) ||
+ (JAPANESE (last_word_letter) &&
+ !JAPANESE (wc)) ||
+ (!JAPANESE (last_word_letter) &&
+ JAPANESE (wc)))
+ attrs[i].is_word_end = TRUE;
+ }
+ }
+ else
+ {
+ /* end the number word, start the letter word */
+ attrs[i].is_word_end = TRUE;
+ attrs[i].is_word_start = TRUE;
+ current_word_type = WordLetters;
+ }
+
+ last_word_letter = wc;
+ break;
+
+ case G_UNICODE_DECIMAL_NUMBER:
+ case G_UNICODE_LETTER_NUMBER:
+ case G_UNICODE_OTHER_NUMBER:
+ if (current_word_type != WordNumbers)
+ {
+ attrs[i].is_word_end = TRUE;
+ attrs[i].is_word_start = TRUE;
+ current_word_type = WordNumbers;
+ }
+
+ last_word_letter = wc;
+ break;
+
+ default:
+ /* Punctuation, control/format chars, etc. all end a word. */
+ attrs[i].is_word_end = TRUE;
current_word_type = WordNone;
- break;
- }
- }
+ break;
+ }
+ }
else
- {
- /* Check for a word start */
- switch (type)
- {
- case G_UNICODE_LOWERCASE_LETTER:
- case G_UNICODE_MODIFIER_LETTER:
- case G_UNICODE_OTHER_LETTER:
- case G_UNICODE_TITLECASE_LETTER:
- case G_UNICODE_UPPERCASE_LETTER:
- current_word_type = WordLetters;
- last_word_letter = wc;
- attrs[i].is_word_start = TRUE;
- break;
-
- case G_UNICODE_DECIMAL_NUMBER:
- case G_UNICODE_LETTER_NUMBER:
- case G_UNICODE_OTHER_NUMBER:
- current_word_type = WordNumbers;
- last_word_letter = wc;
- attrs[i].is_word_start = TRUE;
- break;
-
- default:
- /* No word here */
- break;
- }
- }
+ {
+ /* Check for a word start */
+ switch (type)
+ {
+ case G_UNICODE_LOWERCASE_LETTER:
+ case G_UNICODE_MODIFIER_LETTER:
+ case G_UNICODE_OTHER_LETTER:
+ case G_UNICODE_TITLECASE_LETTER:
+ case G_UNICODE_UPPERCASE_LETTER:
+ current_word_type = WordLetters;
+ last_word_letter = wc;
+ attrs[i].is_word_start = TRUE;
+ break;
+
+ case G_UNICODE_DECIMAL_NUMBER:
+ case G_UNICODE_LETTER_NUMBER:
+ case G_UNICODE_OTHER_NUMBER:
+ current_word_type = WordNumbers;
+ last_word_letter = wc;
+ attrs[i].is_word_start = TRUE;
+ break;
+
+ default:
+ /* No word here */
+ break;
+ }
+ }
/* ---- Sentence breaks ---- */
*/
#define MAYBE_START_NEW_SENTENCE \
- switch (type) \
- { \
- case G_UNICODE_LINE_SEPARATOR: \
- case G_UNICODE_PARAGRAPH_SEPARATOR: \
- case G_UNICODE_CONTROL: \
- case G_UNICODE_FORMAT: \
- case G_UNICODE_SPACE_SEPARATOR: \
- sentence_state = STATE_SENTENCE_OUTSIDE; \
- break; \
- \
- default: \
- sentence_state = STATE_SENTENCE_BODY; \
- attrs[i].is_sentence_start = TRUE; \
- break; \
- }
+ switch (type) \
+ { \
+ case G_UNICODE_LINE_SEPARATOR: \
+ case G_UNICODE_PARAGRAPH_SEPARATOR: \
+ case G_UNICODE_CONTROL: \
+ case G_UNICODE_FORMAT: \
+ case G_UNICODE_SPACE_SEPARATOR: \
+ sentence_state = STATE_SENTENCE_OUTSIDE; \
+ break; \
+ \
+ default: \
+ sentence_state = STATE_SENTENCE_BODY; \
+ attrs[i].is_sentence_start = TRUE; \
+ break; \
+ }
/* No sentence break at the start of the text */
* followed by newline
*/
switch (prev_type)
- {
- case G_UNICODE_LINE_SEPARATOR:
- case G_UNICODE_PARAGRAPH_SEPARATOR:
- case G_UNICODE_CONTROL:
- case G_UNICODE_FORMAT:
- if (wc == '\r')
- {
- if (next_wc != '\n')
- attrs[i].is_sentence_boundary = TRUE;
- }
- else
- attrs[i].is_sentence_boundary = TRUE;
- break;
-
- default:
- break;
- }
+ {
+ case G_UNICODE_LINE_SEPARATOR:
+ case G_UNICODE_PARAGRAPH_SEPARATOR:
+ case G_UNICODE_CONTROL:
+ case G_UNICODE_FORMAT:
+ if (wc == '\r')
+ {
+ if (next_wc != '\n')
+ attrs[i].is_sentence_boundary = TRUE;
+ }
+ else
+ attrs[i].is_sentence_boundary = TRUE;
+ break;
+
+ default:
+ break;
+ }
/* break before para/line separators except newline following
* carriage return
*/
switch (type)
- {
- case G_UNICODE_LINE_SEPARATOR:
- case G_UNICODE_PARAGRAPH_SEPARATOR:
- case G_UNICODE_CONTROL:
- case G_UNICODE_FORMAT:
- if (wc == '\n')
- {
- if (prev_wc != '\r')
- attrs[i].is_sentence_boundary = TRUE;
- }
- else
- attrs[i].is_sentence_boundary = TRUE;
- break;
-
- default:
- break;
- }
+ {
+ case G_UNICODE_LINE_SEPARATOR:
+ case G_UNICODE_PARAGRAPH_SEPARATOR:
+ case G_UNICODE_CONTROL:
+ case G_UNICODE_FORMAT:
+ if (wc == '\n')
+ {
+ if (prev_wc != '\r')
+ attrs[i].is_sentence_boundary = TRUE;
+ }
+ else
+ attrs[i].is_sentence_boundary = TRUE;
+ break;
+
+ default:
+ break;
+ }
switch (sentence_state)
- {
- case STATE_SENTENCE_OUTSIDE:
- /* Start sentence if we have non-whitespace/format/control */
- switch (type)
- {
- case G_UNICODE_LINE_SEPARATOR:
- case G_UNICODE_PARAGRAPH_SEPARATOR:
- case G_UNICODE_CONTROL:
- case G_UNICODE_FORMAT:
- case G_UNICODE_SPACE_SEPARATOR:
- break;
-
- default:
- attrs[i].is_sentence_start = TRUE;
- sentence_state = STATE_SENTENCE_BODY;
- break;
- }
- break;
-
- case STATE_SENTENCE_BODY:
- /* If we already broke here due to separators, end the sentence. */
- if (attrs[i].is_sentence_boundary)
- {
- attrs[i].is_sentence_end = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
- }
- else
- {
- if (wc == '.')
- sentence_state = STATE_SENTENCE_DOT;
- else if (wc == '?' || wc == '!')
- sentence_state = STATE_SENTENCE_TERM;
- }
- break;
-
- case STATE_SENTENCE_TERM:
- /* End sentence on anything but close punctuation and some
- * loosely-specified OTHER_PUNCTUATION such as period,
- * comma, etc.; follow Unicode rules for breaks
- */
- switch (type)
- {
- case G_UNICODE_OTHER_PUNCTUATION:
- case G_UNICODE_CLOSE_PUNCTUATION:
- if (type == G_UNICODE_CLOSE_PUNCTUATION ||
- wc == '.' ||
- wc == ',' ||
- wc == '?' ||
- wc == '!')
- sentence_state = STATE_SENTENCE_POST_TERM_CLOSE;
- else
- {
- attrs[i].is_sentence_end = TRUE;
- attrs[i].is_sentence_boundary = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
- }
- break;
-
- case G_UNICODE_SPACE_SEPARATOR:
- attrs[i].is_sentence_end = TRUE;
- sentence_state = STATE_SENTENCE_POST_TERM_SPACE;
- break;
-
- case G_UNICODE_LINE_SEPARATOR:
- case G_UNICODE_PARAGRAPH_SEPARATOR:
- attrs[i].is_sentence_end = TRUE;
- sentence_state = STATE_SENTENCE_POST_TERM_SEP;
- break;
-
- default:
- attrs[i].is_sentence_end = TRUE;
- attrs[i].is_sentence_boundary = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
-
- break;
- }
- break;
-
- case STATE_SENTENCE_POST_TERM_CLOSE:
- /* End sentence on anything besides more punctuation; follow
- * rules for breaks
- */
- switch (type)
- {
- case G_UNICODE_OTHER_PUNCTUATION:
- case G_UNICODE_CLOSE_PUNCTUATION:
- if (type == G_UNICODE_CLOSE_PUNCTUATION ||
- wc == '.' ||
- wc == ',' ||
- wc == '?' ||
- wc == '!')
- /* continue in this state */
- ;
- else
- {
- attrs[i].is_sentence_end = TRUE;
- attrs[i].is_sentence_boundary = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
- }
- break;
-
- case G_UNICODE_SPACE_SEPARATOR:
- attrs[i].is_sentence_end = TRUE;
- sentence_state = STATE_SENTENCE_POST_TERM_SPACE;
- break;
-
- case G_UNICODE_LINE_SEPARATOR:
- case G_UNICODE_PARAGRAPH_SEPARATOR:
- attrs[i].is_sentence_end = TRUE;
- /* undo the unconditional break-at-all-line/para-separators
- * from above; I'm not sure this is what the Unicode spec
- * intends, but it seems right - we get to include
- * a single line/para separator in the sentence according
- * to their rules
- */
- attrs[i].is_sentence_boundary = FALSE;
- sentence_state = STATE_SENTENCE_POST_TERM_SEP;
- break;
-
- default:
- attrs[i].is_sentence_end = TRUE;
- attrs[i].is_sentence_boundary = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
-
- break;
- }
- break;
-
- case STATE_SENTENCE_POST_TERM_SPACE:
-
- /* Sentence is definitely already ended; to enter this state
- * we had to see a space, which ends the sentence.
- */
-
- switch (type)
- {
- case G_UNICODE_SPACE_SEPARATOR:
- /* continue in this state */
- break;
-
- case G_UNICODE_LINE_SEPARATOR:
- case G_UNICODE_PARAGRAPH_SEPARATOR:
- /* undo the unconditional break-at-all-line/para-separators
- * from above; I'm not sure this is what the Unicode spec
- * intends, but it seems right
- */
- attrs[i].is_sentence_boundary = FALSE;
- sentence_state = STATE_SENTENCE_POST_TERM_SEP;
- break;
-
- default:
- attrs[i].is_sentence_boundary = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
-
- break;
- }
- break;
-
- case STATE_SENTENCE_POST_TERM_SEP:
- /* Break is forced at this point, unless we're a newline
- * after a CR, then we will break after the newline on the
- * next iteration. Only a single Sep can be in the
- * sentence.
- */
- if (!(prev_wc == '\r' && wc == '\n'))
- attrs[i].is_sentence_boundary = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
-
- break;
-
- case STATE_SENTENCE_DOT:
- switch (type)
- {
- case G_UNICODE_CLOSE_PUNCTUATION:
- sentence_state = STATE_SENTENCE_POST_DOT_CLOSE;
- break;
-
- case G_UNICODE_SPACE_SEPARATOR:
- possible_sentence_end = i;
- sentence_state = STATE_SENTENCE_POST_DOT_SPACE;
- break;
-
- default:
- /* If we broke on a control/format char, end the
- * sentence; else this was not a sentence end, since
- * we didn't enter the POST_DOT_SPACE state.
- */
- if (attrs[i].is_sentence_boundary)
- {
- attrs[i].is_sentence_end = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
- }
- else
- sentence_state = STATE_SENTENCE_BODY;
- break;
- }
- break;
-
- case STATE_SENTENCE_POST_DOT_CLOSE:
- switch (type)
- {
- case G_UNICODE_SPACE_SEPARATOR:
- possible_sentence_end = i;
- sentence_state = STATE_SENTENCE_POST_DOT_SPACE;
- break;
-
- default:
- /* If we broke on a control/format char, end the
- * sentence; else this was not a sentence end, since
- * we didn't enter the POST_DOT_SPACE state.
- */
- if (attrs[i].is_sentence_boundary)
- {
- attrs[i].is_sentence_end = TRUE;
-
- MAYBE_START_NEW_SENTENCE;
- }
- else
- sentence_state = STATE_SENTENCE_BODY;
- break;
- }
- break;
-
- case STATE_SENTENCE_POST_DOT_SPACE:
-
- possible_sentence_boundary = i;
-
- switch (type)
- {
- case G_UNICODE_SPACE_SEPARATOR:
- /* remain in current state */
- break;
-
- case G_UNICODE_OPEN_PUNCTUATION:
- sentence_state = STATE_SENTENCE_POST_DOT_OPEN;
- break;
-
- case G_UNICODE_LOWERCASE_LETTER:
- /* wasn't a sentence-ending period; so re-enter the sentence
- * body
- */
- sentence_state = STATE_SENTENCE_BODY;
- break;
-
- default:
- /* End the sentence, break, maybe start a new one */
-
- g_assert (possible_sentence_end >= 0);
- g_assert (possible_sentence_boundary >= 0);
-
- attrs[possible_sentence_boundary].is_sentence_boundary = TRUE;
- attrs[possible_sentence_end].is_sentence_end = TRUE;
-
- possible_sentence_end = -1;
- possible_sentence_boundary = -1;
-
- MAYBE_START_NEW_SENTENCE;
-
- break;
- }
- break;
-
- case STATE_SENTENCE_POST_DOT_OPEN:
- switch (type)
- {
- case G_UNICODE_OPEN_PUNCTUATION:
- /* continue in current state */
- break;
-
- case G_UNICODE_LOWERCASE_LETTER:
- /* wasn't a sentence-ending period; so re-enter the sentence
- * body
- */
- sentence_state = STATE_SENTENCE_BODY;
- break;
-
- default:
- /* End the sentence, break, maybe start a new one */
-
- g_assert (possible_sentence_end >= 0);
- g_assert (possible_sentence_boundary >= 0);
-
- attrs[possible_sentence_boundary].is_sentence_boundary = TRUE;
- attrs[possible_sentence_end].is_sentence_end = TRUE;
-
- possible_sentence_end = -1;
- possible_sentence_boundary = -1;
-
- MAYBE_START_NEW_SENTENCE;
-
- break;
- }
- break;
-
- case STATE_SENTENCE_POST_DOT_SEP:
- /* Break is forced at this point, unless we're a newline
- * after a CR, then we will break after the newline on the
- * next iteration. Only a single Sep can be in the
- * sentence.
- */
- if (!(prev_wc == '\r' && wc == '\n'))
- attrs[i].is_sentence_boundary = TRUE;
+ {
+ case STATE_SENTENCE_OUTSIDE:
+ /* Start sentence if we have non-whitespace/format/control */
+ switch (type)
+ {
+ case G_UNICODE_LINE_SEPARATOR:
+ case G_UNICODE_PARAGRAPH_SEPARATOR:
+ case G_UNICODE_CONTROL:
+ case G_UNICODE_FORMAT:
+ case G_UNICODE_SPACE_SEPARATOR:
+ break;
- g_assert (possible_sentence_end >= 0);
- g_assert (possible_sentence_boundary >= 0);
+ default:
+ attrs[i].is_sentence_start = TRUE;
+ sentence_state = STATE_SENTENCE_BODY;
+ break;
+ }
+ break;
- attrs[possible_sentence_end].is_sentence_end = TRUE;
+ case STATE_SENTENCE_BODY:
+ /* If we already broke here due to separators, end the sentence. */
+ if (attrs[i].is_sentence_boundary)
+ {
+ attrs[i].is_sentence_end = TRUE;
- possible_sentence_end = -1;
- possible_sentence_boundary = -1;
+ MAYBE_START_NEW_SENTENCE;
+ }
+ else
+ {
+ if (wc == '.')
+ sentence_state = STATE_SENTENCE_DOT;
+ else if (wc == '?' || wc == '!')
+ sentence_state = STATE_SENTENCE_TERM;
+ }
+ break;
- MAYBE_START_NEW_SENTENCE;
+ case STATE_SENTENCE_TERM:
+ /* End sentence on anything but close punctuation and some
+ * loosely-specified OTHER_PUNCTUATION such as period,
+ * comma, etc.; follow Unicode rules for breaks
+ */
+ switch (type)
+ {
+ case G_UNICODE_OTHER_PUNCTUATION:
+ case G_UNICODE_CLOSE_PUNCTUATION:
+ if (type == G_UNICODE_CLOSE_PUNCTUATION ||
+ wc == '.' ||
+ wc == ',' ||
+ wc == '?' ||
+ wc == '!')
+ sentence_state = STATE_SENTENCE_POST_TERM_CLOSE;
+ else
+ {
+ attrs[i].is_sentence_end = TRUE;
+ attrs[i].is_sentence_boundary = TRUE;
+
+ MAYBE_START_NEW_SENTENCE;
+ }
+ break;
+
+ case G_UNICODE_SPACE_SEPARATOR:
+ attrs[i].is_sentence_end = TRUE;
+ sentence_state = STATE_SENTENCE_POST_TERM_SPACE;
+ break;
+
+ case G_UNICODE_LINE_SEPARATOR:
+ case G_UNICODE_PARAGRAPH_SEPARATOR:
+ attrs[i].is_sentence_end = TRUE;
+ sentence_state = STATE_SENTENCE_POST_TERM_SEP;
+ break;
+
+ default:
+ attrs[i].is_sentence_end = TRUE;
+ attrs[i].is_sentence_boundary = TRUE;
+
+ MAYBE_START_NEW_SENTENCE;
+
+ break;
+ }
+ break;
+
+ case STATE_SENTENCE_POST_TERM_CLOSE:
+ /* End sentence on anything besides more punctuation; follow
+ * rules for breaks
+ */
+ switch (type)
+ {
+ case G_UNICODE_OTHER_PUNCTUATION:
+ case G_UNICODE_CLOSE_PUNCTUATION:
+ if (type == G_UNICODE_CLOSE_PUNCTUATION ||
+ wc == '.' ||
+ wc == ',' ||
+ wc == '?' ||
+ wc == '!')
+ /* continue in this state */
+ ;
+ else
+ {
+ attrs[i].is_sentence_end = TRUE;
+ attrs[i].is_sentence_boundary = TRUE;
+
+ MAYBE_START_NEW_SENTENCE;
+ }
+ break;
+
+ case G_UNICODE_SPACE_SEPARATOR:
+ attrs[i].is_sentence_end = TRUE;
+ sentence_state = STATE_SENTENCE_POST_TERM_SPACE;
+ break;
+
+ case G_UNICODE_LINE_SEPARATOR:
+ case G_UNICODE_PARAGRAPH_SEPARATOR:
+ attrs[i].is_sentence_end = TRUE;
+ /* undo the unconditional break-at-all-line/para-separators
+ * from above; I'm not sure this is what the Unicode spec
+ * intends, but it seems right - we get to include
+ * a single line/para separator in the sentence according
+ * to their rules
+ */
+ attrs[i].is_sentence_boundary = FALSE;
+ sentence_state = STATE_SENTENCE_POST_TERM_SEP;
+ break;
+
+ default:
+ attrs[i].is_sentence_end = TRUE;
+ attrs[i].is_sentence_boundary = TRUE;
+
+ MAYBE_START_NEW_SENTENCE;
+
+ break;
+ }
+ break;
+
+ case STATE_SENTENCE_POST_TERM_SPACE:
+
+ /* Sentence is definitely already ended; to enter this state
+ * we had to see a space, which ends the sentence.
+ */
+
+ switch (type)
+ {
+ case G_UNICODE_SPACE_SEPARATOR:
+ /* continue in this state */
+ break;
+
+ case G_UNICODE_LINE_SEPARATOR:
+ case G_UNICODE_PARAGRAPH_SEPARATOR:
+ /* undo the unconditional break-at-all-line/para-separators
+ * from above; I'm not sure this is what the Unicode spec
+ * intends, but it seems right
+ */
+ attrs[i].is_sentence_boundary = FALSE;
+ sentence_state = STATE_SENTENCE_POST_TERM_SEP;
+ break;
+
+ default:
+ attrs[i].is_sentence_boundary = TRUE;
+
+ MAYBE_START_NEW_SENTENCE;
+
+ break;
+ }
+ break;
+
+ case STATE_SENTENCE_POST_TERM_SEP:
+ /* Break is forced at this point, unless we're a newline
+ * after a CR, then we will break after the newline on the
+ * next iteration. Only a single Sep can be in the
+ * sentence.
+ */
+ if (!(prev_wc == '\r' && wc == '\n'))
+ attrs[i].is_sentence_boundary = TRUE;
- break;
+ MAYBE_START_NEW_SENTENCE;
- default:
- g_assert_not_reached ();
- break;
- }
+ break;
+
+ case STATE_SENTENCE_DOT:
+ switch (type)
+ {
+ case G_UNICODE_CLOSE_PUNCTUATION:
+ sentence_state = STATE_SENTENCE_POST_DOT_CLOSE;
+ break;
+
+ case G_UNICODE_SPACE_SEPARATOR:
+ possible_sentence_end = i;
+ sentence_state = STATE_SENTENCE_POST_DOT_SPACE;
+ break;
+
+ default:
+ /* If we broke on a control/format char, end the
+ * sentence; else this was not a sentence end, since
+ * we didn't enter the POST_DOT_SPACE state.
+ */
+ if (attrs[i].is_sentence_boundary)
+ {
+ attrs[i].is_sentence_end = TRUE;
+
+ MAYBE_START_NEW_SENTENCE;
+ }
+ else
+ sentence_state = STATE_SENTENCE_BODY;
+ break;
+ }
+ break;
+
+ case STATE_SENTENCE_POST_DOT_CLOSE:
+ switch (type)
+ {
+ case G_UNICODE_SPACE_SEPARATOR:
+ possible_sentence_end = i;
+ sentence_state = STATE_SENTENCE_POST_DOT_SPACE;
+ break;
+
+ default:
+ /* If we broke on a control/format char, end the
+ * sentence; else this was not a sentence end, since
+ * we didn't enter the POST_DOT_SPACE state.
+ */
+ if (attrs[i].is_sentence_boundary)
+ {
+ attrs[i].is_sentence_end = TRUE;
+
+ MAYBE_START_NEW_SENTENCE;
+ }
+ else
+ sentence_state = STATE_SENTENCE_BODY;
+ break;
+ }
+ break;
+
+ case STATE_SENTENCE_POST_DOT_SPACE:
+
+ possible_sentence_boundary = i;
+
+ switch (type)
+ {
+ case G_UNICODE_SPACE_SEPARATOR:
+ /* remain in current state */
+ break;
+
+ case G_UNICODE_OPEN_PUNCTUATION:
+ sentence_state = STATE_SENTENCE_POST_DOT_OPEN;
+ break;
+
+ case G_UNICODE_LOWERCASE_LETTER:
+ /* wasn't a sentence-ending period; so re-enter the sentence
+ * body
+ */
+ sentence_state = STATE_SENTENCE_BODY;
+ break;
+
+ default:
+ /* End the sentence, break, maybe start a new one */
+
+ g_assert (possible_sentence_end >= 0);
+ g_assert (possible_sentence_boundary >= 0);
+
+ attrs[possible_sentence_boundary].is_sentence_boundary = TRUE;
+ attrs[possible_sentence_end].is_sentence_end = TRUE;
+
+ possible_sentence_end = -1;
+ possible_sentence_boundary = -1;
+
+ MAYBE_START_NEW_SENTENCE;
+
+ break;
+ }
+ break;
+
+ case STATE_SENTENCE_POST_DOT_OPEN:
+ switch (type)
+ {
+ case G_UNICODE_OPEN_PUNCTUATION:
+ /* continue in current state */
+ break;
+
+ case G_UNICODE_LOWERCASE_LETTER:
+ /* wasn't a sentence-ending period; so re-enter the sentence
+ * body
+ */
+ sentence_state = STATE_SENTENCE_BODY;
+ break;
+
+ default:
+ /* End the sentence, break, maybe start a new one */
+
+ g_assert (possible_sentence_end >= 0);
+ g_assert (possible_sentence_boundary >= 0);
+
+ attrs[possible_sentence_boundary].is_sentence_boundary = TRUE;
+ attrs[possible_sentence_end].is_sentence_end = TRUE;
+
+ possible_sentence_end = -1;
+ possible_sentence_boundary = -1;
+
+ MAYBE_START_NEW_SENTENCE;
+
+ break;
+ }
+ break;
+
+ case STATE_SENTENCE_POST_DOT_SEP:
+ /* Break is forced at this point, unless we're a newline
+ * after a CR, then we will break after the newline on the
+ * next iteration. Only a single Sep can be in the
+ * sentence.
+ */
+ if (!(prev_wc == '\r' && wc == '\n'))
+ attrs[i].is_sentence_boundary = TRUE;
+
+ g_assert (possible_sentence_end >= 0);
+ g_assert (possible_sentence_boundary >= 0);
+
+ attrs[possible_sentence_end].is_sentence_end = TRUE;
+
+ possible_sentence_end = -1;
+ possible_sentence_boundary = -1;
+
+ MAYBE_START_NEW_SENTENCE;
+
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
prev_type = type;
prev_wc = wc;
/* wc might not be a valid Unicode base character, but really all we
* need to know is the last non-combining character */
if (type != G_UNICODE_COMBINING_MARK &&
- type != G_UNICODE_ENCLOSING_MARK &&
- type != G_UNICODE_NON_SPACING_MARK)
- base_character = wc;
+ type != G_UNICODE_ENCLOSING_MARK &&
+ type != G_UNICODE_NON_SPACING_MARK)
+ base_character = wc;
}
}
static gboolean
tailor_break (const gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoLogAttr *attrs,
- int attrs_len)
+ gint length,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs,
+ int attrs_len)
{
if (analysis->lang_engine && PANGO_ENGINE_LANG_GET_CLASS (analysis->lang_engine)->script_break)
{
*/
void
pango_break (const gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoLogAttr *attrs,
- int attrs_len)
+ gint length,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs,
+ int attrs_len)
{
g_return_if_fail (analysis != NULL);
g_return_if_fail (attrs != NULL);
**/
void
pango_find_paragraph_boundary (const gchar *text,
- gint length,
- gint *paragraph_delimiter_index,
- gint *next_paragraph_start)
+ gint length,
+ gint *paragraph_delimiter_index,
+ gint *next_paragraph_start)
{
const gchar *p = text;
const gchar *end;
while (p != end)
{
if (prev_sep == '\n' ||
- prev_sep == PARAGRAPH_SEPARATOR_STRING[0])
- {
- g_assert (delimiter);
- start = p;
- break;
- }
+ prev_sep == PARAGRAPH_SEPARATOR_STRING[0])
+ {
+ g_assert (delimiter);
+ start = p;
+ break;
+ }
else if (prev_sep == '\r')
- {
- /* don't break between \r and \n */
- if (*p != '\n')
- {
- g_assert (delimiter);
- start = p;
- break;
- }
- }
+ {
+ /* don't break between \r and \n */
+ if (*p != '\n')
+ {
+ g_assert (delimiter);
+ start = p;
+ break;
+ }
+ }
if (*p == '\n' ||
- *p == '\r' ||
- !strncmp(p, PARAGRAPH_SEPARATOR_STRING,
+ *p == '\r' ||
+ !strncmp(p, PARAGRAPH_SEPARATOR_STRING,
strlen(PARAGRAPH_SEPARATOR_STRING)))
- {
- if (delimiter == NULL)
+ {
+ if (delimiter == NULL)
delimiter = p;
prev_sep = *p;
}
*/
void
pango_get_log_attrs (const char *text,
- int length,
- int level,
- PangoLanguage *language,
- PangoLogAttr *log_attrs,
- int attrs_len)
+ int length,
+ int level,
+ PangoLanguage *language,
+ PangoLogAttr *log_attrs,
+ int attrs_len)
{
PangoMap *lang_map;
int chars_broken;
g_assert (range_end == run_start);
if (range_engine != run_engine)
- {
- /* Engine has changed; do the tailoring for the current range,
- * then start a new range.
- */
+ {
+ /* Engine has changed; do the tailoring for the current range,
+ * then start a new range.
+ */
chars_broken += tailor_segment (range_start, range_end, range_engine, chars_broken, &analysis, log_attrs);
- range_start = run_start;
+ range_start = run_start;
range_engine = run_engine;
- }
+ }
range_end = run_end;
}
pango_script_iter_free (iter);
{ \
found = TRUE; \
if (desc) \
- desc->mask |= MASK; \
+ desc->mask |= MASK; \
} \
} G_STMT_END
*pango_size = (int)(size * PANGO_SCALE + 0.5);
if (size_is_absolute)
- *size_is_absolute = end < word + wordlen;
+ *size_is_absolute = end < word + wordlen;
return TRUE;
}
desc = pango_font_description_new ();
desc->mask = PANGO_FONT_MASK_STYLE |
- PANGO_FONT_MASK_WEIGHT |
- PANGO_FONT_MASK_VARIANT |
- PANGO_FONT_MASK_STRETCH;
+ PANGO_FONT_MASK_WEIGHT |
+ PANGO_FONT_MASK_VARIANT |
+ PANGO_FONT_MASK_STRETCH;
len = strlen (str);
last = str + len;
{
if (!_pango_warning_history.get_glyph_extents)
- {
+ {
_pango_warning_history.get_glyph_extents = TRUE;
g_warning (bad_font_warning, "pango_font_get_glyph_extents");
}
if (ink_rect)
- {
+ {
ink_rect->x = PANGO_SCALE;
ink_rect->y = - (PANGO_UNKNOWN_GLYPH_HEIGHT - 1) * PANGO_SCALE;
ink_rect->height = (PANGO_UNKNOWN_GLYPH_HEIGHT - 2) * PANGO_SCALE;
ink_rect->width = (PANGO_UNKNOWN_GLYPH_WIDTH - 2) * PANGO_SCALE;
- }
+ }
if (logical_rect)
- {
+ {
logical_rect->x = logical_rect->y = 0;
logical_rect->y = - PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE;
logical_rect->height = PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE;
{
if (!_pango_warning_history.get_metrics)
- {
+ {
_pango_warning_history.get_metrics = TRUE;
g_warning (bad_font_warning, "pango_font_get_metrics");
}
{
if (!_pango_warning_history.get_font_map)
- {
+ {
_pango_warning_history.get_font_map = TRUE;
g_warning (bad_font_warning, "pango_font_get_font_map");
}
**/
void
pango_font_face_list_sizes (PangoFontFace *face,
- int **sizes,
- int *n_sizes)
+ int **sizes,
+ int *n_sizes)
{
g_return_if_fail (PANGO_IS_FONT_FACE (face));
g_return_if_fail (sizes == NULL || n_sizes != NULL);
while (new_len > string->space)
{
if (string->space == 0)
- string->space = 1;
+ string->space = 1;
else
- string->space *= 2;
+ string->space *= 2;
if (string->space < 0)
- {
+ {
g_warning ("glyph string length overflows maximum integer size, truncated");
new_len = string->space = G_MAXINT - 8;
}
* @glyphs: a #PangoGlyphString
* @start: start index
* @end: end index (the range is the set of bytes with
- indices such that start <= index < end)
+ indices such that start <= index < end)
* @font: a #PangoFont
* @ink_rect: rectangle used to store the extents of the glyph string range as drawn
* or %NULL to indicate that the result is not needed.
**/
void
pango_glyph_string_extents_range (PangoGlyphString *glyphs,
- int start,
- int end,
- PangoFont *font,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ int start,
+ int end,
+ PangoFont *font,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
{
int x_pos = 0;
int i;
PangoRectangle *logical_rect)
{
pango_glyph_string_extents_range (glyphs, 0, glyphs->num_glyphs,
- font, ink_rect, logical_rect);
+ font, ink_rect, logical_rect);
}
/**
}
if (!pair->engine)
- {
+ {
/* If a module cannot be used, or doesn't not create an engine
* correctly, we print out an error containing module name and id,
* but to not flood the terminal with zillions of the message, we
};
static PangoAttribute *pango_attr_color_new (const PangoAttrClass *klass,
- guint16 red,
- guint16 green,
- guint16 blue);
+ guint16 red,
+ guint16 green,
+ guint16 blue);
static PangoAttribute *pango_attr_string_new (const PangoAttrClass *klass,
- const char *str);
+ const char *str);
static PangoAttribute *pango_attr_int_new (const PangoAttrClass *klass,
- int value);
+ int value);
static PangoAttribute *pango_attr_float_new (const PangoAttrClass *klass,
- double value);
+ double value);
static PangoAttribute *pango_attr_size_new_internal (int size,
gboolean absolute);
return pango_attr_color_new (attr->klass,
color_attr->color.red,
- color_attr->color.green,
- color_attr->color.blue);
+ color_attr->color.green,
+ color_attr->color.blue);
}
static void
static PangoAttribute*
pango_attr_float_new (const PangoAttrClass *klass,
- double value)
+ double value)
{
PangoAttrFloat *result = g_slice_new (PangoAttrFloat);
result->attr.klass = klass;
while (iter != NULL)
{
new_attrs = g_slist_prepend (new_attrs,
- pango_attribute_copy (iter->data));
+ pango_attribute_copy (iter->data));
iter = g_slist_next (iter);
}
if (tmp_attr2->start_index >= tmp_attr->start_index)
break;
- prev2 = tmp_list2;
+ prev2 = tmp_list2;
tmp_list2 = tmp_list2->next;
}
pango_font_description_merge_static (desc, ((PangoAttrFontDesc *)attr)->desc, FALSE);
break;
- }
+ }
case PANGO_ATTR_FAMILY:
if (!(mask & PANGO_FONT_MASK_FAMILY))
{
pango_font_description_set_absolute_size (desc, ((PangoAttrSize *)attr)->size);
}
break;
- case PANGO_ATTR_SCALE:
+ case PANGO_ATTR_SCALE:
if (!have_scale)
{
have_scale = TRUE;
PangoAttribute *pango_attr_letter_spacing_new (int letter_spacing);
PangoAttribute *pango_attr_shape_new (const PangoRectangle *ink_rect,
- const PangoRectangle *logical_rect);
+ const PangoRectangle *logical_rect);
PangoAttribute *pango_attr_shape_new_with_data (const PangoRectangle *ink_rect,
const PangoRectangle *logical_rect,
gpointer data,
PangoAttrIterator *pango_attr_list_get_iterator (PangoAttrList *list);
void pango_attr_iterator_range (PangoAttrIterator *iterator,
- gint *start,
- gint *end);
+ gint *start,
+ gint *end);
gboolean pango_attr_iterator_next (PangoAttrIterator *iterator);
PangoAttrIterator *pango_attr_iterator_copy (PangoAttrIterator *iterator);
void pango_attr_iterator_destroy (PangoAttrIterator *iterator);
PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator,
- PangoAttrType type);
+ PangoAttrType type);
void pango_attr_iterator_get_font (PangoAttrIterator *iterator,
- PangoFontDescription *desc,
+ PangoFontDescription *desc,
PangoLanguage **language,
- GSList **extra_attrs);
+ GSList **extra_attrs);
GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator);
gboolean pango_parse_markup (const char *markup_text,
- int length,
- gunichar accel_marker,
- PangoAttrList **attr_list,
- char **text,
- gunichar *accel_char,
- GError **error);
+ int length,
+ gunichar accel_marker,
+ PangoAttrList **attr_list,
+ char **text,
+ gunichar *accel_char,
+ GError **error);
G_END_DECLS
int length,
PangoAnalysis *analysis,
PangoLogAttr *attrs,
- int attrs_len);
+ int attrs_len);
void pango_find_paragraph_boundary (const gchar *text,
- gint length,
- gint *paragraph_delimiter_index,
- gint *next_paragraph_start);
+ gint length,
+ gint *paragraph_delimiter_index,
+ gint *next_paragraph_start);
void pango_get_log_attrs (const char *text,
- int length,
- int level,
- PangoLanguage *language,
- PangoLogAttr *log_attrs,
- int attrs_len);
+ int length,
+ int level,
+ PangoLanguage *language,
+ PangoLogAttr *log_attrs,
+ int attrs_len);
#ifdef PANGO_ENABLE_ENGINE
* from a language engine override.
*/
void pango_default_break (const gchar *text,
- int length,
- PangoAnalysis *analysis,
- PangoLogAttr *attrs,
- int attrs_len);
+ int length,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs,
+ int attrs_len);
#endif /* PANGO_ENABLE_ENGINE */
ColorEntry *found;
found = bsearch (name, color_entries, G_N_ELEMENTS (color_entries),
- sizeof (ColorEntry),
- compare_xcolor_entries);
+ sizeof (ColorEntry),
+ compare_xcolor_entries);
if (found == NULL)
return FALSE;
spec++;
len = strlen (spec);
if (len % 3 || len < 3 || len > 12)
- return FALSE;
+ return FALSE;
len /= 3;
color->red = r;
color->green = g;
color->blue = b;
- }
+ }
}
else
{
if (!find_color (spec, color))
- return FALSE;
+ return FALSE;
}
return TRUE;
}
while (start_index >= end_range)
{
if (!pango_attr_iterator_next (iterator))
- return FALSE;
+ return FALSE;
pango_attr_iterator_range (iterator, &start_range, &end_range);
}
if (start_range > start_index)
g_warning ("In pango_itemize(), the cached iterator passed in "
- "had already moved beyond the start_index");
+ "had already moved beyond the start_index");
return TRUE;
}
static PangoAttribute *
find_attribute (GSList *attr_list,
- PangoAttrType type)
+ PangoAttrType type)
{
GSList *node;
{
if (!state->base_font)
state->base_font = pango_font_map_load_font (state->context->font_map,
- state->context,
- state->font_desc);
+ state->context,
+ state->font_desc);
return state->base_font;
}
PangoScript script;
if (PANGO_GRAVITY_IS_VERTICAL (state->resolved_gravity))
- script = PANGO_SCRIPT_COMMON;
+ script = PANGO_SCRIPT_COMMON;
else
- script = state->script;
+ script = state->script;
get_engines (state->context, state->derived_lang, script,
&state->exact_engines, &state->fallback_engines);
/* skip caching if fallback disabled (see above) */
if (state->enable_fallback)
- shaper_font_cache_insert (state->cache, wc, *shape_engine, *font);
+ shaper_font_cache_insert (state->cache, wc, *shape_engine, *font);
return TRUE;
}
PangoGravity old_gravity = state->resolved_gravity;
if (state->font_desc_gravity != PANGO_GRAVITY_AUTO)
- {
+ {
state->resolved_gravity = state->font_desc_gravity;
state->centered_baseline = PANGO_GRAVITY_IS_VERTICAL (state->resolved_gravity);
}
else
- {
+ {
PangoGravity gravity = state->gravity;
PangoGravityHint gravity_hint = state->gravity_hint;
}
if (old_gravity != state->resolved_gravity)
- {
+ {
pango_font_description_set_gravity (state->font_desc, state->resolved_gravity);
- state->changed |= FONT_CHANGED;
+ state->changed |= FONT_CHANGED;
}
}
font = NULL;
}
else
- {
+ {
get_shaper_and_font (state, wc, &shape_engine, &font);
}
/**
* pango_itemize_with_base_dir:
* @context: a structure holding information that affects
- the itemization process.
+ the itemization process.
* @text: the text to itemize.
* @start_index: first byte in @text to process
* @length: the number of bytes (not characters) to process
/**
* pango_itemize:
* @context: a structure holding information that affects
- the itemization process.
+ the itemization process.
* @text: the text to itemize.
* @start_index: first byte in @text to process
* @length: the number of bytes (not characters) to process
GList *
pango_itemize (PangoContext *context,
const char *text,
- int start_index,
+ int start_index,
int length,
PangoAttrList *attrs,
- PangoAttrIterator *cached_iter)
+ PangoAttrIterator *cached_iter)
{
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (start_index >= 0, NULL);
**/
void
pango_coverage_set (PangoCoverage *coverage,
- int index,
- PangoCoverageLevel level)
+ int index,
+ PangoCoverageLevel level)
{
int block_index, i;
guchar *data;
byte = coverage->blocks[block_index].level |
(coverage->blocks[block_index].level << 2) |
(coverage->blocks[block_index].level << 4) |
- (coverage->blocks[block_index].level << 6);
+ (coverage->blocks[block_index].level << 6);
memset (data, byte, 64);
}
**/
void
pango_coverage_max (PangoCoverage *coverage,
- PangoCoverage *other)
+ PangoCoverage *other)
{
int block_index, i;
int old_blocks;
static void
fallback_engine_shape (PangoEngineShape *engine,
PangoFont *font,
- const char *text,
- gint length,
- const PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+ const char *text,
+ gint length,
+ const PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
{
int n_chars;
int i;
int len,
PangoAnalysis *analysis,
PangoLogAttr *attrs,
- int attrs_len);
+ int attrs_len);
};
GType pango_engine_lang_get_type (void) G_GNUC_CONST;
}; \
\
prefix ## _type = g_type_module_register_type (module, parent_type, \
- # name, \
+ # name, \
&object_info, 0); \
}
#define PANGO_ENGINE_LANG_DEFINE_TYPE(name, prefix, class_init, instance_init) \
PANGO_ENGINE_DEFINE_TYPE (name, prefix, \
class_init, instance_init, \
- PANGO_TYPE_ENGINE_LANG)
+ PANGO_TYPE_ENGINE_LANG)
/**
* PANGO_ENGINE_SHAPE_DEFINE_TYPE:
#define PANGO_ENGINE_SHAPE_DEFINE_TYPE(name, prefix, class_init, instance_init) \
PANGO_ENGINE_DEFINE_TYPE (name, prefix, \
class_init, instance_init, \
- PANGO_TYPE_ENGINE_SHAPE)
+ PANGO_TYPE_ENGINE_SHAPE)
/* Macro used for possibly builtin Pango modules. Not useful
* for externally build modules. If we are compiling a module standaline,
/*< public >*/
void (*list_faces) (PangoFontFamily *family,
- PangoFontFace ***faces,
- int *n_faces);
+ PangoFontFace ***faces,
+ int *n_faces);
const char * (*get_name) (PangoFontFamily *family);
gboolean (*is_monospace) (PangoFontFamily *family);
PangoFontDescription *pango_font_face_describe (PangoFontFace *face);
G_CONST_RETURN char *pango_font_face_get_face_name (PangoFontFace *face);
void pango_font_face_list_sizes (PangoFontFace *face,
- int **sizes,
- int *n_sizes);
+ int **sizes,
+ int *n_sizes);
#ifdef PANGO_ENABLE_BACKEND
const char * (*get_face_name) (PangoFontFace *face);
PangoFontDescription * (*describe) (PangoFontFace *face);
void (*list_sizes) (PangoFontFace *face,
- int **sizes,
- int *n_sizes);
+ int **sizes,
+ int *n_sizes);
/*< private >*/
pango_font_description_set_family_static (tmp_desc, "Sans");
if (!warned_fonts || !g_hash_table_lookup (warned_fonts, ctmp1))
- {
+ {
if (!warned_fonts)
warned_fonts = g_hash_table_new (g_str_hash, g_str_equal);
g_warning ("couldn't load font \"%s\", falling back to \"%s\", "
"expect ugly output.", ctmp1, ctmp2);
g_free (ctmp2);
- }
+ }
g_free (ctmp1);
pango_font_map_fontset_add_fonts (fontmap,
pango_font_description_set_stretch (tmp_desc, PANGO_STRETCH_NORMAL);
if (!warned_fonts || !g_hash_table_lookup (warned_fonts, ctmp1))
- {
+ {
g_hash_table_insert (warned_fonts, g_strdup (ctmp1), GINT_TO_POINTER (1));
ctmp2 = pango_font_description_to_string (tmp_desc);
int pango_glyph_string_get_width(PangoGlyphString *glyphs);
void pango_glyph_string_extents_range (PangoGlyphString *glyphs,
- int start,
- int end,
- PangoFont *font,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect);
+ int start,
+ int end,
+ PangoFont *font,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
void pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
const char *text,
default:
case PANGO_GRAVITY_HINT_NATURAL:
if (props.vert_dir == PANGO_VERTICAL_DIRECTION_NONE)
- return PANGO_GRAVITY_SOUTH;
+ return PANGO_GRAVITY_SOUTH;
if ((base_gravity == PANGO_GRAVITY_EAST) ^
(props.vert_dir == PANGO_VERTICAL_DIRECTION_BTT))
- return PANGO_GRAVITY_SOUTH;
+ return PANGO_GRAVITY_SOUTH;
else
- return PANGO_GRAVITY_NORTH;
+ return PANGO_GRAVITY_NORTH;
case PANGO_GRAVITY_HINT_STRONG:
return base_gravity;
case PANGO_GRAVITY_HINT_LINE:
if ((base_gravity == PANGO_GRAVITY_EAST) ^
(props.horiz_dir == PANGO_DIRECTION_RTL))
- return PANGO_GRAVITY_SOUTH;
+ return PANGO_GRAVITY_SOUTH;
else
- return PANGO_GRAVITY_NORTH;
+ return PANGO_GRAVITY_NORTH;
}
}
}
#define PANGO_DEFINE_TYPE(name, prefix, \
- class_init, instance_init, \
+ class_init, instance_init, \
parent_type) \
PANGO_DEFINE_TYPE_FULL (name, prefix, \
class_init, instance_init, \
parent_type, 0)
#define PANGO_DEFINE_TYPE_ABSTRACT(name, prefix, \
- class_init, instance_init, \
+ class_init, instance_init, \
parent_type) \
PANGO_DEFINE_TYPE_FULL (name, prefix, \
class_init, instance_init, \
if (our_type == 0)
our_type = g_boxed_type_register_static (I_("PangoItem"),
- (GBoxedCopyFunc) pango_item_copy,
- (GBoxedFreeFunc) pango_item_free);
+ (GBoxedCopyFunc) pango_item_copy,
+ (GBoxedFreeFunc) pango_item_free);
return our_type;
}
**/
PangoItem*
pango_item_split (PangoItem *orig,
- int split_index,
- int split_offset)
+ int split_index,
+ int split_offset)
{
PangoItem *new_item;
PangoItem *pango_item_copy (PangoItem *item);
void pango_item_free (PangoItem *item);
PangoItem *pango_item_split (PangoItem *orig,
- int split_index,
- int split_offset);
+ int split_index,
+ int split_offset);
G_END_DECLS
#define ITER_IS_INVALID(iter) G_UNLIKELY (check_invalid ((iter), G_STRLOC))
static gboolean
check_invalid (PangoLayoutIter *iter,
- const char *loc)
+ const char *loc)
{
if (iter->line->layout == NULL)
{
**/
void
pango_layout_set_wrap (PangoLayout *layout,
- PangoWrapMode wrap)
+ PangoWrapMode wrap)
{
g_return_if_fail (PANGO_IS_LAYOUT (layout));
**/
void
pango_layout_set_spacing (PangoLayout *layout,
- int spacing)
+ int spacing)
{
g_return_if_fail (layout != NULL);
**/
void
pango_layout_set_tabs (PangoLayout *layout,
- PangoTabArray *tabs)
+ PangoTabArray *tabs)
{
g_return_if_fail (PANGO_IS_LAYOUT (layout));
**/
void
pango_layout_set_single_paragraph_mode (PangoLayout *layout,
- gboolean setting)
+ gboolean setting)
{
g_return_if_fail (PANGO_IS_LAYOUT (layout));
**/
void
pango_layout_set_markup (PangoLayout *layout,
- const char *markup,
- int length)
+ const char *markup,
+ int length)
{
pango_layout_set_markup_with_accel (layout, markup, length, 0, NULL);
}
**/
void
pango_layout_set_markup_with_accel (PangoLayout *layout,
- const char *markup,
- int length,
- gunichar accel_marker,
- gunichar *accel_char)
+ const char *markup,
+ int length,
+ gunichar accel_marker,
+ gunichar *accel_char)
{
PangoAttrList *list = NULL;
char *text = NULL;
error = NULL;
if (!pango_parse_markup (markup, length,
- accel_marker,
- &list, &text,
- accel_char,
- &error))
+ accel_marker,
+ &list, &text,
+ accel_char,
+ &error))
{
g_warning ("pango_layout_set_markup_with_accel: %s", error->message);
g_error_free (error);
lines_list = layout->lines;
while (lines_list)
{
- line = lines_list->data;
- runs_list = line->runs;
-
- while (runs_list)
- {
- run = runs_list->data;
-
- for (i = 0; i < run->glyphs->num_glyphs; i++)
- {
- if (run->glyphs->glyphs[i].glyph & PANGO_GLYPH_UNKNOWN_FLAG)
- count++;
- }
-
- runs_list = runs_list->next;
- }
- lines_list = lines_list->next;
+ line = lines_list->data;
+ runs_list = line->runs;
+
+ while (runs_list)
+ {
+ run = runs_list->data;
+
+ for (i = 0; i < run->glyphs->num_glyphs; i++)
+ {
+ if (run->glyphs->glyphs[i].glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+ count++;
+ }
+
+ runs_list = runs_list->next;
+ }
+ lines_list = lines_list->next;
}
layout->unknown_glyphs_count = count;
&run->item->analysis,
index - run->item->offset, trailing, x_pos);
if (x_pos)
- *x_pos += width;
+ *x_pos += width;
}
return;
PangoLayoutLine *tmp_line = tmp_list->data;
if (tmp_line->start_index > index)
- break; /* index was in paragraph delimiters */
+ break; /* index was in paragraph delimiters */
prev_line = line;
line = tmp_line;
i++;
if (line->start_index + line->length > index)
- break;
+ break;
tmp_list = tmp_list->next;
}
pango_layout_iter_get_line_yrange (iter, &first_y, &last_y);
if (y < first_y)
- {
- if (prev_line && y < (prev_last + (first_y - prev_last) / 2))
- {
- found = prev_line;
- found_line_x = prev_line_x;
- }
- else
- {
- if (prev_line == NULL)
- outside = TRUE; /* off the top */
-
- found = _pango_layout_iter_get_line (iter);
- found_line_x = x - line_logical.x;
- }
- }
+ {
+ if (prev_line && y < (prev_last + (first_y - prev_last) / 2))
+ {
+ found = prev_line;
+ found_line_x = prev_line_x;
+ }
+ else
+ {
+ if (prev_line == NULL)
+ outside = TRUE; /* off the top */
+
+ found = _pango_layout_iter_get_line (iter);
+ found_line_x = x - line_logical.x;
+ }
+ }
else if (y >= first_y &&
- y < last_y)
- {
- found = _pango_layout_iter_get_line (iter);
- found_line_x = x - line_logical.x;
- }
+ y < last_y)
+ {
+ found = _pango_layout_iter_get_line (iter);
+ found_line_x = x - line_logical.x;
+ }
prev_line = _pango_layout_iter_get_line (iter);
prev_last = last_y;
prev_line_x = x - line_logical.x;
if (found != NULL)
- break;
+ break;
}
while (pango_layout_iter_next_line (iter));
}
retval = pango_layout_line_x_to_index (found,
- found_line_x,
- index, trailing);
+ found_line_x,
+ index, trailing);
if (outside)
retval = FALSE;
{
dir1 = layout_line->resolved_dir;
if (layout_line->resolved_dir == PANGO_DIRECTION_LTR)
- x1_trailing = 0;
+ x1_trailing = 0;
else
- x1_trailing = line_rect.width;
+ x1_trailing = line_rect.width;
}
else
{
if (index >= layout_line->start_index + layout_line->length)
{
if (layout_line->resolved_dir == PANGO_DIRECTION_LTR)
- x2 = line_rect.width;
+ x2 = line_rect.width;
else
- x2 = 0;
+ x2 = 0;
}
else
{
static void
get_x_offset (PangoLayout *layout,
- PangoLayoutLine *line,
- int layout_width,
- int line_width,
- int *x_offset)
+ PangoLayoutLine *line,
+ int layout_width,
+ int line_width,
+ int *x_offset)
{
PangoAlignment alignment = get_alignment (layout, line);
if (line->is_paragraph_start)
{
if (layout->indent > 0)
- {
- if (alignment == PANGO_ALIGN_LEFT)
- *x_offset += layout->indent;
- else
- *x_offset -= layout->indent;
- }
+ {
+ if (alignment == PANGO_ALIGN_LEFT)
+ *x_offset += layout->indent;
+ else
+ *x_offset -= layout->indent;
+ }
}
else
{
if (layout->indent < 0)
- {
- if (alignment == PANGO_ALIGN_LEFT)
- *x_offset -= layout->indent;
- else
- *x_offset += layout->indent;
- }
+ {
+ if (alignment == PANGO_ALIGN_LEFT)
+ *x_offset -= layout->indent;
+ else
+ *x_offset += layout->indent;
+ }
}
}
static void
get_line_extents_layout_coords (PangoLayout *layout,
- PangoLayoutLine *line,
- int layout_width,
- int y_offset,
- int *baseline,
- PangoRectangle *line_ink_layout,
- PangoRectangle *line_logical_layout)
+ PangoLayoutLine *line,
+ int layout_width,
+ int y_offset,
+ int *baseline,
+ PangoRectangle *line_ink_layout,
+ PangoRectangle *line_logical_layout)
{
int x_offset;
/* Line extents in line coords (origin at line baseline) */
PangoRectangle line_logical;
pango_layout_line_get_extents (line, line_ink_layout ? &line_ink : NULL,
- &line_logical);
+ &line_logical);
get_x_offset (layout, line, layout_width, line_logical.width, &x_offset);
*/
static void
pango_layout_get_extents_internal (PangoLayout *layout,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect,
- GSList **line_extents)
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect,
+ GSList **line_extents)
{
GSList *line_list;
int y_offset = 0;
/* This block gets the line extents in layout coords */
{
- int baseline;
-
- get_line_extents_layout_coords (layout, line,
- width, y_offset,
- &baseline,
- ink_rect ? &line_ink_layout : NULL,
- &line_logical_layout);
-
- if (line_extents)
- {
- Extents *ext = g_slice_new (Extents);
- ext->baseline = baseline;
- ext->ink_rect = line_ink_layout;
- ext->logical_rect = line_logical_layout;
- *line_extents = g_slist_prepend (*line_extents, ext);
- }
+ int baseline;
+
+ get_line_extents_layout_coords (layout, line,
+ width, y_offset,
+ &baseline,
+ ink_rect ? &line_ink_layout : NULL,
+ &line_logical_layout);
+
+ if (line_extents)
+ {
+ Extents *ext = g_slice_new (Extents);
+ ext->baseline = baseline;
+ ext->ink_rect = line_ink_layout;
+ ext->logical_rect = line_logical_layout;
+ *line_extents = g_slist_prepend (*line_extents, ext);
+ }
}
if (ink_rect)
{
- /* Compute the union of the current ink_rect with
- * line_ink_layout
- */
+ /* Compute the union of the current ink_rect with
+ * line_ink_layout
+ */
if (line_list == layout->lines)
{
- *ink_rect = line_ink_layout;
+ *ink_rect = line_ink_layout;
}
else
{
new_pos = MIN (ink_rect->x, line_ink_layout.x);
ink_rect->width =
- MAX (ink_rect->x + ink_rect->width,
- line_ink_layout.x + line_ink_layout.width) - new_pos;
+ MAX (ink_rect->x + ink_rect->width,
+ line_ink_layout.x + line_ink_layout.width) - new_pos;
ink_rect->x = new_pos;
new_pos = MIN (ink_rect->y, line_ink_layout.y);
ink_rect->height =
- MAX (ink_rect->y + ink_rect->height,
- line_ink_layout.y + line_ink_layout.height) - new_pos;
+ MAX (ink_rect->y + ink_rect->height,
+ line_ink_layout.y + line_ink_layout.height) - new_pos;
ink_rect->y = new_pos;
- }
+ }
}
if (logical_rect)
logical_rect->height += line_logical_layout.height;
- /* No space after the last line, of course. */
- if (line_list->next != NULL)
- logical_rect->height += layout->spacing;
+ /* No space after the last line, of course. */
+ if (line_list->next != NULL)
+ logical_rect->height += layout->spacing;
}
y_offset += line_logical_layout.height + layout->spacing;
* @ink_rect: rectangle used to store the extents of the layout as drawn
* or %NULL to indicate that the result is not needed.
* @logical_rect: rectangle used to store the logical extents of the layout
- or %NULL to indicate that the result is not needed.
+ or %NULL to indicate that the result is not needed.
*
* Computes the logical and ink extents of @layout. Logical extents
* are usually what you want for positioning things. Note that both extents
pango_tab_array_get_tab (layout->tabs, index, NULL, &pos);
if (in_pixels)
- return pos * PANGO_SCALE;
+ return pos * PANGO_SCALE;
else
- return pos;
+ return pos;
}
if (n_tabs > 0)
pango_tab_array_get_tab (layout->tabs, n_tabs - 1, NULL, &last_pos);
if (n_tabs > 1)
- pango_tab_array_get_tab (layout->tabs, n_tabs - 2, NULL, &next_to_last_pos);
+ pango_tab_array_get_tab (layout->tabs, n_tabs - 2, NULL, &next_to_last_pos);
else
- next_to_last_pos = 0;
+ next_to_last_pos = 0;
if (in_pixels)
{
length = g_utf8_offset_to_pointer (layout->text + item->offset, break_num_chars) - (layout->text + item->offset);
- new_item = pango_item_split (item, length, break_num_chars);
+ new_item = pango_item_split (item, length, break_num_chars);
insert_run (line, state, new_item, FALSE);
break;
case PANGO_GRAVITY_NORTH:
line->resolved_dir = PANGO_DIRECTION_LTR
- + PANGO_DIRECTION_RTL
+ + PANGO_DIRECTION_RTL
- line->resolved_dir;
break;
case PANGO_GRAVITY_EAST:
layout->is_wrapped = TRUE;
goto done;
- case BREAK_LINE_SEPARATOR:
- state->items = g_list_delete_link (state->items, state->items);
- state->start_offset += old_num_chars;
- goto done;
+ case BREAK_LINE_SEPARATOR:
+ state->items = g_list_delete_link (state->items, state->items);
+ state->start_offset += old_num_chars;
+ goto done;
}
}
static void
get_items_log_attrs (const char *text,
- GList *items,
- PangoLogAttr *log_attrs,
- int para_delimiter_len)
+ GList *items,
+ PangoLogAttr *log_attrs,
+ int para_delimiter_len)
{
int offset = 0;
int index = 0;
}
pango_break (text + index, tmp_item.length, &tmp_item.analysis,
- log_attrs + offset, tmp_item.num_chars + 1);
+ log_attrs + offset, tmp_item.num_chars + 1);
offset += tmp_item.num_chars;
index += tmp_item.length;
ParaBreakState state;
if (layout->single_paragraph)
- {
- delimiter_index = layout->length;
- next_para_index = layout->length;
- }
+ {
+ delimiter_index = layout->length;
+ next_para_index = layout->length;
+ }
else
- {
- pango_find_paragraph_boundary (start,
- (layout->text + layout->length) - start,
- &delimiter_index,
- &next_para_index);
- }
+ {
+ pango_find_paragraph_boundary (start,
+ (layout->text + layout->length) - start,
+ &delimiter_index,
+ &next_para_index);
+ }
g_assert (next_para_index >= delimiter_index);
iter);
get_items_log_attrs (start, state.items,
- layout->log_attrs + start_offset,
- delim_len);
+ layout->log_attrs + start_offset,
+ delim_len);
if (state.items)
{
state.first_line = TRUE;
state.base_dir = base_dir;
state.start_offset = start_offset;
- state.line_start_index = start - layout->text;
+ state.line_start_index = start - layout->text;
state.glyphs = NULL;
state.log_widths = NULL;
while (state.items)
- process_line (layout, &state);
+ process_line (layout, &state);
}
else
- {
- PangoLayoutLine *empty_line;
+ {
+ PangoLayoutLine *empty_line;
- empty_line = pango_layout_line_new (layout);
- empty_line->start_index = start - layout->text;
+ empty_line = pango_layout_line_new (layout);
+ empty_line->start_index = start - layout->text;
empty_line->is_paragraph_start = TRUE;
line_set_resolved_dir (empty_line, base_dir);
- layout->lines = g_slist_prepend (layout->lines,
- empty_line);
- }
+ layout->lines = g_slist_prepend (layout->lines,
+ empty_line);
+ }
if (!done)
- start_offset += g_utf8_strlen (start, (end - start) + delim_len);
+ start_offset += g_utf8_strlen (start, (end - start) + delim_len);
start = end + delim_len;
}
if (our_type == 0)
our_type = g_boxed_type_register_static (I_("PangoLayoutLine"),
- (GBoxedCopyFunc) pango_layout_line_ref,
- (GBoxedFreeFunc) pango_layout_line_unref);
+ (GBoxedCopyFunc) pango_layout_line_ref,
+ (GBoxedFreeFunc) pango_layout_line_unref);
return our_type;
}
static void
pango_layout_run_get_extents (PangoLayoutRun *run,
- PangoRectangle *run_ink,
- PangoRectangle *run_logical)
+ PangoRectangle *run_ink,
+ PangoRectangle *run_logical)
{
PangoRectangle logical;
ItemProperties properties;
*/
if (properties.strikethrough)
- {
+ {
if (run_ink->height == 0)
{
run_ink->height = strikethrough_thickness;
if (properties.rise != 0)
{
if (run_ink)
- run_ink->y -= properties.rise;
+ run_ink->y -= properties.rise;
if (run_logical)
run_logical->y -= properties.rise;
}
case NOT_CACHED:
{
- caching = TRUE;
+ caching = TRUE;
if (!ink_rect)
ink_rect = &private->ink_rect;
if (!logical_rect)
}
case LEAKED:
{
- break;
+ break;
}
}
PangoRectangle run_logical;
pango_layout_run_get_extents (run,
- ink_rect ? &run_ink : NULL,
- &run_logical);
+ ink_rect ? &run_ink : NULL,
+ &run_logical);
if (ink_rect)
{
properties->strikethrough = ((PangoAttrInt *)attr)->value;
break;
- case PANGO_ATTR_RISE:
+ case PANGO_ATTR_RISE:
properties->rise = ((PangoAttrInt *)attr)->value;
- break;
+ break;
case PANGO_ATTR_LETTER_SPACING:
properties->letter_spacing = ((PangoAttrInt *)attr)->value;
static int
next_cluster_start (PangoGlyphString *gs,
- int cluster_start)
+ int cluster_start)
{
int i;
while (i < gs->num_glyphs)
{
if (gs->glyphs[i].attr.is_cluster_start)
- return i;
+ return i;
i++;
}
while (i < gs->num_glyphs)
{
if (gs->glyphs[i].attr.is_cluster_start)
- break;
+ break;
width += gs->glyphs[i].geometry.width;
i++;
static inline void
offset_y (PangoLayoutIter *iter,
- int *y)
+ int *y)
{
Extents *line_ext;
iter->line_extents = NULL;
pango_layout_get_extents_internal (layout,
- NULL,
- &logical_rect,
- &iter->line_extents);
+ NULL,
+ &logical_rect,
+ &iter->line_extents);
iter->layout_width = layout->width == -1 ? logical_rect.width : layout->width;
iter->line_extents_link = iter->line_extents;
**/
void
pango_layout_iter_get_char_extents (PangoLayoutIter *iter,
- PangoRectangle *logical_rect)
+ PangoRectangle *logical_rect)
{
PangoRectangle cluster_rect;
int x0, x1;
**/
void
pango_layout_iter_get_cluster_extents (PangoLayoutIter *iter,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
{
if (ITER_IS_INVALID (iter))
return;
}
pango_glyph_string_extents_range (iter->run->glyphs,
- iter->cluster_start,
- iter->next_cluster_glyph,
- iter->run->item->analysis.font,
- ink_rect,
- logical_rect);
+ iter->cluster_start,
+ iter->next_cluster_glyph,
+ iter->run->item->analysis.font,
+ ink_rect,
+ logical_rect);
if (ink_rect)
{
**/
void
pango_layout_iter_get_run_extents (PangoLayoutIter *iter,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
{
if (G_UNLIKELY (!ink_rect && !logical_rect))
return;
pango_layout_iter_get_line_extents (iter, ink_rect, logical_rect);
if (ink_rect)
- {
- ink_rect->x = iter->run_x;
- ink_rect->width = 0;
- }
+ {
+ ink_rect->x = iter->run_x;
+ ink_rect->width = 0;
+ }
if (logical_rect)
{
**/
void
pango_layout_iter_get_line_extents (PangoLayoutIter *iter,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
{
Extents *ext;
if (ink_rect)
{
get_line_extents_layout_coords (iter->layout, iter->line,
- iter->layout_width,
- ext->logical_rect.y,
- NULL,
- ink_rect,
- NULL);
+ iter->layout_width,
+ ext->logical_rect.y,
+ NULL,
+ ink_rect,
+ NULL);
}
if (logical_rect)
**/
void
pango_layout_iter_get_line_yrange (PangoLayoutIter *iter,
- int *y0,
- int *y1)
+ int *y0,
+ int *y1)
{
Extents *ext;
int half_spacing;
/* No spacing above the first line */
if (iter->line_extents_link == iter->line_extents)
- *y0 = ext->logical_rect.y;
+ *y0 = ext->logical_rect.y;
else
- *y0 = ext->logical_rect.y - (iter->layout->spacing - half_spacing);
+ *y0 = ext->logical_rect.y - (iter->layout->spacing - half_spacing);
}
if (y1)
{
/* No spacing below the last line */
if (iter->line_extents_link->next == NULL)
- *y1 = ext->logical_rect.y + ext->logical_rect.height;
+ *y1 = ext->logical_rect.y + ext->logical_rect.height;
else
- *y1 = ext->logical_rect.y + ext->logical_rect.height + half_spacing;
+ *y1 = ext->logical_rect.y + ext->logical_rect.height + half_spacing;
}
}
**/
void
pango_layout_iter_get_layout_extents (PangoLayoutIter *iter,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
{
if (ITER_IS_INVALID (iter))
return;
const char *pango_layout_get_text (PangoLayout *layout);
void pango_layout_set_markup (PangoLayout *layout,
- const char *markup,
- int length);
+ const char *markup,
+ int length);
void pango_layout_set_markup_with_accel (PangoLayout *layout,
- const char *markup,
- int length,
- gunichar accel_marker,
- gunichar *accel_char);
+ const char *markup,
+ int length,
+ gunichar accel_marker,
+ gunichar *accel_char);
void pango_layout_set_font_description (PangoLayout *layout,
const PangoFontDescription *desc);
int width);
int pango_layout_get_width (PangoLayout *layout);
void pango_layout_set_wrap (PangoLayout *layout,
- PangoWrapMode wrap);
+ PangoWrapMode wrap);
PangoWrapMode pango_layout_get_wrap (PangoLayout *layout);
gboolean pango_layout_is_wrapped (PangoLayout *layout);
void pango_layout_set_indent (PangoLayout *layout,
PangoAlignment pango_layout_get_alignment (PangoLayout *layout);
void pango_layout_set_tabs (PangoLayout *layout,
- PangoTabArray *tabs);
+ PangoTabArray *tabs);
PangoTabArray* pango_layout_get_tabs (PangoLayout *layout);
void pango_layout_set_single_paragraph_mode (PangoLayout *layout,
- gboolean setting);
+ gboolean setting);
gboolean pango_layout_get_single_paragraph_mode (PangoLayout *layout);
void pango_layout_set_ellipsize (PangoLayout *layout,
int index_,
PangoRectangle *pos);
void pango_layout_index_to_line_x (PangoLayout *layout,
- int index_,
- gboolean trailing,
- int *line,
- int *x_pos);
+ int index_,
+ gboolean trailing,
+ int *line,
+ int *x_pos);
void pango_layout_get_cursor_pos (PangoLayout *layout,
int index_,
PangoRectangle *strong_pos,
gboolean pango_layout_iter_next_line (PangoLayoutIter *iter);
void pango_layout_iter_get_char_extents (PangoLayoutIter *iter,
- PangoRectangle *logical_rect);
+ PangoRectangle *logical_rect);
void pango_layout_iter_get_cluster_extents (PangoLayoutIter *iter,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect);
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
void pango_layout_iter_get_run_extents (PangoLayoutIter *iter,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect);
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
void pango_layout_iter_get_line_extents (PangoLayoutIter *iter,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect);
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
/* All the yranges meet, unlike the logical_rect's (i.e. the yranges
* assign between-line spacing to the nearest line)
*/
void pango_layout_iter_get_line_yrange (PangoLayoutIter *iter,
- int *y0_,
- int *y1_);
+ int *y0_,
+ int *y1_);
void pango_layout_iter_get_layout_extents (PangoLayoutIter *iter,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect);
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
int pango_layout_iter_get_baseline (PangoLayoutIter *iter);
G_END_DECLS
};
typedef gboolean (*TagParseFunc) (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean b_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean big_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean span_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean i_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean markup_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean s_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean sub_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean sup_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean small_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean tt_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static gboolean u_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error);
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error);
static double
scale_factor (int scale_level, double base)
{
i = 0;
while (i < scale_level)
- {
- factor *= 1.2;
+ {
+ factor *= 1.2;
- ++i;
- }
+ ++i;
+ }
}
else if (scale_level < 0)
{
i = scale_level;
while (i < 0)
- {
- factor /= 1.2;
+ {
+ factor /= 1.2;
- ++i;
- }
+ ++i;
+ }
}
return factor;
static void
open_tag_set_absolute_font_size (OpenTag *ot,
- int font_size)
+ int font_size)
{
ot->base_font_size = font_size;
ot->has_base_font_size = TRUE;
static void
open_tag_set_absolute_font_scale (OpenTag *ot,
- double scale)
+ double scale)
{
ot->base_scale_factor = scale;
ot->has_base_font_size = FALSE;
/* pop the stack */
ot = md->tag_stack->data;
md->tag_stack = g_slist_delete_link (md->tag_stack,
- md->tag_stack);
+ md->tag_stack);
/* Adjust end indexes, and push each attr onto the front of the
* to_apply list. This means that outermost tags are on the front of
PangoAttribute *a;
if (ot->has_base_font_size)
- {
- /* Create a font using the absolute point size
- * as the base size to be scaled from
- */
- a = pango_attr_size_new (scale_factor (ot->scale_level,
- 1.0) *
- ot->base_font_size);
- }
+ {
+ /* Create a font using the absolute point size
+ * as the base size to be scaled from
+ */
+ a = pango_attr_size_new (scale_factor (ot->scale_level,
+ 1.0) *
+ ot->base_font_size);
+ }
else
- {
- /* Create a font using the current scale factor
- * as the base size to be scaled from
- */
- a = pango_attr_scale_new (scale_factor (ot->scale_level,
- ot->base_scale_factor));
- }
+ {
+ /* Create a font using the current scale factor
+ * as the base size to be scaled from
+ */
+ a = pango_attr_scale_new (scale_factor (ot->scale_level,
+ ot->base_scale_factor));
+ }
a->start_index = ot->start_index;
a->end_index = md->index;
static void
start_element_handler (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error)
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error)
{
TagParseFunc parse_func = NULL;
OpenTag *ot;
{
case 'b':
if (strcmp ("b", element_name) == 0)
- parse_func = b_parse_func;
+ parse_func = b_parse_func;
else if (strcmp ("big", element_name) == 0)
- parse_func = big_parse_func;
+ parse_func = big_parse_func;
break;
case 'i':
if (strcmp ("i", element_name) == 0)
- parse_func = i_parse_func;
+ parse_func = i_parse_func;
break;
case 'm':
if (strcmp ("markup", element_name) == 0)
- parse_func = markup_parse_func;
+ parse_func = markup_parse_func;
break;
case 's':
if (strcmp ("span", element_name) == 0)
- parse_func = span_parse_func;
+ parse_func = span_parse_func;
else if (strcmp ("s", element_name) == 0)
- parse_func = s_parse_func;
+ parse_func = s_parse_func;
else if (strcmp ("sub", element_name) == 0)
- parse_func = sub_parse_func;
+ parse_func = sub_parse_func;
else if (strcmp ("sup", element_name) == 0)
- parse_func = sup_parse_func;
+ parse_func = sup_parse_func;
else if (strcmp ("small", element_name) == 0)
- parse_func = small_parse_func;
+ parse_func = small_parse_func;
break;
case 't':
if (strcmp ("tt", element_name) == 0)
- parse_func = tt_parse_func;
+ parse_func = tt_parse_func;
break;
case 'u':
if (strcmp ("u", element_name) == 0)
- parse_func = u_parse_func;
+ parse_func = u_parse_func;
break;
}
gint line_number, char_number;
g_markup_parse_context_get_position (context,
- &line_number, &char_number);
+ &line_number, &char_number);
g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_UNKNOWN_ELEMENT,
- _("Unknown tag '%s' on line %d char %d"),
- element_name,
- line_number, char_number);
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_UNKNOWN_ELEMENT,
+ _("Unknown tag '%s' on line %d char %d"),
+ element_name,
+ line_number, char_number);
return;
}
/* note ot may be NULL if the user didn't want the attribute list */
if (!(*parse_func) (user_data, ot,
- attribute_names, attribute_values,
- context, error))
+ attribute_names, attribute_values,
+ context, error))
{
/* there's nothing to do; we return an error, and end up
* freeing ot off the tag stack later.
static void
end_element_handler (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error)
{
markup_data_close_tag (user_data);
}
static void
text_handler (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error)
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
{
MarkupData *md = user_data;
end = text + text_len;
while (p != end)
- {
- gunichar c;
-
- c = g_utf8_get_char (p);
-
- if (range_end)
- {
- if (c == md->accel_marker)
- {
- /* escaped accel marker; move range_end
- * past the accel marker that came before,
- * append the whole thing
- */
- range_end = g_utf8_next_char (range_end);
- g_string_append_len (md->text,
- range_start,
- range_end - range_start);
- md->index += range_end - range_start;
-
- /* set next range_start, skipping accel marker */
- range_start = g_utf8_next_char (p);
- }
- else
- {
- /* Don't append the accel marker (leave range_end
- * alone); set the accel char to c; record location for
- * underline attribute
- */
- if (md->accel_char == 0)
- md->accel_char = c;
-
- g_string_append_len (md->text,
- range_start,
- range_end - range_start);
- md->index += range_end - range_start;
-
- /* The underline should go underneath the char
- * we're setting as the next range_start
- */
- uline_index = md->index;
- uline_len = g_utf8_next_char (p) - p;
-
- /* set next range_start to include this char */
- range_start = p;
- }
-
- /* reset range_end */
- range_end = NULL;
- }
- else if (c == md->accel_marker)
- {
- range_end = p;
- }
-
- p = g_utf8_next_char (p);
- }
+ {
+ gunichar c;
+
+ c = g_utf8_get_char (p);
+
+ if (range_end)
+ {
+ if (c == md->accel_marker)
+ {
+ /* escaped accel marker; move range_end
+ * past the accel marker that came before,
+ * append the whole thing
+ */
+ range_end = g_utf8_next_char (range_end);
+ g_string_append_len (md->text,
+ range_start,
+ range_end - range_start);
+ md->index += range_end - range_start;
+
+ /* set next range_start, skipping accel marker */
+ range_start = g_utf8_next_char (p);
+ }
+ else
+ {
+ /* Don't append the accel marker (leave range_end
+ * alone); set the accel char to c; record location for
+ * underline attribute
+ */
+ if (md->accel_char == 0)
+ md->accel_char = c;
+
+ g_string_append_len (md->text,
+ range_start,
+ range_end - range_start);
+ md->index += range_end - range_start;
+
+ /* The underline should go underneath the char
+ * we're setting as the next range_start
+ */
+ uline_index = md->index;
+ uline_len = g_utf8_next_char (p) - p;
+
+ /* set next range_start to include this char */
+ range_start = p;
+ }
+
+ /* reset range_end */
+ range_end = NULL;
+ }
+ else if (c == md->accel_marker)
+ {
+ range_end = p;
+ }
+
+ p = g_utf8_next_char (p);
+ }
if (range_end)
- {
- g_string_append_len (md->text,
- range_start,
- range_end - range_start);
- md->index += range_end - range_start;
- }
+ {
+ g_string_append_len (md->text,
+ range_start,
+ range_end - range_start);
+ md->index += range_end - range_start;
+ }
else
- {
- g_string_append_len (md->text,
- range_start,
- end - range_start);
- md->index += end - range_start;
- }
+ {
+ g_string_append_len (md->text,
+ range_start,
+ end - range_start);
+ md->index += end - range_start;
+ }
if (md->attr_list != NULL && uline_index >= 0)
- {
- /* Add the underline indicating the accelerator */
- PangoAttribute *attr;
+ {
+ /* Add the underline indicating the accelerator */
+ PangoAttribute *attr;
- attr = pango_attr_underline_new (PANGO_UNDERLINE_LOW);
+ attr = pango_attr_underline_new (PANGO_UNDERLINE_LOW);
- attr->start_index = uline_index;
- attr->end_index = uline_index + uline_len;
+ attr->start_index = uline_index;
+ attr->end_index = uline_index + uline_len;
- pango_attr_list_change (md->attr_list, attr);
- }
+ pango_attr_list_change (md->attr_list, attr);
+ }
}
}
**/
gboolean
pango_parse_markup (const char *markup_text,
- int length,
- gunichar accel_marker,
- PangoAttrList **attr_list,
- char **text,
- gunichar *accel_char,
- GError **error)
+ int length,
+ gunichar accel_marker,
+ PangoAttrList **attr_list,
+ char **text,
+ gunichar *accel_char,
+ GError **error)
{
GMarkupParseContext *context = NULL;
MarkupData *md = NULL;
md->to_apply = NULL;
context = g_markup_parse_context_new (&pango_markup_parser,
- 0, md, NULL);
+ 0, md, NULL);
if (length < 0)
length = strlen (markup_text);
if (needs_root)
if (!g_markup_parse_context_parse (context,
- "<markup>",
- -1,
- error))
+ "<markup>",
+ -1,
+ error))
goto error;
if (!g_markup_parse_context_parse (context,
- markup_text,
- length,
- error))
+ markup_text,
+ length,
+ error))
goto error;
if (needs_root)
if (!g_markup_parse_context_parse (context,
- "</markup>",
- -1,
- error))
+ "</markup>",
+ -1,
+ error))
goto error;
if (!g_markup_parse_context_end_parse (context, error))
*/
tmp_list = md->to_apply;
while (tmp_list != NULL)
- {
- PangoAttribute *attr = tmp_list->data;
+ {
+ PangoAttribute *attr = tmp_list->data;
- /* Innermost tags before outermost */
- pango_attr_list_change (md->attr_list, attr);
+ /* Innermost tags before outermost */
+ pango_attr_list_change (md->attr_list, attr);
- tmp_list = g_slist_next (tmp_list);
- }
+ tmp_list = g_slist_next (tmp_list);
+ }
g_slist_free (md->to_apply);
md->to_apply = NULL;
}
static void
set_bad_attribute (GError **error,
- GMarkupParseContext *context,
- const char *element_name,
- const char *attribute_name)
+ GMarkupParseContext *context,
+ const char *element_name,
+ const char *attribute_name)
{
gint line_number, char_number;
g_markup_parse_context_get_position (context,
- &line_number, &char_number);
+ &line_number, &char_number);
g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
- _("Tag '%s' does not support attribute '%s' on line %d char %d"),
- element_name,
- attribute_name,
- line_number, char_number);
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
+ _("Tag '%s' does not support attribute '%s' on line %d char %d"),
+ element_name,
+ attribute_name,
+ line_number, char_number);
}
static void
add_attribute (OpenTag *ot,
- PangoAttribute *attr)
+ PangoAttribute *attr)
{
if (ot == NULL)
pango_attribute_destroy (attr);
}
#define CHECK_NO_ATTRS(elem) G_STMT_START { \
- if (*names != NULL) { \
- set_bad_attribute (error, context, (elem), *names); \
- return FALSE; \
- } }G_STMT_END
+ if (*names != NULL) { \
+ set_bad_attribute (error, context, (elem), *names); \
+ return FALSE; \
+ } }G_STMT_END
static gboolean
b_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("b");
add_attribute (tag, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
static gboolean
big_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("big");
static gboolean
parse_absolute_size (OpenTag *tag,
- const char *size)
+ const char *size)
{
SizeLevel level = Medium;
double factor;
cb = *b++;
if (ca == cb)
- continue;
+ continue;
ca = ca == '_' ? '-' : ca;
cb = cb == '_' ? '-' : cb;
if (ca != cb)
- return cb - ca;
+ return cb - ca;
}
ca = *a;
strcmp (attr_val, "y") == 0)
*val = TRUE;
else if (strcmp (attr_val, "false") == 0 ||
- strcmp (attr_val, "no") == 0 ||
- strcmp (attr_val, "f") == 0 ||
- strcmp (attr_val, "n") == 0)
+ strcmp (attr_val, "no") == 0 ||
+ strcmp (attr_val, "f") == 0 ||
+ strcmp (attr_val, "n") == 0)
*val = FALSE;
else
{
static gboolean
span_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
int line_number, char_number;
int i;
const char *gravity_hint = NULL;
g_markup_parse_context_get_position (context,
- &line_number, &char_number);
+ &line_number, &char_number);
#define CHECK_DUPLICATE(var) G_STMT_START{ \
- if ((var) != NULL) { \
- g_set_error (error, G_MARKUP_ERROR, \
- G_MARKUP_ERROR_INVALID_CONTENT, \
- _("Attribute '%s' occurs twice on <span> tag " \
- "on line %d char %d, may only occur once"), \
- names[i], line_number, char_number); \
- return FALSE; \
- }}G_STMT_END
+ if ((var) != NULL) { \
+ g_set_error (error, G_MARKUP_ERROR, \
+ G_MARKUP_ERROR_INVALID_CONTENT, \
+ _("Attribute '%s' occurs twice on <span> tag " \
+ "on line %d char %d, may only occur once"), \
+ names[i], line_number, char_number); \
+ return FALSE; \
+ }}G_STMT_END
#define CHECK_ATTRIBUTE2(var, name) \
if (attr_strcmp (names[i], (name)) == 0) { \
CHECK_DUPLICATE (var); \
switch (names[i][0]) {
case 'f':
- CHECK_ATTRIBUTE2(family, "face");
- CHECK_ATTRIBUTE (fallback);
- CHECK_ATTRIBUTE2(desc, "font_desc");
- CHECK_ATTRIBUTE2(family, "font_family");
- CHECK_ATTRIBUTE (foreground);
+ CHECK_ATTRIBUTE2(family, "face");
+ CHECK_ATTRIBUTE (fallback);
+ CHECK_ATTRIBUTE2(desc, "font_desc");
+ CHECK_ATTRIBUTE2(family, "font_family");
+ CHECK_ATTRIBUTE (foreground);
break;
case 's':
- CHECK_ATTRIBUTE (size);
- CHECK_ATTRIBUTE (stretch);
- CHECK_ATTRIBUTE (strikethrough);
- CHECK_ATTRIBUTE (strikethrough_color);
- CHECK_ATTRIBUTE (style);
+ CHECK_ATTRIBUTE (size);
+ CHECK_ATTRIBUTE (stretch);
+ CHECK_ATTRIBUTE (strikethrough);
+ CHECK_ATTRIBUTE (strikethrough_color);
+ CHECK_ATTRIBUTE (style);
break;
case 'g':
- CHECK_ATTRIBUTE (gravity);
- CHECK_ATTRIBUTE (gravity_hint);
+ CHECK_ATTRIBUTE (gravity);
+ CHECK_ATTRIBUTE (gravity_hint);
break;
case 'l':
- CHECK_ATTRIBUTE (lang);
- CHECK_ATTRIBUTE (letter_spacing);
+ CHECK_ATTRIBUTE (lang);
+ CHECK_ATTRIBUTE (letter_spacing);
break;
case 'u':
- CHECK_ATTRIBUTE (underline);
- CHECK_ATTRIBUTE (underline_color);
+ CHECK_ATTRIBUTE (underline);
+ CHECK_ATTRIBUTE (underline_color);
break;
default:
- CHECK_ATTRIBUTE (background);
- CHECK_ATTRIBUTE2(foreground, "color");
- CHECK_ATTRIBUTE (rise);
- CHECK_ATTRIBUTE (variant);
- CHECK_ATTRIBUTE (weight);
+ CHECK_ATTRIBUTE (background);
+ CHECK_ATTRIBUTE2(foreground, "color");
+ CHECK_ATTRIBUTE (rise);
+ CHECK_ATTRIBUTE (variant);
+ CHECK_ATTRIBUTE (weight);
break;
}
if (!found)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
- _("Attribute '%s' is not allowed on the <span> tag "
- "on line %d char %d"),
- names[i], line_number, char_number);
- return FALSE;
- }
+ {
+ g_set_error (error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
+ _("Attribute '%s' is not allowed on the <span> tag "
+ "on line %d char %d"),
+ names[i], line_number, char_number);
+ return FALSE;
+ }
++i;
}
parsed = pango_font_description_from_string (desc);
if (parsed)
- {
- add_attribute (tag, pango_attr_font_desc_new (parsed));
+ {
+ add_attribute (tag, pango_attr_font_desc_new (parsed));
if (tag)
open_tag_set_absolute_font_size (tag, pango_font_description_get_size (parsed));
- pango_font_description_free (parsed);
- }
+ pango_font_description_free (parsed);
+ }
}
if (G_UNLIKELY (family))
if (G_UNLIKELY (size))
{
if (g_ascii_isdigit (*size))
- {
- char *end = NULL;
- gulong n;
-
- n = strtoul (size, &end, 10);
-
- if (*end != '\0' || n < 0 || n > 1000000)
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- _("Value of 'size' attribute on <span> tag on line %d"
- "could not be parsed; should be an integer, or a "
- "string such as 'small', not '%s'"),
- line_number, size);
- goto error;
- }
-
- add_attribute (tag, pango_attr_size_new (n));
+ {
+ char *end = NULL;
+ gulong n;
+
+ n = strtoul (size, &end, 10);
+
+ if (*end != '\0' || n < 0 || n > 1000000)
+ {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ _("Value of 'size' attribute on <span> tag on line %d"
+ "could not be parsed; should be an integer, or a "
+ "string such as 'small', not '%s'"),
+ line_number, size);
+ goto error;
+ }
+
+ add_attribute (tag, pango_attr_size_new (n));
if (tag)
open_tag_set_absolute_font_size (tag, n);
- }
+ }
else if (strcmp (size, "smaller") == 0)
- {
+ {
if (tag)
{
tag->scale_level_delta -= 1;
tag->scale_level -= 1;
}
- }
+ }
else if (strcmp (size, "larger") == 0)
- {
+ {
if (tag)
{
tag->scale_level_delta += 1;
tag->scale_level += 1;
}
- }
+ }
else if (parse_absolute_size (tag, size))
- ; /* nothing */
+ ; /* nothing */
else
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- _("Value of 'size' attribute on <span> tag on line %d"
- "could not be parsed; should be an integer, or a "
- "string such as 'small', not '%s'"),
- line_number, size);
- goto error;
- }
+ {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ _("Value of 'size' attribute on <span> tag on line %d"
+ "could not be parsed; should be an integer, or a "
+ "string such as 'small', not '%s'"),
+ line_number, size);
+ goto error;
+ }
}
if (G_UNLIKELY (style))
PangoStyle pango_style;
if (pango_parse_style (style, &pango_style, FALSE))
- add_attribute (tag, pango_attr_style_new (pango_style));
+ add_attribute (tag, pango_attr_style_new (pango_style));
else
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- _("'%s' is not a valid value for the 'style' attribute "
- "on <span> tag, line %d; valid values are "
- "'normal', 'oblique', 'italic'"),
- style, line_number);
- goto error;
- }
+ {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ _("'%s' is not a valid value for the 'style' attribute "
+ "on <span> tag, line %d; valid values are "
+ "'normal', 'oblique', 'italic'"),
+ style, line_number);
+ goto error;
+ }
}
if (G_UNLIKELY (weight))
PangoWeight pango_weight;
if (pango_parse_weight (weight, &pango_weight, FALSE))
- add_attribute (tag,
- pango_attr_weight_new (pango_weight));
+ add_attribute (tag,
+ pango_attr_weight_new (pango_weight));
else
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- _("'%s' is not a valid value for the 'weight' "
- "attribute on <span> tag, line %d; valid "
- "values are for example 'light', 'ultrabold' or a number"),
- weight, line_number);
- goto error;
- }
+ {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ _("'%s' is not a valid value for the 'weight' "
+ "attribute on <span> tag, line %d; valid "
+ "values are for example 'light', 'ultrabold' or a number"),
+ weight, line_number);
+ goto error;
+ }
}
if (G_UNLIKELY (variant))
PangoVariant pango_variant;
if (pango_parse_variant (variant, &pango_variant, FALSE))
- add_attribute (tag, pango_attr_variant_new (pango_variant));
+ add_attribute (tag, pango_attr_variant_new (pango_variant));
else
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- _("'%s' is not a valid value for the 'variant' "
- "attribute on <span> tag, line %d; valid values are "
- "'normal', 'smallcaps'"),
- variant, line_number);
- goto error;
- }
+ {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ _("'%s' is not a valid value for the 'variant' "
+ "attribute on <span> tag, line %d; valid values are "
+ "'normal', 'smallcaps'"),
+ variant, line_number);
+ goto error;
+ }
}
if (G_UNLIKELY (stretch))
PangoStretch pango_stretch;
if (pango_parse_stretch (stretch, &pango_stretch, FALSE))
- add_attribute (tag, pango_attr_stretch_new (pango_stretch));
+ add_attribute (tag, pango_attr_stretch_new (pango_stretch));
else
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- _("'%s' is not a valid value for the 'stretch' "
- "attribute on <span> tag, line %d; valid "
- "values are for example 'condensed', "
- "'ultraexpanded', 'normal'"),
- stretch, line_number);
- goto error;
- }
+ {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ _("'%s' is not a valid value for the 'stretch' "
+ "attribute on <span> tag, line %d; valid "
+ "values are for example 'condensed', "
+ "'ultraexpanded', 'normal'"),
+ stretch, line_number);
+ goto error;
+ }
}
if (G_UNLIKELY (foreground))
PangoColor color;
if (!span_parse_color ("foreground", foreground, &color, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_foreground_new (color.red, color.green, color.blue));
}
PangoColor color;
if (!span_parse_color ("background", background, &color, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_background_new (color.red, color.green, color.blue));
}
PangoUnderline ul = PANGO_UNDERLINE_NONE;
if (!span_parse_enum ("underline", underline, PANGO_TYPE_UNDERLINE, &ul, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_underline_new (ul));
}
PangoColor color;
if (!span_parse_color ("underline_color", underline_color, &color, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_underline_color_new (color.red, color.green, color.blue));
}
PangoGravity gr = PANGO_GRAVITY_SOUTH;
if (!span_parse_enum ("gravity", gravity, PANGO_TYPE_GRAVITY, &gr, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_gravity_new (gr));
}
PangoGravityHint hint = PANGO_GRAVITY_HINT_NATURAL;
if (!span_parse_enum ("gravity_hint", gravity_hint, PANGO_TYPE_GRAVITY_HINT, &hint, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_gravity_hint_new (hint));
}
gboolean b = FALSE;
if (!span_parse_boolean ("strikethrough", strikethrough, &b, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_strikethrough_new (b));
}
PangoColor color;
if (!span_parse_color ("strikethrough_color", strikethrough_color, &color, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_strikethrough_color_new (color.red, color.green, color.blue));
}
gboolean b = FALSE;
if (!span_parse_boolean ("fallback", fallback, &b, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_fallback_new (b));
}
gint n = 0;
if (!span_parse_int ("rise", rise, &n, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_rise_new (n));
}
gint n = 0;
if (!span_parse_int ("letter_spacing", letter_spacing, &n, line_number, error))
- goto error;
+ goto error;
add_attribute (tag, pango_attr_letter_spacing_new (n));
}
static gboolean
i_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("i");
add_attribute (tag, pango_attr_style_new (PANGO_STYLE_ITALIC));
static gboolean
markup_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
/* We don't do anything with this tag at the moment. */
static gboolean
s_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("s");
add_attribute (tag, pango_attr_strikethrough_new (TRUE));
static gboolean
sub_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("sub");
static gboolean
sup_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("sup");
static gboolean
small_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("small");
static gboolean
tt_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("tt");
static gboolean
u_parse_func (MarkupData *md,
- OpenTag *tag,
- const gchar **names,
- const gchar **values,
- GMarkupParseContext *context,
- GError **error)
+ OpenTag *tag,
+ const gchar **names,
+ const gchar **values,
+ GMarkupParseContext *context,
+ GError **error)
{
CHECK_NO_ATTRS("u");
add_attribute (tag, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
{
const GTypeInfo object_info =
{
- sizeof (PangoOTInfoClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc)pango_ot_info_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoOTInfo),
- 0, /* n_preallocs */
+ sizeof (PangoOTInfoClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc)pango_ot_info_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoOTInfo),
+ 0, /* n_preallocs */
NULL, /* init */
NULL, /* value_table */
};
object_type = g_type_register_static (G_TYPE_OBJECT,
- I_("PangoOTInfo"),
- &object_info, 0);
+ I_("PangoOTInfo"),
+ &object_info, 0);
}
return object_type;
{
const GTypeInfo object_info =
{
- sizeof (PangoOTRulesetClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc)pango_ot_ruleset_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoOTRuleset),
- 0, /* n_preallocs */
- (GInstanceInitFunc)pango_ot_ruleset_init,
+ sizeof (PangoOTRulesetClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc)pango_ot_ruleset_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoOTRuleset),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc)pango_ot_ruleset_init,
NULL /* value_table */
};
object_type = g_type_register_static (G_TYPE_OBJECT,
- I_("PangoOTRuleset"),
- &object_info, 0);
+ I_("PangoOTRuleset"),
+ &object_info, 0);
}
return object_type;
continue;
if (!gpos)
- {
+ {
gpos = pango_ot_info_get_gpos (ruleset->info);
if (gpos)
HB_GPOS_Clear_Features (gpos);
else
return;
- }
+ }
HB_GPOS_Add_Feature (gpos, rule->feature_index, rule->property_bit);
}
*shape_attr = (PangoAttrShape *)attr;
break;
- case PANGO_ATTR_RISE:
- if (rise)
- *rise = ((PangoAttrInt *)attr)->value;
- break;
+ case PANGO_ATTR_RISE:
+ if (rise)
+ *rise = ((PangoAttrInt *)attr)->value;
+ break;
default:
break;
PangoRectangle logical_rect, *logical = NULL;
if (run->item->analysis.flags & PANGO_ANALYSIS_FLAG_CENTERED_BASELINE)
- logical = &logical_rect;
+ logical = &logical_rect;
pango_renderer_prepare_run (renderer, run);
state.logical_rect_end = x + x_off + glyph_string_width;
if (run->item->analysis.flags & PANGO_ANALYSIS_FLAG_CENTERED_BASELINE)
- rise += logical_rect.y + logical_rect.height / 2;
+ rise += logical_rect.y + logical_rect.height / 2;
if (renderer->priv->color_set[PANGO_RENDER_PART_BACKGROUND])
if (iter->paren_sp < start_sp)
start_sp = iter->paren_sp;
- }
+ }
}
else
{
struct _PangoTab
{
gint location; /* Offset in pixels of this tab stop
- * from the left margin of the text.
- */
+ * from the left margin of the text.
+ */
PangoTabAlign alignment; /* Where the tab stop appears relative
- * to the text.
- */
+ * to the text.
+ */
};
struct _PangoTabArray
**/
PangoTabArray*
pango_tab_array_new (gint initial_size,
- gboolean positions_in_pixels)
+ gboolean positions_in_pixels)
{
PangoTabArray *array;
**/
PangoTabArray *
pango_tab_array_new_with_positions (gint size,
- gboolean positions_in_pixels,
- PangoTabAlign first_alignment,
- gint first_position,
- ...)
+ gboolean positions_in_pixels,
+ PangoTabAlign first_alignment,
+ gint first_position,
+ ...)
{
PangoTabArray *array;
va_list args;
if (our_type == 0)
our_type = g_boxed_type_register_static (I_("PangoTabArray"),
- (GBoxedCopyFunc)pango_tab_array_copy,
- (GBoxedFreeFunc)pango_tab_array_free);
+ (GBoxedCopyFunc)pango_tab_array_copy,
+ (GBoxedFreeFunc)pango_tab_array_free);
return our_type;
}
**/
void
pango_tab_array_resize (PangoTabArray *tab_array,
- gint new_size)
+ gint new_size)
{
if (new_size > tab_array->allocated)
{
/* Ratchet allocated size up above the index. */
if (tab_array->allocated == 0)
- tab_array->allocated = 2;
+ tab_array->allocated = 2;
while (new_size > tab_array->allocated)
- tab_array->allocated = tab_array->allocated * 2;
+ tab_array->allocated = tab_array->allocated * 2;
tab_array->tabs = g_renew (PangoTab, tab_array->tabs,
tab_array->allocated);
**/
void
pango_tab_array_set_tab (PangoTabArray *tab_array,
- gint tab_index,
- PangoTabAlign alignment,
- gint location)
+ gint tab_index,
+ PangoTabAlign alignment,
+ gint location)
{
g_return_if_fail (tab_array != NULL);
g_return_if_fail (tab_index >= 0);
**/
void
pango_tab_array_get_tab (PangoTabArray *tab_array,
- gint tab_index,
- PangoTabAlign *alignment,
- gint *location)
+ gint tab_index,
+ PangoTabAlign *alignment,
+ gint *location)
{
g_return_if_fail (tab_array != NULL);
g_return_if_fail (tab_index < tab_array->size);
**/
void
pango_tab_array_get_tabs (PangoTabArray *tab_array,
- PangoTabAlign **alignments,
- gint **locations)
+ PangoTabAlign **alignments,
+ gint **locations)
{
gint i;
while (i < tab_array->size)
{
if (alignments)
- (*alignments)[i] = tab_array->tabs[i].alignment;
+ (*alignments)[i] = tab_array->tabs[i].alignment;
if (locations)
- (*locations)[i] = tab_array->tabs[i].location;
+ (*locations)[i] = tab_array->tabs[i].location;
++i;
}
#define PANGO_TYPE_TAB_ARRAY (pango_tab_array_get_type ())
PangoTabArray *pango_tab_array_new (gint initial_size,
- gboolean positions_in_pixels);
+ gboolean positions_in_pixels);
PangoTabArray *pango_tab_array_new_with_positions (gint size,
- gboolean positions_in_pixels,
- PangoTabAlign first_alignment,
- gint first_position,
- ...);
+ gboolean positions_in_pixels,
+ PangoTabAlign first_alignment,
+ gint first_position,
+ ...);
GType pango_tab_array_get_type (void);
PangoTabArray *pango_tab_array_copy (PangoTabArray *src);
void pango_tab_array_free (PangoTabArray *tab_array);
gint pango_tab_array_get_size (PangoTabArray *tab_array);
void pango_tab_array_resize (PangoTabArray *tab_array,
- gint new_size);
+ gint new_size);
void pango_tab_array_set_tab (PangoTabArray *tab_array,
- gint tab_index,
- PangoTabAlign alignment,
- gint location);
+ gint tab_index,
+ PangoTabAlign alignment,
+ gint location);
void pango_tab_array_get_tab (PangoTabArray *tab_array,
- gint tab_index,
- PangoTabAlign *alignment,
- gint *location);
+ gint tab_index,
+ PangoTabAlign *alignment,
+ gint *location);
void pango_tab_array_get_tabs (PangoTabArray *tab_array,
- PangoTabAlign **alignments,
- gint **locations);
+ PangoTabAlign **alignments,
+ gint **locations);
gboolean pango_tab_array_get_positions_in_pixels (PangoTabArray *tab_array);
**/
const gchar*
pango_version_check (int required_major,
- int required_minor,
- int required_micro)
+ int required_minor,
+ int required_micro)
{
gint pango_effective_micro = 100 * PANGO_VERSION_MINOR + PANGO_VERSION_MICRO;
gint required_effective_micro = 100 * required_minor + required_micro;
if (v)
{
if (G_LIKELY (value))
- *value = v->value;
+ *value = v->value;
}
else
{
ret = FALSE;
if (warn || possible_values)
- {
+ {
int i;
GString *s = g_string_new (NULL);
i++ , v = g_enum_get_value (class, i))
{
if (i)
- g_string_append_c (s, '/');
+ g_string_append_c (s, '/');
g_string_append (s, v->value_nick);
}
if (our_type == 0)
our_type = g_boxed_type_register_static (I_("PangoLanguage"),
- (GBoxedCopyFunc)pango_language_copy,
- (GBoxedFreeFunc)pango_language_free);
+ (GBoxedCopyFunc)pango_language_copy,
+ (GBoxedFreeFunc)pango_language_free);
return our_type;
}
/* Check that run-time Pango is as new as required */
G_CONST_RETURN char * pango_version_check (int required_major,
- int required_minor,
- int required_micro);
+ int required_minor,
+ int required_micro);
G_END_DECLS
{
const GTypeInfo object_info =
{
- sizeof (PangoFontFamilyClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_atsui_family_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoATSUIFamily),
- 0, /* n_preallocs */
- (GInstanceInitFunc) pango_atsui_family_init,
+ sizeof (PangoFontFamilyClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_atsui_family_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoATSUIFamily),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) pango_atsui_family_init,
};
object_type = g_type_register_static (PANGO_TYPE_FONT_FAMILY,
- I_("PangoATSUIFamily"),
- &object_info, 0);
+ I_("PangoATSUIFamily"),
+ &object_info, 0);
}
return object_type;
static void
pango_atsui_face_list_sizes (PangoFontFace *face,
- int **sizes,
- int *n_sizes)
+ int **sizes,
+ int *n_sizes)
{
*n_sizes = 0;
*sizes = NULL;
{
const GTypeInfo object_info =
{
- sizeof (PangoFontFaceClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_atsui_face_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoATSUIFace),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
+ sizeof (PangoFontFaceClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_atsui_face_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoATSUIFace),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (PANGO_TYPE_FONT_FACE,
- I_("PangoATSUIFace"),
- &object_info, 0);
+ I_("PangoATSUIFace"),
+ &object_info, 0);
}
return object_type;
}
if (best_desc == NULL || best_face == NULL)
- return NULL;
+ return NULL;
pango_font_description_set_size (best_desc, size);
ink_rect->x = ink_rect->y = ink_rect->width = ink_rect->height = 0;
}
if (logical_rect)
- {
+ {
logical_rect->x = 0;
logical_rect->y = - font_extents.ascent * PANGO_SCALE;
logical_rect->width = 0;
* This means out of memory or a cairo/fontconfig/FreeType bug,
*/
if (!cffont->font_face)
- return NULL;
+ return NULL;
}
return cffont->font_face;
font_face = pango_cairo_fc_font_get_font_face (font);
if (!font_face)
- return NULL;
+ return NULL;
cffont->scaled_font = cairo_scaled_font_create (font_face,
&cffont->font_matrix,
* or a missing font...
*/
if (!cffont->scaled_font)
- return NULL;
+ return NULL;
}
return cffont->scaled_font;
}
shift = (height - info->metrics->ascent) - info->metrics->descent;
if (fcfont->is_hinted)
- shift &= ~(PANGO_SCALE - 1);
+ shift &= ~(PANGO_SCALE - 1);
info->metrics->descent += shift;
info->metrics->underline_position -= shift;
info->metrics->strikethrough_position -= shift;
default:
case PANGO_GRAVITY_AUTO:
case PANGO_GRAVITY_SOUTH:
- cffont->font_extents.y = - pango_units_from_double (font_extents.ascent);
+ cffont->font_extents.y = - pango_units_from_double (font_extents.ascent);
break;
case PANGO_GRAVITY_NORTH:
- cffont->font_extents.y = - pango_units_from_double (font_extents.descent);
+ cffont->font_extents.y = - pango_units_from_double (font_extents.descent);
break;
case PANGO_GRAVITY_EAST:
case PANGO_GRAVITY_WEST:
- cffont->font_extents.y = - pango_units_from_double ((font_extents.ascent + font_extents.descent) * 0.5);
+ cffont->font_extents.y = - pango_units_from_double ((font_extents.ascent + font_extents.descent) * 0.5);
}
cffont->glyph_extents_cache = g_new0 (GlyphExtentsCacheEntry, GLYPH_CACHE_NUM_ENTRIES);
if (G_UNLIKELY (!PANGO_IS_CAIRO_FONT (font)))
{
if (!_pango_cairo_warning_history.font_install)
- {
+ {
_pango_cairo_warning_history.font_install = TRUE;
g_warning ("_pango_cairo_font_install called with bad font, expect ugly output");
cairo_set_font_face (cr, NULL);
if (G_UNLIKELY (!PANGO_IS_CAIRO_FONT (font)))
{
if (!_pango_cairo_warning_history.font_get_scaled_font)
- {
+ {
_pango_cairo_warning_history.font_get_scaled_font = TRUE;
g_warning ("_pango_cairo_font_get_scaled_font called with bad font, expect ugly output");
}
void
_pango_cairo_get_glyph_extents_missing (PangoCairoFont *cfont,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+ PangoGlyph glyph,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
{
PangoCairoHexBoxInfo *hbi;
gint rows, cols;
PangoGlyphInfo *gi = &glyphs->glyphs[i];
if (gi->glyph != PANGO_GLYPH_EMPTY)
- {
- double cx = base_x + (double)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
- double cy = gi->geometry.y_offset == 0 ?
+ {
+ double cx = base_x + (double)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
+ double cy = gi->geometry.y_offset == 0 ?
base_y :
base_y + (double)(gi->geometry.y_offset) / PANGO_SCALE;
- if (gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+ if (gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG)
_pango_cairo_renderer_draw_unknown_glyph (crenderer, font, gi, cx, cy);
- else
- {
- cairo_glyphs[count].index = gi->glyph;
- cairo_glyphs[count].x = cx;
- cairo_glyphs[count].y = cy;
- count++;
- }
- }
+ else
+ {
+ cairo_glyphs[count].index = gi->glyph;
+ cairo_glyphs[count].x = cx;
+ cairo_glyphs[count].y = cy;
+ count++;
+ }
+ }
x_position += gi->geometry.width;
}
if (G_LIKELY (G_TRYLOCK (cached_renderer)))
{
if (G_UNLIKELY (!cached_renderer))
- cached_renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL);
+ cached_renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL);
renderer = cached_renderer;
*free_renderer = FALSE;
**/
void
pango_cairo_show_error_underline (cairo_t *cr,
- double x,
- double y,
- double width,
- double height)
+ double x,
+ double y,
+ double width,
+ double height)
{
g_return_if_fail (cr != NULL);
g_return_if_fail ((width >= 0) && (height >= 0));
**/
void
pango_cairo_error_underline_path (cairo_t *cr,
- double x,
- double y,
- double width,
- double height)
+ double x,
+ double y,
+ double width,
+ double height)
{
g_return_if_fail (cr != NULL);
g_return_if_fail ((width >= 0) && (height >= 0));
PangoLayoutLine *line = l->data;
for (r = line->runs; r; r = r->next)
- {
- PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
- int i;
-
- for (i = 0; i < glyphs->num_glyphs; i++)
- if (glyphs->glyphs[i].geometry.width > max_width)
- max_width = glyphs->glyphs[i].geometry.width;
- }
+ {
+ PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
+ int i;
+
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ if (glyphs->glyphs[i].geometry.width > max_width)
+ max_width = glyphs->glyphs[i].geometry.width;
+ }
}
return max_width;
PangoLayoutLine *line = l->data;
for (r = line->runs; r; r = r->next)
- {
- PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
- int i;
-
- for (i = 0; i < glyphs->num_glyphs; i++)
- if (glyphs->glyphs[i].geometry.width > max_width)
- max_width = glyphs->glyphs[i].geometry.width;
- }
+ {
+ PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
+ int i;
+
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ if (glyphs->glyphs[i].geometry.width > max_width)
+ max_width = glyphs->glyphs[i].geometry.width;
+ }
}
return max_width;
*/
static PangoFontMetrics *
pango_fc_font_get_metrics (PangoFont *font,
- PangoLanguage *language)
+ PangoLanguage *language)
{
PangoFcFont *fcfont = PANGO_FC_FONT (font);
PangoFcMetricsInfo *info = NULL; /* Quiet gcc */
FcCharSet *charset;
if (FcPatternGetCharSet (font->font_pattern,
- FC_CHARSET, 0, &charset) != FcResultMatch)
+ FC_CHARSET, 0, &charset) != FcResultMatch)
return FALSE;
return FcCharSetHasChar (charset, wc);
face = PANGO_FC_FONT_LOCK_FACE (font);
index = FcFreeTypeCharIndex (face, wc);
if (index > (FT_UInt)face->num_glyphs)
- index = 0;
+ index = 0;
entry->ch = wc;
entry->glyph = index;
registered_modules = TRUE;
for (i = 0; _pango_included_fc_modules[i].list; i++)
- pango_module_register (&_pango_included_fc_modules[i]);
+ pango_module_register (&_pango_included_fc_modules[i]);
}
priv->n_families = -1;
static PangoFcFamily *
create_family (PangoFcFontMap *fcfontmap,
const char *family_name,
- int spacing)
+ int spacing)
{
PangoFcFamily *family = g_object_new (PANGO_FC_TYPE_FAMILY, NULL);
family->fontmap = fcfontmap;
{
FcChar8 *s;
FcResult res;
- int spacing;
+ int spacing;
res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **) &s);
g_assert (res == FcResultMatch);
- res = FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &spacing);
- g_assert (res == FcResultMatch || res == FcResultNoMatch);
- if (res == FcResultNoMatch)
- spacing = FC_PROPORTIONAL;
+ res = FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &spacing);
+ g_assert (res == FcResultMatch || res == FcResultNoMatch);
+ if (res == FcResultNoMatch)
+ spacing = FC_PROPORTIONAL;
if (!is_alias_family (s) && !g_hash_table_lookup (temp_family_hash, s))
- {
- PangoFcFamily *temp_family = create_family (fcfontmap, (gchar *)s, spacing);
- g_hash_table_insert (temp_family_hash, g_strdup (s), s);
- priv->families[count++] = temp_family;
- }
+ {
+ PangoFcFamily *temp_family = create_family (fcfontmap, (gchar *)s, spacing);
+ g_hash_table_insert (temp_family_hash, g_strdup (s), s);
+ priv->families[count++] = temp_family;
+ }
}
FcFontSetDestroy (fontset);
static int
compare_ints (gconstpointer ap,
- gconstpointer bp)
+ gconstpointer bp)
{
int a = *(int *)ap;
int b = *(int *)bp;
static void
pango_fc_face_list_sizes (PangoFontFace *face,
- int **sizes,
- int *n_sizes)
+ int **sizes,
+ int *n_sizes)
{
PangoFcFace *fcface = PANGO_FC_FACE (face);
FcPattern *pattern;
size_array = g_array_new (FALSE, FALSE, sizeof (int));
for (i = 0; i < fontset->nfont; i++)
- {
- if (FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
- {
- if (dpi < 0)
+ {
+ if (FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
+ {
+ if (dpi < 0)
dpi = pango_fc_font_map_get_resolution (fcface->family->fontmap, NULL);
- size_i = (int) (PANGO_SCALE * size * 72.0 / dpi);
- g_array_append_val (size_array, size_i);
- }
- }
+ size_i = (int) (PANGO_SCALE * size * 72.0 / dpi);
+ g_array_append_val (size_array, size_i);
+ }
+ }
g_array_sort (size_array, compare_ints);
if (size_array->len == 0)
- {
- *n_sizes = 0;
- if (sizes)
- *sizes = NULL;
- g_array_free (size_array, TRUE);
- }
+ {
+ *n_sizes = 0;
+ if (sizes)
+ *sizes = NULL;
+ g_array_free (size_array, TRUE);
+ }
else
- {
- *n_sizes = size_array->len;
- if (sizes)
- {
- *sizes = (int *) size_array->data;
- g_array_free (size_array, FALSE);
- }
- else
- g_array_free (size_array, TRUE);
- }
+ {
+ *n_sizes = size_array->len;
+ if (sizes)
+ {
+ *sizes = (int *) size_array->data;
+ g_array_free (size_array, FALSE);
+ }
+ else
+ g_array_free (size_array, TRUE);
+ }
FcFontSetDestroy (fontset);
}
{
*n_sizes = 0;
if (sizes)
- *sizes = NULL;
+ *sizes = NULL;
}
FcPatternDestroy (pattern);
return fcfamily->spacing == FC_MONO ||
#ifdef FC_DUAL
- fcfamily->spacing == FC_DUAL ||
+ fcfamily->spacing == FC_DUAL ||
#endif
- fcfamily->spacing == FC_CHARCELL;
+ fcfamily->spacing == FC_CHARCELL;
}
static void
{
const GTypeInfo object_info =
{
- sizeof (PangoFontFaceClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_fc_face_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoFcFace),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
+ sizeof (PangoFontFaceClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_fc_face_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoFcFace),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
NULL /* value_table */
};
object_type = g_type_register_static (PANGO_TYPE_FONT_FACE,
- I_("PangoFcFace"),
- &object_info, 0);
+ I_("PangoFcFace"),
+ &object_info, 0);
}
return object_type;
slant = FC_SLANT_ROMAN;
if (FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &font_style) != FcResultMatch)
- font_style = NULL;
+ font_style = NULL;
if (weight <= FC_WEIGHT_MEDIUM)
{
- if (slant == FC_SLANT_ROMAN)
+ if (slant == FC_SLANT_ROMAN)
{
has_face[REGULAR] = TRUE;
style = "Regular";
}
else
{
- if (slant == FC_SLANT_ROMAN)
+ if (slant == FC_SLANT_ROMAN)
{
has_face[BOLD] = TRUE;
style = "Bold";
}
if (!font_style)
- font_style = style;
+ font_style = style;
faces[num++] = create_face (fcfamily, font_style, FALSE);
}
{
const GTypeInfo object_info =
{
- sizeof (PangoFontFamilyClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_fc_family_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoFcFamily),
- 0, /* n_preallocs */
- (GInstanceInitFunc) pango_fc_family_init,
+ sizeof (PangoFontFamilyClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_fc_family_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoFcFamily),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) pango_fc_family_init,
NULL /* value_table */
};
object_type = g_type_register_static (PANGO_TYPE_FONT_FAMILY,
- I_("PangoFcFamily"),
- &object_info, 0);
+ I_("PangoFcFamily"),
+ &object_info, 0);
}
return object_type;
/*< public >*/
/* Deprecated in favor of context_substitute */
void (*default_substitute) (PangoFcFontMap *fontmap,
- FcPattern *pattern);
+ FcPattern *pattern);
/* Deprecated in favor of create_font */
PangoFcFont *(*new_font) (PangoFcFontMap *fontmap,
- FcPattern *pattern);
+ FcPattern *pattern);
double (*get_resolution) (PangoFcFontMap *fcfontmap,
PangoContext *context);
void (*context_substitute) (PangoFcFontMap *fontmap,
PangoContext *context,
- FcPattern *pattern);
+ FcPattern *pattern);
PangoFcFont *(*create_font) (PangoFcFontMap *fontmap,
PangoContext *context,
const PangoFontDescription *desc,
- FcPattern *pattern);
+ FcPattern *pattern);
/*< private >*/
/* Padding for future expansion */
{
glyph = pango_ft2_get_unknown_glyph (font);
if (glyph == PANGO_GLYPH_EMPTY)
- {
+ {
/* No unknown glyph found for the font, draw a box */
/* Since we only draw an empty box for FT2 renderer,
if (G_UNLIKELY (!PANGO_FT2_IS_FONT (font)))
{
if (!_pango_ft2_warning_history.get_face)
- {
+ {
_pango_ft2_warning_history.get_face = TRUE;
g_warning ("pango_ft2_font_get_face called with bad font, expect ugly output");
}
/* disable antialiasing if requested */
if (FcPatternGetBool (pattern,
- FC_ANTIALIAS, 0, &antialias) != FcResultMatch)
+ FC_ANTIALIAS, 0, &antialias) != FcResultMatch)
antialias = FcTrue;
if (antialias)
- ft2font->load_flags |= FT_LOAD_NO_BITMAP;
+ ft2font->load_flags |= FT_LOAD_NO_BITMAP;
else
ft2font->load_flags |= FT_LOAD_TARGET_MONO;
/* disable hinting if requested */
if (FcPatternGetBool (pattern,
- FC_HINTING, 0, &hinting) != FcResultMatch)
+ FC_HINTING, 0, &hinting) != FcResultMatch)
hinting = FcTrue;
if (!hinting)
- ft2font->load_flags |= FT_LOAD_NO_HINTING;
+ ft2font->load_flags |= FT_LOAD_NO_HINTING;
/* force autohinting if requested */
if (FcPatternGetBool (pattern,
- FC_AUTOHINT, 0, &autohint) != FcResultMatch)
+ FC_AUTOHINT, 0, &autohint) != FcResultMatch)
autohint = FcFalse;
if (autohint)
- ft2font->load_flags |= FT_LOAD_FORCE_AUTOHINT;
+ ft2font->load_flags |= FT_LOAD_FORCE_AUTOHINT;
if (FcPatternGetString (pattern, FC_FILE, 0, &filename) != FcResultMatch)
goto bail0;
{
glyph = pango_ft2_get_unknown_glyph (font);
if (glyph == PANGO_GLYPH_EMPTY)
- {
+ {
/* No unknown glyph found for the font, draw a box */
PangoFontMetrics *metrics = pango_font_get_metrics (font, NULL);
static char *default_msg = NULL;
if (!default_msg)
- default_msg = g_malloc (60);
+ default_msg = g_malloc (60);
g_sprintf (default_msg, "Unknown FreeType2 error %#x", error);
return default_msg;
typedef struct _PangoFT2FontMap PangoFT2FontMap;
typedef void (*PangoFT2SubstituteFunc) (FcPattern *pattern,
- gpointer data);
+ gpointer data);
/* Calls for applications */
GType pango_win32_face_get_type (void);
static void pango_win32_face_list_sizes (PangoFontFace *face,
- int **sizes,
- int *n_sizes);
+ int **sizes,
+ int *n_sizes);
static void pango_win32_font_map_finalize (GObject *object);
static PangoFont *pango_win32_font_map_load_font (PangoFontMap *fontmap,
static gboolean
first_match (gpointer key,
- gpointer value,
+ gpointer value,
gpointer user_data)
{
LOGFONT *lfp = (LOGFONT *)key;
static void
ensure_italic (gpointer key,
- gpointer value,
- gpointer user_data)
+ gpointer value,
+ gpointer user_data)
{
ItalicHelper *helper = (ItalicHelper *)user_data;
/* PangoWin32Family *win32family = (PangoWin32Family *)value; */
GSList *list = sip->logfonts;
while (list)
- {
+ {
LOGFONT *lfp = (LOGFONT *)list->data;
- if (!lfp->lfItalic)
- {
+ if (!lfp->lfItalic)
+ {
/* we have a non italic variant, look if there is an italic */
LOGFONT logfont = *lfp;
logfont.lfItalic = 1;
sip = (PangoWin32SizeInfo *)g_hash_table_find (helper->fontmap->size_infos, first_match, &logfont);
if (!sip)
- {
+ {
/* remember the non italic variant to be added later as italic */
helper->list = g_slist_append (helper->list, lfp);
}
{
const GTypeInfo object_info =
{
- sizeof (PangoFontFamilyClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_win32_family_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoWin32Family),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
+ sizeof (PangoFontFamilyClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_win32_family_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoWin32Family),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (PANGO_TYPE_FONT_FAMILY,
- I_("PangoWin32Family"),
- &object_info, 0);
+ I_("PangoWin32Family"),
+ &object_info, 0);
}
return object_type;
result = PANGO_WIN32_FONT_MAP_GET_CLASS (win32fontmap)->find_font (win32fontmap, context,
best_match,
description);
- /* TODO: Handle the case that result == NULL. */
+ /* TODO: Handle the case that result == NULL. */
else
PING(("no best match!"));
}
static void
pango_win32_face_list_sizes (PangoFontFace *face,
- int **sizes,
- int *n_sizes)
+ int **sizes,
+ int *n_sizes)
{
/*
* for scalable fonts it's simple, and currently we only have such
{
const GTypeInfo object_info =
{
- sizeof (PangoFontFaceClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_win32_face_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoWin32Face),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
+ sizeof (PangoFontFaceClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_win32_face_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoWin32Face),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (PANGO_TYPE_FONT_FACE,
- I_("PangoWin32Face"),
- &object_info, 0);
+ I_("PangoWin32Face"),
+ &object_info, 0);
}
return object_type;
xForm.eDx = matrix->x0;
xForm.eDy = matrix->y0;
if (!SetWorldTransform (hdc, &xForm))
- g_warning ("GetWorldTransform() failed");
+ g_warning ("GetWorldTransform() failed");
}
pango_win32_render (hdc, font, glyphs, x/PANGO_SCALE, y/PANGO_SCALE);
PangoLayoutLine *line = l->data;
for (r = line->runs; r; r = r->next)
- {
- PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
- int i;
-
- for (i = 0; i < glyphs->num_glyphs; i++)
- if (glyphs->glyphs[i].geometry.width > max_width)
- max_width = glyphs->glyphs[i].geometry.width;
- }
+ {
+ PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
+ int i;
+
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ if (glyphs->glyphs[i].geometry.width > max_width)
+ max_width = glyphs->glyphs[i].geometry.width;
+ }
}
return max_width;
Polyline (hdc, points, 2);
break;
case PANGO_UNDERLINE_ERROR:
- {
- int point_x;
- int counter = 0;
+ {
+ int point_x;
+ int counter = 0;
int end_x = x + PANGO_PIXELS (x_off + ink_rect.x + ink_rect.width);
- for (point_x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1;
- point_x <= end_x;
- point_x += 2)
- {
+ for (point_x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1;
+ point_x <= end_x;
+ point_x += 2)
+ {
points[0].x = point_x;
points[1].x = MAX (point_x + 1, end_x);
- if (counter)
- points[0].y = points[1].y = y + 2;
- else
- points[0].y = points[1].y = y + 3;
+ if (counter)
+ points[0].y = points[1].y = y + 2;
+ else
+ points[0].y = points[1].y = y + 3;
Polyline (hdc, points, 2);
- counter = (counter + 1) % 2;
- }
- }
+ counter = (counter + 1) % 2;
+ }
+ }
break;
case PANGO_UNDERLINE_LOW:
points[0].x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1;
baseline = pango_layout_iter_get_baseline (iter);
pango_win32_render_layout_line (hdc,
- line,
- x + PANGO_PIXELS (logical_rect.x),
- y + PANGO_PIXELS (baseline));
+ line,
+ x + PANGO_PIXELS (logical_rect.x),
+ y + PANGO_PIXELS (baseline));
}
while (pango_layout_iter_next_line (iter));
struct format_4_cmap *table;
/* FIXME: Could look here at the CRC for the font in the DC
- and return a cached copy if the same */
+ and return a cached copy if the same */
offset = get_cmap_offset (hdc, UNICODE_ENCODING_ID);
if (offset == 0)
int y);
void pango_win32_render_transformed (HDC hdc,
- const PangoMatrix *matrix,
- PangoFont *font,
- PangoGlyphString *glyphs,
- int x,
- int y);
+ const PangoMatrix *matrix,
+ PangoFont *font,
+ PangoGlyphString *glyphs,
+ int x,
+ int y);
#ifdef PANGO_ENABLE_ENGINE
void pango_win32_font_cache_free (PangoWin32FontCache *cache);
HFONT pango_win32_font_cache_load (PangoWin32FontCache *cache,
- const LOGFONT *logfont);
+ const LOGFONT *logfont);
void pango_win32_font_cache_unload (PangoWin32FontCache *cache,
HFONT hfont);
{
const GTypeInfo object_info =
{
- sizeof (PangoFontMapClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_x_font_map_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoXFontMap),
- 0, /* n_preallocs */
- (GInstanceInitFunc) pango_x_font_map_init,
+ sizeof (PangoFontMapClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_x_font_map_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoXFontMap),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) pango_x_font_map_init,
NULL /* value_table */
};
object_type = g_type_register_static (PANGO_TYPE_FONT_MAP,
- I_("PangoXFontMap"),
- &object_info, 0);
+ I_("PangoXFontMap"),
+ &object_info, 0);
}
return object_type;
{
const GTypeInfo object_info =
{
- sizeof (PangoFontFaceClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_x_face_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoXFace),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
+ sizeof (PangoFontFaceClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_x_face_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoXFace),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
NULL /* value_table */
};
object_type = g_type_register_static (PANGO_TYPE_FONT_FACE,
- I_("PangoXFace"),
- &object_info, 0);
+ I_("PangoXFace"),
+ &object_info, 0);
}
return object_type;
{
const GTypeInfo object_info =
{
- sizeof (PangoFontFamilyClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_x_family_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoXFamily),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
+ sizeof (PangoFontFamilyClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_x_family_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoXFamily),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
NULL /* value_table */
};
object_type = g_type_register_static (PANGO_TYPE_FONT_FAMILY,
- I_("PangoXFamily"),
- &object_info, 0);
+ I_("PangoXFamily"),
+ &object_info, 0);
}
return object_type;
PangoXFont *xfont);
Atom pango_x_fontmap_atom_from_name (PangoFontMap *fontmap,
- const char *atomname);
+ const char *atomname);
const char *pango_x_fontmap_name_from_atom (PangoFontMap *fontmap,
- Atom atom);
+ Atom atom);
#endif /* __PANGOX_PRIVATE_H__ */
registered_modules = TRUE;
for (i = 0; _pango_included_x_modules[i].list; i++)
- pango_module_register (&_pango_included_x_modules[i]);
+ pango_module_register (&_pango_included_x_modules[i]);
}
result = pango_context_new ();
info->get_gc_func = NULL;
info->free_gc_func = NULL;
g_object_set_qdata_full (G_OBJECT (result),
- g_quark_from_static_string ("pango-x-info"),
- info, (GDestroyNotify)g_free);
+ g_quark_from_static_string ("pango-x-info"),
+ info, (GDestroyNotify)g_free);
pango_context_set_font_map (result, pango_x_font_map_for_display (display));
g_return_if_fail (context != NULL);
info = g_object_get_qdata (G_OBJECT (context),
- g_quark_from_static_string ("pango-x-info"));
+ g_quark_from_static_string ("pango-x-info"));
info->get_gc_func = get_gc_func;
info->free_gc_func = free_gc_func;
{
const GTypeInfo object_info =
{
- sizeof (PangoXFontClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_x_font_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoXFont),
- 0, /* n_preallocs */
- (GInstanceInitFunc) pango_x_font_init,
+ sizeof (PangoXFontClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_x_font_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoXFont),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) pango_x_font_init,
NULL /* value_table */
};
object_type = g_type_register_static (PANGO_TYPE_FONT,
- I_("PangoXFont"),
- &object_info, 0);
+ I_("PangoXFont"),
+ &object_info, 0);
}
return object_type;
goto unknown_glyph;
} else {
PangoFontMetrics *metrics;
- int x1, y1, x2, y2; /* rectangle the character should go inside. */
- int baseline;
+ int x1, y1, x2, y2; /* rectangle the character should go inside. */
+ int baseline;
int stroke_thick;
- gunichar wc;
+ gunichar wc;
unknown_glyph:
FLUSH;
x1 = glyph_x;
x2 = x1 + PANGO_PIXELS (glyphs->glyphs[i].geometry.width);
- baseline = glyph_y;
+ baseline = glyph_y;
stroke_thick = MAX ((int) (0.5 + 0.075 * (y2 - y1)), 1);
if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
else
wc = 0;
- switch (wc)
- {
- case '\n':
- case '\r':
- case 0x2028: /* Line separator */
- case 0x2029: /* Paragraph separator */
- {
- /* Draw a carriage-return thingy */
- PangoRectangle up_stroke;
- PangoRectangle across_stroke;
+ switch (wc)
+ {
+ case '\n':
+ case '\r':
+ case 0x2028: /* Line separator */
+ case 0x2029: /* Paragraph separator */
+ {
+ /* Draw a carriage-return thingy */
+ PangoRectangle up_stroke;
+ PangoRectangle across_stroke;
int hborder = (x2 - x1) * 0.1;
int arrow_height = 0.25 * (y2 - y1);
for (arrow_x = x1 + hborder; arrow_x < x1 + hborder + arrow_width; arrow_x++)
{
- XDrawLine (display, d, gc,
- arrow_x,
+ XDrawLine (display, d, gc,
+ arrow_x,
baseline - stroke_thick + (stroke_thick - tmp_height) / 2,
- arrow_x,
+ arrow_x,
baseline - stroke_thick + (stroke_thick - tmp_height) / 2 + tmp_height - 1);
if ((arrow_x - x1 - hborder) % 2 == 1)
tmp_height += 2;
}
- across_stroke.x = arrow_x;
- across_stroke.width = x2 - hborder - arrow_x - stroke_thick;
- across_stroke.y = baseline - stroke_thick;
- across_stroke.height = stroke_thick;
+ across_stroke.x = arrow_x;
+ across_stroke.width = x2 - hborder - arrow_x - stroke_thick;
+ across_stroke.y = baseline - stroke_thick;
+ across_stroke.height = stroke_thick;
- XFillRectangle (display, d, gc,
- across_stroke.x, across_stroke.y,
- across_stroke.width, across_stroke.height);
+ XFillRectangle (display, d, gc,
+ across_stroke.x, across_stroke.y,
+ across_stroke.width, across_stroke.height);
up_stroke.x = across_stroke.x + across_stroke.width;
up_stroke.width = stroke_thick;
up_stroke.y = y1 + top_border;
up_stroke.height = baseline - up_stroke.y;
- XFillRectangle (display, d, gc,
- up_stroke.x, up_stroke.y,
- up_stroke.width, up_stroke.height);
- }
- break;
+ XFillRectangle (display, d, gc,
+ up_stroke.x, up_stroke.y,
+ up_stroke.width, up_stroke.height);
+ }
+ break;
- default:
+ default:
{
/* Perhaps we should draw the box-with-numbers as in the
* Xft backend, though we have no guarantee of having
}
pango_font_metrics_unref (metrics);
- }
+ }
next_glyph:
x_off += glyphs->glyphs[i].geometry.width;
if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
wc = glyph & (~PANGO_GLYPH_UNKNOWN_FLAG);
else
- wc = 0;
+ wc = 0;
switch (wc)
- {
- case '\n':
- case '\r':
- case 0x2028: /* Line separator */
- case 0x2029: /* Paragraph separator */
- {
+ {
+ case '\n':
+ case '\r':
+ case 0x2028: /* Line separator */
+ case 0x2029: /* Paragraph separator */
+ {
#define MAGIC_FACTOR 1.2
- /* carriage-return thingy */
+ /* carriage-return thingy */
width_factor = MAGIC_FACTOR;
break;
}
metrics = pango_font_get_metrics (font, NULL);
if (metrics)
- {
+ {
w = metrics->approximate_char_width * width_factor;
w = PANGO_SCALE * PANGO_PIXELS (w);
static gboolean
get_int_prop (Atom atom,
- XFontStruct *fs,
- int *val)
+ XFontStruct *fs,
+ int *val)
{
int i;
while (i < fs->n_properties)
{
if (fs->properties[i].name == atom)
- {
- *val = fs->properties[i].card32;
- return TRUE;
- }
+ {
+ *val = fs->properties[i].card32;
+ return TRUE;
+ }
++i;
}
last_shaper = shaper;
last_level = embedding_levels[i];
i++;
- }
+ }
}
pango_glyph_string_free (glyph_str);
Atom avg_width_atom;
avg_width_atom = pango_x_fontmap_atom_from_name (xfont->fontmap,
- "AVERAGE_WIDTH");
+ "AVERAGE_WIDTH");
metrics->ascent = 0;
metrics->descent = 0;
if (subfont)
{
XFontStruct *fs = pango_x_get_font_struct (font, subfont);
- gint avg_width = 0;
+ gint avg_width = 0;
if (fs)
{
PangoContext *context = pango_layout_get_context (line->layout);
PangoXContextInfo *info =
g_object_get_qdata (G_OBJECT (context),
- g_quark_from_static_string ("pango-x-info"));
+ g_quark_from_static_string ("pango-x-info"));
int x_off = 0;
x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE, y + 2);
break;
case PANGO_UNDERLINE_ERROR:
- {
- int point_x;
- int counter = 0;
+ {
+ int point_x;
+ int counter = 0;
int end_x = x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE;
- for (point_x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1;
- point_x <= end_x;
- point_x += 2)
+ for (point_x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1;
+ point_x <= end_x;
+ point_x += 2)
{
if (counter)
XDrawLine (display, drawable, gc,
counter = (counter + 1) % 2;
}
- }
+ }
break;
case PANGO_UNDERLINE_LOW:
XDrawLine (display, drawable, fg_gc,
baseline = pango_layout_iter_get_baseline (iter);
pango_x_render_layout_line (display, drawable, gc,
- line,
- x + PANGO_PIXELS (logical_rect.x),
- y + PANGO_PIXELS (baseline));
+ line,
+ x + PANGO_PIXELS (logical_rect.x),
+ y + PANGO_PIXELS (baseline));
}
while (pango_layout_iter_next_line (iter));
*/
gboolean
pango_x_apply_ligatures (PangoFont *font,
- PangoXSubfont subfont_id,
- gunichar **glyphs,
- int *n_glyphs,
- int **clusters)
+ PangoXSubfont subfont_id,
+ gunichar **glyphs,
+ int *n_glyphs,
+ int **clusters)
{
return FALSE;
}
*/
gboolean
pango_x_find_first_subfont (PangoFont *font,
- char **charsets,
+ char **charsets,
int n_charsets,
- PangoXSubfont *rfont)
+ PangoXSubfont *rfont)
{
int n_subfonts;
gboolean result = FALSE;
g_return_val_if_fail (rfont, 0);
n_subfonts = pango_x_list_subfonts (font, charsets, n_charsets,
- &subfonts, &subfont_charsets);
+ &subfonts, &subfont_charsets);
if (n_subfonts > 0)
{
*/
void
pango_x_fallback_shape (PangoFont *font,
- PangoGlyphString *glyphs,
- const char *text,
- int n_chars)
+ PangoGlyphString *glyphs,
+ const char *text,
+ int n_chars)
{
PangoGlyph unknown_glyph = pango_x_get_unknown_glyph (font);
PangoRectangle logical_rect;
*/
PangoGlyph
pango_x_font_get_unknown_glyph (PangoFont *font,
- gunichar wc)
+ gunichar wc)
{
return PANGO_GET_UNKNOWN_GLYPH (wc);
}
gboolean pango_x_find_first_subfont (PangoFont *font,
- char **charsets,
+ char **charsets,
int n_charsets,
- PangoXSubfont *rfont);
+ PangoXSubfont *rfont);
void pango_x_fallback_shape (PangoFont *font,
- PangoGlyphString *glyphs,
- const char *text,
- int n_chars);
+ PangoGlyphString *glyphs,
+ const char *text,
+ int n_chars);
gboolean pango_x_apply_ligatures (PangoFont *font,
- PangoXSubfont subfont,
- gunichar **glyphs,
- int *n_glyphs,
- int **clusters);
+ PangoXSubfont subfont,
+ gunichar **glyphs,
+ int *n_glyphs,
+ int **clusters);
#endif /* PANGO_DISABLE_DEPRECATED */
xfont->mini_font = pango_font_map_load_font (fcfont->fontmap, context, desc);
if (!xfont->mini_font)
- return NULL;
+ return NULL;
pango_font_description_free (desc);
g_object_unref (context);
size = pango_font_description_get_size (fcfont->description) / PANGO_SCALE;
xft_font = XftFontOpen (display, screen,
- FC_FAMILY, FcTypeString, "sans",
+ FC_FAMILY, FcTypeString, "sans",
size_is_absolute ? FC_PIXEL_SIZE : FC_SIZE, FcTypeDouble, size,
- NULL);
+ NULL);
if (!xft_font)
{
if (G_UNLIKELY (!PANGO_XFT_IS_FONT (font)))
{
if (!_pango_xft_warning_history.get_font)
- {
+ {
_pango_xft_warning_history.get_font = TRUE;
g_warning ("pango_xft_font_get_font called with bad font, expect ugly output");
}
_pango_xft_renderer_draw_box_glyph (renderer, gi, glyph_x, glyph_y);
}
- x_off += gi->geometry.width;
+ x_off += gi->geometry.width;
}
return;
}
typedef struct _PangoXftFont PangoXftFont;
typedef void (*PangoXftSubstituteFunc) (FcPattern *pattern,
- gpointer data);
+ gpointer data);
/* Calls for applications
*/
*/
void
pango_shape (const gchar *text,
- gint length,
- const PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+ gint length,
+ const PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
{
int i;
int last_cluster;
text, length, analysis, glyphs);
if (G_UNLIKELY (glyphs->num_glyphs == 0))
- {
+ {
/* If a font has been correctly chosen, but no glyphs are output,
* there's probably something wrong with the shaper. Trying to be
* informative, we print out the font description, but to not
{
if (!PANGO_IS_ENGINE_SHAPE (analysis->shape_engine) &&
!_pango_warning_history.shape_shape_engine)
- {
+ {
_pango_warning_history.shape_shape_engine = TRUE;
g_warning ("pango_shape called with bad shape_engine, expect ugly output");
}
if (!PANGO_IS_FONT (analysis->font) &&
!_pango_warning_history.shape_font)
- {
+ {
_pango_warning_history.shape_font = TRUE;
g_warning ("pango_shape called with bad font, expect ugly output");
}
attrs = g_new0 (PangoLogAttr, len + 1);
pango_get_log_attrs (text,
- -1,
- 0,
- pango_language_from_string ("C"),
- attrs,
- len + 1);
+ -1,
+ 0,
+ pango_language_from_string ("C"),
+ attrs,
+ len + 1);
ucs4 = g_utf8_to_ucs4 (text, -1, NULL, NULL, NULL);
g_unichar_to_utf8 (ucs4[i], buf);
if (*buf == '\n')
- loc = g_strdup ("\\n");
+ loc = g_strdup ("\\n");
else if (*buf == '\r')
- loc = g_strdup ("\\r");
+ loc = g_strdup ("\\r");
else
- loc = g_locale_from_utf8 (buf, -1, NULL, NULL, NULL);
+ loc = g_locale_from_utf8 (buf, -1, NULL, NULL, NULL);
g_print (CHFORMAT " (%s):\t line_break = %d mandatory_break = %d char_break = %d\n"
- " \t\t white = %d cursor_position = %d\n"
- " \t\t word_start = %d word_end = %d\n"
- " \t\t sentence_boundary = %d sentence_start = %d sentence_end = %d\n",
- ucs4[i], loc ? loc : "?",
- attrs[i].is_line_break,
- attrs[i].is_mandatory_break,
- attrs[i].is_char_break,
- attrs[i].is_white,
- attrs[i].is_cursor_position,
- attrs[i].is_word_start,
- attrs[i].is_word_end,
- attrs[i].is_sentence_boundary,
- attrs[i].is_sentence_start,
- attrs[i].is_sentence_end);
+ " \t\t white = %d cursor_position = %d\n"
+ " \t\t word_start = %d word_end = %d\n"
+ " \t\t sentence_boundary = %d sentence_start = %d sentence_end = %d\n",
+ ucs4[i], loc ? loc : "?",
+ attrs[i].is_line_break,
+ attrs[i].is_mandatory_break,
+ attrs[i].is_char_break,
+ attrs[i].is_white,
+ attrs[i].is_cursor_position,
+ attrs[i].is_word_start,
+ attrs[i].is_word_end,
+ attrs[i].is_sentence_boundary,
+ attrs[i].is_sentence_start,
+ attrs[i].is_sentence_end);
g_free (loc);
*/
#define VIRAMA_SCRIPT(wc) ((wc) >= 0x0901 && (wc) <= 0x17FF)
#define VIRAMA(wc) ((wc) == 0x094D || \
- (wc) == 0x09CD || \
- (wc) == 0x0A4D || \
- (wc) == 0x0ACD || \
- (wc) == 0x0B4D || \
- (wc) == 0x0BCD || \
- (wc) == 0x0C4D || \
- (wc) == 0x0CCD || \
- (wc) == 0x0D4D || \
- (wc) == 0x0DCA || \
- (wc) == 0x0E3A || \
- (wc) == 0x0F84 || \
- (wc) == 0x1039 || \
- (wc) == 0x17D2)
+ (wc) == 0x09CD || \
+ (wc) == 0x0A4D || \
+ (wc) == 0x0ACD || \
+ (wc) == 0x0B4D || \
+ (wc) == 0x0BCD || \
+ (wc) == 0x0C4D || \
+ (wc) == 0x0CCD || \
+ (wc) == 0x0D4D || \
+ (wc) == 0x0DCA || \
+ (wc) == 0x0E3A || \
+ (wc) == 0x0F84 || \
+ (wc) == 0x1039 || \
+ (wc) == 0x17D2)
/* Types of Japanese characters */
#define JAPANESE(wc) ((wc) >= 0x2F00 && (wc) <= 0x30FF)
#define KANJI(wc) ((wc) >= 0x2F00 && (wc) <= 0x2FDF)
}
typedef void (* CharForeachFunc) (gunichar wc,
- gunichar prev_wc,
- gunichar next_wc,
- GUnicodeType type,
- GUnicodeType prev_type,
- GUnicodeType next_type,
- PangoLogAttr *attr,
- PangoLogAttr *prev_attr,
- PangoLogAttr *next_attr,
- gpointer data);
+ gunichar prev_wc,
+ gunichar next_wc,
+ GUnicodeType type,
+ GUnicodeType prev_type,
+ GUnicodeType next_type,
+ PangoLogAttr *attr,
+ PangoLogAttr *prev_attr,
+ PangoLogAttr *next_attr,
+ gpointer data);
static void
log_attr_foreach (const char *text,
- PangoLogAttr *attrs,
- CharForeachFunc func,
- gpointer data)
+ PangoLogAttr *attrs,
+ CharForeachFunc func,
+ gpointer data)
{
const gchar *next = text;
gint length = strlen (text);
line_end = next;
if (next >= end)
- next_wc = 0;
+ next_wc = 0;
else
- next_wc = g_utf8_get_char (next);
+ next_wc = g_utf8_get_char (next);
if (next_wc)
- next_type = g_unichar_type (next_wc);
+ next_type = g_unichar_type (next_wc);
(* func) (wc, prev_wc, next_wc,
- type, prev_type, next_type,
- &attrs[i],
- i != 0 ? &attrs[i-1] : NULL,
- next_wc != 0 ? &attrs[i+1] : NULL,
- data);
+ type, prev_type, next_type,
+ &attrs[i],
+ i != 0 ? &attrs[i-1] : NULL,
+ next_wc != 0 ? &attrs[i+1] : NULL,
+ data);
prev_type = type;
prev_wc = wc;
++i;
++offset;
if (wc == '\n')
- {
- ++line;
- offset = 0;
- line_start = next;
- line_end = next;
- }
+ {
+ ++line;
+ offset = 0;
+ line_start = next;
+ line_end = next;
+ }
}
}
static void
check_line_char (gunichar wc,
- gunichar prev_wc,
- gunichar next_wc,
- GUnicodeType type,
- GUnicodeType prev_type,
- GUnicodeType next_type,
- PangoLogAttr *attr,
- PangoLogAttr *prev_attr,
- PangoLogAttr *next_attr,
- gpointer data)
+ gunichar prev_wc,
+ gunichar next_wc,
+ GUnicodeType type,
+ GUnicodeType prev_type,
+ GUnicodeType next_type,
+ PangoLogAttr *attr,
+ PangoLogAttr *prev_attr,
+ PangoLogAttr *next_attr,
+ gpointer data)
{
GUnicodeBreakType break_type;
GUnicodeBreakType prev_break_type;
if (wc == '\n')
{
if (prev_wc == '\r')
- {
- if (attr->is_line_break)
- fail ("line break between \\r and \\n");
- }
+ {
+ if (attr->is_line_break)
+ fail ("line break between \\r and \\n");
+ }
if (next_attr && !next_attr->is_line_break)
- fail ("no line break after \\n");
+ fail ("no line break after \\n");
}
if (attr->is_line_break && prev_wc == 0)
if (break_type == G_UNICODE_BREAK_SPACE)
{
if (attr->is_line_break && prev_attr != NULL &&
- !attr->is_mandatory_break &&
+ !attr->is_mandatory_break &&
!(next_wc && g_unichar_break_type (next_wc) == G_UNICODE_BREAK_COMBINING_MARK))
- fail ("can't break lines before a space unless a mandatory break char precedes it or a combining mark follows; prev char was " CHFORMAT, prev_wc);
+ fail ("can't break lines before a space unless a mandatory break char precedes it or a combining mark follows; prev char was " CHFORMAT, prev_wc);
}
if (attr->is_mandatory_break && !attr->is_line_break)
static void
check_line_invariants (const char *text,
- PangoLogAttr *attrs)
+ PangoLogAttr *attrs)
{
log_attr_foreach (text, attrs, check_line_char, NULL);
}
static void
check_word_invariants (const char *text,
- PangoLogAttr *attrs)
+ PangoLogAttr *attrs)
{
static void
check_sentence_invariants (const char *text,
- PangoLogAttr *attrs)
+ PangoLogAttr *attrs)
{
static void
check_grapheme_invariants (const char *text,
- PangoLogAttr *attrs)
+ PangoLogAttr *attrs)
{
}
static void print_sentences (const char *text,
- PangoLogAttr *attrs);
+ PangoLogAttr *attrs);
static void
print_sentences (const char *text,
- PangoLogAttr *attrs)
+ PangoLogAttr *attrs)
{
const char *p;
const char *last;
while (*p)
{
if (attrs[i].is_sentence_boundary)
- {
- char *s = g_strndup (last, p - last);
- printf ("%s\n", s);
- g_free (s);
- last = p;
- }
+ {
+ char *s = g_strndup (last, p - last);
+ printf ("%s\n", s);
+ g_free (s);
+ last = p;
+ }
p = g_utf8_next_char (p);
++i;
attrs = g_new0 (PangoLogAttr, len + 1);
pango_get_log_attrs (text,
- -1,
- 0,
- pango_language_from_string ("C"),
- attrs,
- len + 1);
+ -1,
+ 0,
+ pango_language_from_string ("C"),
+ attrs,
+ len + 1);
check_line_invariants (text, attrs);
check_sentence_invariants (text, attrs);
if (stmt) { } \
else \
{ \
- g_warning ("%s:%d (%s): assertion '%s' failed", \
+ g_warning ("%s:%d (%s): assertion '%s' failed", \
__FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, #stmt); \
- exit (1); \
+ exit (1); \
} \
} G_STMT_END