diff options
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | pango.pc.in | 1 | ||||
-rw-r--r-- | pango/pango-bidi-type.c | 71 | ||||
-rw-r--r-- | pango/pango-ot-buffer.c | 1 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 6 | ||||
-rw-r--r-- | utils/EMOJI-MODIFIERS.txt (renamed from pango-view/EMOJI-MODIFIERS.txt) | 0 | ||||
-rw-r--r-- | utils/GLASS.txt (renamed from pango-view/GLASS.txt) | 0 | ||||
-rw-r--r-- | utils/HELLO.txt (renamed from pango-view/HELLO.txt) | 0 | ||||
-rw-r--r-- | utils/Makefile.am (renamed from pango-view/Makefile.am) | 11 | ||||
-rw-r--r-- | utils/meson.build (renamed from pango-view/meson.build) | 0 | ||||
-rw-r--r-- | utils/pango-list.c | 98 | ||||
-rw-r--r-- | utils/pango-view.c (renamed from pango-view/pango-view.c) | 0 | ||||
-rw-r--r-- | utils/test-arabic.txt (renamed from pango-view/test-arabic.txt) | 0 | ||||
-rw-r--r-- | utils/test-chinese.txt (renamed from pango-view/test-chinese.txt) | 0 | ||||
-rw-r--r-- | utils/test-devanagari.txt (renamed from pango-view/test-devanagari.txt) | 0 | ||||
-rw-r--r-- | utils/test-feature-tag.markup (renamed from pango-view/test-feature-tag.markup) | 0 | ||||
-rw-r--r-- | utils/test-font-variations.markup (renamed from pango-view/test-font-variations.markup) | 0 | ||||
-rw-r--r-- | utils/test-gurmukhi.txt (renamed from pango-view/test-gurmukhi.txt) | 0 | ||||
-rw-r--r-- | utils/test-hebrew.txt (renamed from pango-view/test-hebrew.txt) | 0 | ||||
-rw-r--r-- | utils/test-ipa.txt (renamed from pango-view/test-ipa.txt) | 0 | ||||
-rw-r--r-- | utils/test-justify.txt (renamed from pango-view/test-justify.txt) | 0 | ||||
-rw-r--r-- | utils/test-lao.txt (renamed from pango-view/test-lao.txt) | 0 | ||||
-rw-r--r-- | utils/test-latin.txt (renamed from pango-view/test-latin.txt) | 0 | ||||
-rw-r--r-- | utils/test-long-paragraph.txt (renamed from pango-view/test-long-paragraph.txt) | 0 | ||||
-rw-r--r-- | utils/test-mixed.markup (renamed from pango-view/test-mixed.markup) | 0 | ||||
-rw-r--r-- | utils/test-mixed.txt (renamed from pango-view/test-mixed.txt) | 0 | ||||
-rw-r--r-- | utils/test-mongolian.txt (renamed from pango-view/test-mongolian.txt) | 0 | ||||
-rw-r--r-- | utils/test-nko.txt (renamed from pango-view/test-nko.txt) | 0 | ||||
-rw-r--r-- | utils/test-opentype-language.markup (renamed from pango-view/test-opentype-language.markup) | 0 | ||||
-rw-r--r-- | utils/test-syriac.txt (renamed from pango-view/test-syriac.txt) | 0 | ||||
-rw-r--r-- | utils/test-tamil.txt (renamed from pango-view/test-tamil.txt) | 0 | ||||
-rw-r--r-- | utils/test-thai.txt (renamed from pango-view/test-thai.txt) | 0 | ||||
-rw-r--r-- | utils/test-tibetan.txt (renamed from pango-view/test-tibetan.txt) | 0 | ||||
-rw-r--r-- | utils/viewer-cairo.c (renamed from pango-view/viewer-cairo.c) | 0 | ||||
-rw-r--r-- | utils/viewer-cairo.h (renamed from pango-view/viewer-cairo.h) | 0 | ||||
-rw-r--r-- | utils/viewer-main.c (renamed from pango-view/viewer-main.c) | 0 | ||||
-rw-r--r-- | utils/viewer-pangocairo.c (renamed from pango-view/viewer-pangocairo.c) | 0 | ||||
-rw-r--r-- | utils/viewer-pangoft2.c (renamed from pango-view/viewer-pangoft2.c) | 0 | ||||
-rw-r--r-- | utils/viewer-pangoxft.c (renamed from pango-view/viewer-pangoxft.c) | 0 | ||||
-rw-r--r-- | utils/viewer-render.c (renamed from pango-view/viewer-render.c) | 0 | ||||
-rw-r--r-- | utils/viewer-render.h (renamed from pango-view/viewer-render.h) | 0 | ||||
-rw-r--r-- | utils/viewer-x.c (renamed from pango-view/viewer-x.c) | 0 | ||||
-rw-r--r-- | utils/viewer-x.h (renamed from pango-view/viewer-x.h) | 0 | ||||
-rw-r--r-- | utils/viewer.h (renamed from pango-view/viewer.h) | 1 |
46 files changed, 185 insertions, 12 deletions
diff --git a/Makefile.am b/Makefile.am index 3de1fadb..16d8c8d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,10 @@ ## Process this file with automake to create Makefile.in. -SUBDIRS= pango pango-view examples docs tools tests win32 +SUBDIRS= pango utils examples docs tools tests win32 meson_dist_files = \ pango/pango-features.h.meson \ - pango-view/meson.build \ + utils/meson.build \ meson.build \ meson_options.txt \ pango/meson.build \ diff --git a/configure.ac b/configure.ac index a0cf1284..6964b14e 100644 --- a/configure.ac +++ b/configure.ac @@ -669,7 +669,7 @@ pango/pangoft2.rc pango/pangowin32.rc pango/pangocairo.rc pango/pangoxft.rc -pango-view/Makefile +utils/Makefile examples/Makefile docs/Makefile docs/version.xml diff --git a/meson.build b/meson.build index dc50240c..3733f246 100644 --- a/meson.build +++ b/meson.build @@ -510,8 +510,8 @@ configure_file(output: 'config.h', configuration: pango_conf) root_inc = include_directories('.') subdir('pango') +subdir('utils') subdir('examples') -subdir('pango-view') subdir('tests') subdir('tools') diff --git a/pango.pc.in b/pango.pc.in index bae2fd33..81c074b1 100644 --- a/pango.pc.in +++ b/pango.pc.in @@ -7,6 +7,7 @@ Name: Pango Description: Internationalized text handling Version: @VERSION@ Requires: glib-2.0 gobject-2.0 +Requires.private: fribidi Libs: -L${libdir} -lpango-@PANGO_API_VERSION@ Libs.private: -lm Cflags: -I${includedir}/pango-1.0 diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c index 782f60f2..19a40dae 100644 --- a/pango/pango-bidi-type.c +++ b/pango/pango-bidi-type.c @@ -96,7 +96,9 @@ pango_bidi_type_for_unichar (gunichar ch) case FRIBIDI_TYPE_WS: return PANGO_BIDI_TYPE_WS; case FRIBIDI_TYPE_ON: return PANGO_BIDI_TYPE_ON; default: - g_assert_not_reached (); + /* TODO + * This function has not been updated for latest FriBidi. + * Should add new types and / or deprecate this function. */ return PANGO_BIDI_TYPE_ON; } } @@ -139,6 +141,8 @@ pango_log2vis_get_embedding_levels (const gchar *text, FriBidiBracketType *bracket_types = local_bracket_types; #endif FriBidiLevel max_level; + FriBidiCharType ored_types = 0; + FriBidiCharType anded_strongs = FRIBIDI_TYPE_RLE; G_STATIC_ASSERT (sizeof (FriBidiLevel) == sizeof (guint8)); G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar)); @@ -181,7 +185,12 @@ pango_log2vis_get_embedding_levels (const gchar *text, for (i = 0, p = text; p < text + length; p = g_utf8_next_char(p), i++) { gunichar ch = g_utf8_get_char (p); - bidi_types[i] = fribidi_get_bidi_type (ch); + FriBidiCharType char_type; + char_type = fribidi_get_bidi_type (ch); + bidi_types[i] = char_type; + ored_types |= char_type; + if (FRIBIDI_IS_STRONG (char_type)) + anded_strongs &= char_type; #ifdef USE_FRIBIDI_EX_API if (G_UNLIKELY(bidi_types[i] == FRIBIDI_TYPE_ON)) bracket_types[i] = fribidi_get_bracket (ch); @@ -190,6 +199,58 @@ pango_log2vis_get_embedding_levels (const gchar *text, #endif } + /* Short-circuit (malloc-expensive) FriBidi call for unidirectional + * text. + * + * For details see: + * https://bugzilla.gnome.org/show_bug.cgi?id=590183 + */ + +#ifndef FRIBIDI_IS_ISOLATE +#define FRIBIDI_IS_ISOLATE(x) 0 +#endif + /* The case that all resolved levels will be ltr. + * No isolates, all strongs be LTR, there should be no Arabic numbers + * (or letters for that matter), and one of the following: + * + * o base_dir doesn't have an RTL taste. + * o there are letters, and base_dir is weak. + */ + if (!FRIBIDI_IS_ISOLATE (ored_types) && + !FRIBIDI_IS_RTL (ored_types) && + !FRIBIDI_IS_ARABIC (ored_types) && + (!FRIBIDI_IS_RTL (fribidi_base_dir) || + (FRIBIDI_IS_WEAK (fribidi_base_dir) && + FRIBIDI_IS_LETTER (ored_types)) + )) + { + /* all LTR */ + fribidi_base_dir = FRIBIDI_PAR_LTR; + memset (embedding_levels_list, 0, n_chars); + goto resolved; + } + /* The case that all resolved levels will be RTL is much more complex. + * No isolates, no numbers, all strongs are RTL, and one of + * the following: + * + * o base_dir has an RTL taste (may be weak). + * o there are letters, and base_dir is weak. + */ + else if (!FRIBIDI_IS_ISOLATE (ored_types) && + !FRIBIDI_IS_NUMBER (ored_types) && + FRIBIDI_IS_RTL (anded_strongs) && + (FRIBIDI_IS_RTL (fribidi_base_dir) || + (FRIBIDI_IS_WEAK (fribidi_base_dir) && + FRIBIDI_IS_LETTER (ored_types)) + )) + { + /* all RTL */ + fribidi_base_dir = FRIBIDI_PAR_RTL; + memset (embedding_levels_list, 1, n_chars); + goto resolved; + } + + #ifdef USE_FRIBIDI_EX_API max_level = fribidi_get_par_embedding_levels_ex (bidi_types, bracket_types, n_chars, &fribidi_base_dir, @@ -207,11 +268,13 @@ pango_log2vis_get_embedding_levels (const gchar *text, if (G_UNLIKELY(max_level == 0)) { - /* fribidi_get_par_embedding_levels() failed, - * is this the best thing to do? */ + /* fribidi_get_par_embedding_levels() failed. */ memset (embedding_levels_list, 0, length); } +resolved: + g_free (bidi_types); + *pbase_dir = (fribidi_base_dir == FRIBIDI_PAR_LTR) ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL; return embedding_levels_list; diff --git a/pango/pango-ot-buffer.c b/pango/pango-ot-buffer.c index 142b2f17..334df746 100644 --- a/pango/pango-ot-buffer.c +++ b/pango/pango-ot-buffer.c @@ -40,7 +40,6 @@ pango_ot_buffer_new (PangoFcFont *font) PangoOTBuffer *buffer = g_slice_new (PangoOTBuffer); buffer->buffer = hb_buffer_create (); - hb_buffer_set_unicode_funcs (buffer->buffer, hb_glib_get_unicode_funcs ()); return buffer; } diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index cc4694d2..97a07307 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -2410,13 +2410,15 @@ pango_fc_face_list_sizes (PangoFontFace *face, { GArray *size_array; double size, dpi = -1.0; - int i, size_i; + int i, size_i, j; 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) + for (j = 0; + FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, j, &size) == FcResultMatch; + j++) { if (dpi < 0) dpi = pango_fc_font_map_get_resolution (fcface->family->fontmap, NULL); diff --git a/pango-view/EMOJI-MODIFIERS.txt b/utils/EMOJI-MODIFIERS.txt index 11101e5f..11101e5f 100644 --- a/pango-view/EMOJI-MODIFIERS.txt +++ b/utils/EMOJI-MODIFIERS.txt diff --git a/pango-view/GLASS.txt b/utils/GLASS.txt index 8eec3344..8eec3344 100644 --- a/pango-view/GLASS.txt +++ b/utils/GLASS.txt diff --git a/pango-view/HELLO.txt b/utils/HELLO.txt index 21acb941..21acb941 100644 --- a/pango-view/HELLO.txt +++ b/utils/HELLO.txt diff --git a/pango-view/Makefile.am b/utils/Makefile.am index b432e50f..97c83413 100644 --- a/pango-view/Makefile.am +++ b/utils/Makefile.am @@ -40,6 +40,17 @@ INCLUDES = \ ######################################################### bin_PROGRAMS = pango-view + +if HAVE_CAIRO +bin_PROGRAMS += pango-list +pango_list_SOURCES = pango-list.c +pango_list_LDADD = \ + ../pango/libpangocairo-$(PANGO_API_VERSION).la \ + ../pango/libpango-$(PANGO_API_VERSION).la \ + $(GLIB_LIBS) +endif + + pango_view_SOURCES = \ viewer-render.h \ viewer-render.c \ diff --git a/pango-view/meson.build b/utils/meson.build index a0043fc7..a0043fc7 100644 --- a/pango-view/meson.build +++ b/utils/meson.build diff --git a/utils/pango-list.c b/utils/pango-list.c new file mode 100644 index 00000000..40d8802d --- /dev/null +++ b/utils/pango-list.c @@ -0,0 +1,98 @@ +/* pango-list.c: List all fonts + * + * Copyright (C) 2018 Google + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Google Author(s): Behdad Esfahbod + */ + +#include "config.h" +#include <pango/pangocairo.h> +#include <glib/gstdio.h> + +int +main (int argc, + char **argv) +{ + PangoFontMap *fontmap; + PangoFontFamily **families; + int n_families; + int i, j, k; + +#if !GLIB_CHECK_VERSION (2, 35, 3) + g_type_init(); +#endif + g_set_prgname ("pango-list"); + + /* Use PangoCairo to get default fontmap so it works on every platform. */ + fontmap = pango_cairo_font_map_get_default (); + + pango_font_map_list_families (fontmap, &families, &n_families); + for (i = 0; i < n_families; i++) + { + PangoFontFace **faces; + int n_faces; + + const char *family_name = pango_font_family_get_name (families[i]); + g_print ("%s\n", family_name); + + pango_font_family_list_faces (families[i], &faces, &n_faces); + for (j = 0; j < n_faces; j++) + { + const char *face_name = pango_font_face_get_face_name (faces[j]); + gboolean is_synth = pango_font_face_is_synthesized (faces[j]); + const char *synth_str = is_synth ? "*" : ""; + g_print (" %s%s\n", synth_str, face_name); + + if (1) + { + int *sizes; + int n_sizes; + pango_font_face_list_sizes (faces[j], &sizes, &n_sizes); + if (n_sizes) + { + g_print (" {"); + for (k = 0; k < n_sizes; k++) + { + if (k) + g_print (", "); + g_print ("%g", pango_units_to_double (sizes[k])); + } + g_print ("}\n"); + } + g_free (sizes); + } + + if (1) + { + PangoFontDescription *desc = pango_font_face_describe (faces[j]); + char *desc_str = pango_font_description_to_string (desc); + + g_print (" \"%s\"\n", desc_str); + + g_free (desc_str); + pango_font_description_free (desc); + } + } + + g_free (faces); + } + g_free (families); + g_object_unref (fontmap); + + return 0; +} diff --git a/pango-view/pango-view.c b/utils/pango-view.c index fec00be9..fec00be9 100644 --- a/pango-view/pango-view.c +++ b/utils/pango-view.c diff --git a/pango-view/test-arabic.txt b/utils/test-arabic.txt index b75f9a6c..b75f9a6c 100644 --- a/pango-view/test-arabic.txt +++ b/utils/test-arabic.txt diff --git a/pango-view/test-chinese.txt b/utils/test-chinese.txt index bddc8234..bddc8234 100644 --- a/pango-view/test-chinese.txt +++ b/utils/test-chinese.txt diff --git a/pango-view/test-devanagari.txt b/utils/test-devanagari.txt index 9cfccc56..9cfccc56 100644 --- a/pango-view/test-devanagari.txt +++ b/utils/test-devanagari.txt diff --git a/pango-view/test-feature-tag.markup b/utils/test-feature-tag.markup index c92fc646..c92fc646 100644 --- a/pango-view/test-feature-tag.markup +++ b/utils/test-feature-tag.markup diff --git a/pango-view/test-font-variations.markup b/utils/test-font-variations.markup index ae277e35..ae277e35 100644 --- a/pango-view/test-font-variations.markup +++ b/utils/test-font-variations.markup diff --git a/pango-view/test-gurmukhi.txt b/utils/test-gurmukhi.txt index f3d05920..f3d05920 100644 --- a/pango-view/test-gurmukhi.txt +++ b/utils/test-gurmukhi.txt diff --git a/pango-view/test-hebrew.txt b/utils/test-hebrew.txt index 15467d87..15467d87 100644 --- a/pango-view/test-hebrew.txt +++ b/utils/test-hebrew.txt diff --git a/pango-view/test-ipa.txt b/utils/test-ipa.txt index 2fdd5e2c..2fdd5e2c 100644 --- a/pango-view/test-ipa.txt +++ b/utils/test-ipa.txt diff --git a/pango-view/test-justify.txt b/utils/test-justify.txt index 754ed28c..754ed28c 100644 --- a/pango-view/test-justify.txt +++ b/utils/test-justify.txt diff --git a/pango-view/test-lao.txt b/utils/test-lao.txt index 012025e4..012025e4 100644 --- a/pango-view/test-lao.txt +++ b/utils/test-lao.txt diff --git a/pango-view/test-latin.txt b/utils/test-latin.txt index 31fe90bd..31fe90bd 100644 --- a/pango-view/test-latin.txt +++ b/utils/test-latin.txt diff --git a/pango-view/test-long-paragraph.txt b/utils/test-long-paragraph.txt index 95c795b5..95c795b5 100644 --- a/pango-view/test-long-paragraph.txt +++ b/utils/test-long-paragraph.txt diff --git a/pango-view/test-mixed.markup b/utils/test-mixed.markup index 894a1b81..894a1b81 100644 --- a/pango-view/test-mixed.markup +++ b/utils/test-mixed.markup diff --git a/pango-view/test-mixed.txt b/utils/test-mixed.txt index e23f0314..e23f0314 100644 --- a/pango-view/test-mixed.txt +++ b/utils/test-mixed.txt diff --git a/pango-view/test-mongolian.txt b/utils/test-mongolian.txt index 9117b7b1..9117b7b1 100644 --- a/pango-view/test-mongolian.txt +++ b/utils/test-mongolian.txt diff --git a/pango-view/test-nko.txt b/utils/test-nko.txt index 65a4347e..65a4347e 100644 --- a/pango-view/test-nko.txt +++ b/utils/test-nko.txt diff --git a/pango-view/test-opentype-language.markup b/utils/test-opentype-language.markup index 3d956aa4..3d956aa4 100644 --- a/pango-view/test-opentype-language.markup +++ b/utils/test-opentype-language.markup diff --git a/pango-view/test-syriac.txt b/utils/test-syriac.txt index 05fedc7b..05fedc7b 100644 --- a/pango-view/test-syriac.txt +++ b/utils/test-syriac.txt diff --git a/pango-view/test-tamil.txt b/utils/test-tamil.txt index ff080a24..ff080a24 100644 --- a/pango-view/test-tamil.txt +++ b/utils/test-tamil.txt diff --git a/pango-view/test-thai.txt b/utils/test-thai.txt index 4bb8d2e0..4bb8d2e0 100644 --- a/pango-view/test-thai.txt +++ b/utils/test-thai.txt diff --git a/pango-view/test-tibetan.txt b/utils/test-tibetan.txt index 83d44aab..83d44aab 100644 --- a/pango-view/test-tibetan.txt +++ b/utils/test-tibetan.txt diff --git a/pango-view/viewer-cairo.c b/utils/viewer-cairo.c index ca98c1cd..ca98c1cd 100644 --- a/pango-view/viewer-cairo.c +++ b/utils/viewer-cairo.c diff --git a/pango-view/viewer-cairo.h b/utils/viewer-cairo.h index e843664f..e843664f 100644 --- a/pango-view/viewer-cairo.h +++ b/utils/viewer-cairo.h diff --git a/pango-view/viewer-main.c b/utils/viewer-main.c index 525599a7..525599a7 100644 --- a/pango-view/viewer-main.c +++ b/utils/viewer-main.c diff --git a/pango-view/viewer-pangocairo.c b/utils/viewer-pangocairo.c index 3e893207..3e893207 100644 --- a/pango-view/viewer-pangocairo.c +++ b/utils/viewer-pangocairo.c diff --git a/pango-view/viewer-pangoft2.c b/utils/viewer-pangoft2.c index 87973c80..87973c80 100644 --- a/pango-view/viewer-pangoft2.c +++ b/utils/viewer-pangoft2.c diff --git a/pango-view/viewer-pangoxft.c b/utils/viewer-pangoxft.c index 948cd90e..948cd90e 100644 --- a/pango-view/viewer-pangoxft.c +++ b/utils/viewer-pangoxft.c diff --git a/pango-view/viewer-render.c b/utils/viewer-render.c index 573cb59a..573cb59a 100644 --- a/pango-view/viewer-render.c +++ b/utils/viewer-render.c diff --git a/pango-view/viewer-render.h b/utils/viewer-render.h index ade22986..ade22986 100644 --- a/pango-view/viewer-render.h +++ b/utils/viewer-render.h diff --git a/pango-view/viewer-x.c b/utils/viewer-x.c index ad1c9a8d..ad1c9a8d 100644 --- a/pango-view/viewer-x.c +++ b/utils/viewer-x.c diff --git a/pango-view/viewer-x.h b/utils/viewer-x.h index 28f61f6b..28f61f6b 100644 --- a/pango-view/viewer-x.h +++ b/utils/viewer-x.h diff --git a/pango-view/viewer.h b/utils/viewer.h index a4937693..c4d58193 100644 --- a/pango-view/viewer.h +++ b/utils/viewer.h @@ -21,7 +21,6 @@ #ifndef VIEWER_H #define VIEWER_H -#include <stdio.h> #include <pango/pango.h> typedef struct _PangoViewer PangoViewer; |