summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/pango-sections.txt1
-rw-r--r--pango/ellipsize.c6
-rw-r--r--pango/fonts.c21
-rw-r--r--pango/pango-context.c4
-rw-r--r--pango/pango-coverage-private.h65
-rw-r--r--pango/pango-coverage.c411
-rw-r--r--pango/pango-coverage.h10
-rw-r--r--pango/pango-font-private.h1
-rw-r--r--pango/pango-font.h3
-rw-r--r--pango/pangofc-fontmap.c128
10 files changed, 258 insertions, 392 deletions
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 61823711..0fc648af 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -232,6 +232,7 @@ pango_font_find_shaper
pango_font_describe
pango_font_describe_with_absolute_size
pango_font_get_coverage
+pango_font_covers
pango_font_get_glyph_extents
pango_font_get_metrics
pango_font_get_font_map
diff --git a/pango/ellipsize.c b/pango/ellipsize.c
index ade33ec7..928ec744 100644
--- a/pango/ellipsize.c
+++ b/pango/ellipsize.c
@@ -24,7 +24,7 @@
#include "pango-glyph-item.h"
#include "pango-layout-private.h"
-#include "pango-engine-private.h"
+#include "pango-font-private.h"
#include "pango-impl-utils.h"
typedef struct _EllipsizeState EllipsizeState;
@@ -345,8 +345,8 @@ shape_ellipsis (EllipsizeState *state)
/* If that fails we use "..." in the first matching font
*/
if (!item->analysis.font ||
- !_pango_engine_shape_covers (item->analysis.shape_engine, item->analysis.font,
- item->analysis.language, g_utf8_get_char (ellipsis_text)))
+ !pango_font_covers (item->analysis.font,
+ g_utf8_get_char (ellipsis_text)))
{
pango_item_free (item);
diff --git a/pango/fonts.c b/pango/fonts.c
index f273cd26..2dd39f2e 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -2306,3 +2306,24 @@ pango_font_face_list_sizes (PangoFontFace *face,
*n_sizes = 0;
}
}
+
+/**
+ * pango_font_covers:
+ * @font: a #PangoFont
+ * @wc: a Unicode character
+ *
+ * Returns whether the font provides a glyph for this character.
+ *
+ * Returns %TRUE if @font can render @wc
+ *
+ * Since: 1.44
+ */
+gboolean
+pango_font_covers (PangoFont *font,
+ gunichar wc)
+{
+ PangoCoverage *coverage = pango_font_get_coverage (font, pango_language_get_default ());
+ PangoCoverageLevel result = pango_coverage_get (coverage, wc);
+ pango_coverage_unref (coverage);
+ return result != PANGO_COVERAGE_NONE;
+}
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 413119f3..1cb89d4a 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -1247,14 +1247,12 @@ get_font_foreach (PangoFontset *fontset,
gpointer data)
{
GetFontInfo *info = data;
- PangoEngineShape *engine;
PangoCoverageLevel level;
if (G_UNLIKELY (!font))
return FALSE;
- engine = pango_font_find_shaper (font, info->lang, info->wc),
- level = _pango_engine_shape_covers (engine, font, info->lang, info->wc);
+ level = pango_font_covers (font, info->wc);
if (level != PANGO_COVERAGE_NONE)
{
info->font = font;
diff --git a/pango/pango-coverage-private.h b/pango/pango-coverage-private.h
new file mode 100644
index 00000000..806a012b
--- /dev/null
+++ b/pango/pango-coverage-private.h
@@ -0,0 +1,65 @@
+/* Pango
+ * pango-coverage-private.h: Coverage sets for fonts
+ *
+ * Copyright (C) 2000 Red Hat Software
+ *
+ * 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.
+ */
+
+#ifndef __PANGO_COVERAGE_PRIVATE_H__
+#define __PANGO_COVERAGE_PRIVATE_H__
+
+#include <glib-object.h>
+#include <pango-coverage.h>
+
+G_BEGIN_DECLS
+
+#define PANGO_TYPE_COVERAGE (pango_coverage_get_type ())
+#define PANGO_COVERAGE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_COVERAGE, PangoCoverage))
+#define PANGO_IS_COVERAGE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_COVERAGE))
+#define PANGO_COVERAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_COVERAGE, PangoCoverageClass))
+#define PANGO_IS_COVERAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_COVERAGE))
+#define PANGO_COVERAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_COVERAGE, PangoCoverageClass))
+
+typedef struct _PangoCoverageClass PangoCoverageClass;
+typedef struct _PangoCoveragePrivate PangoCoveragePrivate;
+
+struct _PangoCoverage
+{
+ GObject parent_instance;
+
+ hb_set_t *chars;
+};
+
+struct _PangoCoverageClass
+{
+ GObjectClass parent_class;
+
+ PangoCoverageLevel (* get) (PangoCoverage *coverage,
+ int index);
+ void (* set) (PangoCoverage *coverage,
+ int index,
+ PangoCoverageLevel level);
+ PangoCoverage * (* copy) (PangoCoverage *coverage);
+};
+
+PANGO_AVAILABLE_IN_ALL
+GType pango_coverage_get_type (void) G_GNUC_CONST;
+
+
+G_END_DECLS
+
+#endif /* __PANGO_COVERAGE_PRIVATE_H__ */
diff --git a/pango/pango-coverage.c b/pango/pango-coverage.c
index 80fded2b..41943720 100644
--- a/pango/pango-coverage.c
+++ b/pango/pango-coverage.c
@@ -32,29 +32,72 @@
#include "config.h"
#include <string.h>
-#include "pango-coverage.h"
+#include "pango-coverage-private.h"
-typedef struct _PangoBlockInfo PangoBlockInfo;
+G_DEFINE_TYPE (PangoCoverage, pango_coverage, G_TYPE_OBJECT)
-#define N_BLOCKS_INCREMENT 256
+static void
+pango_coverage_init (PangoCoverage *coverage)
+{
+}
-/* The structure of a PangoCoverage object is a two-level table, with blocks of size 256.
- * each block is stored as a packed array of 2 bit values for each index, in LSB order.
- */
+static void
+pango_coverage_finalize (GObject *object)
+{
+ PangoCoverage *coverage = PANGO_COVERAGE (object);
+
+ if (coverage->chars)
+ hb_set_destroy (coverage->chars);
+
+ G_OBJECT_CLASS (pango_coverage_parent_class)->finalize (object);
+}
+
+static PangoCoverageLevel
+pango_coverage_real_get (PangoCoverage *coverage,
+ int index)
+{
+ if (hb_set_has (coverage->chars, (hb_codepoint_t)index))
+ return PANGO_COVERAGE_EXACT;
+ else
+ return PANGO_COVERAGE_NONE;
+}
+
+static void
+pango_coverage_real_set (PangoCoverage *coverage,
+ int index,
+ PangoCoverageLevel level)
+{
+ if (level != PANGO_COVERAGE_NONE)
+ hb_set_add (coverage->chars, (hb_codepoint_t)index);
+ else
+ hb_set_del (coverage->chars, (hb_codepoint_t)index);
+}
-struct _PangoBlockInfo
+static PangoCoverage *
+pango_coverage_real_copy (PangoCoverage *coverage)
{
- guchar *data;
- PangoCoverageLevel level; /* Used if data == NULL */
-};
+ PangoCoverage *copy;
-struct _PangoCoverage
+ g_return_val_if_fail (coverage != NULL, NULL);
+
+ copy = g_object_new (PANGO_TYPE_COVERAGE, NULL);
+ hb_set_destroy (copy->chars);
+ copy->chars = hb_set_reference (coverage->chars);
+
+ return copy;
+}
+
+static void
+pango_coverage_class_init (PangoCoverageClass *class)
{
- guint ref_count;
- int n_blocks;
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = pango_coverage_finalize;
- PangoBlockInfo *blocks;
-};
+ class->get = pango_coverage_real_get;
+ class->set = pango_coverage_real_set;
+ class->copy = pango_coverage_real_copy;
+}
/**
* pango_coverage_new:
@@ -69,13 +112,7 @@ struct _PangoCoverage
PangoCoverage *
pango_coverage_new (void)
{
- PangoCoverage *coverage = g_slice_new (PangoCoverage);
-
- coverage->n_blocks = N_BLOCKS_INCREMENT;
- coverage->blocks = g_new0 (PangoBlockInfo, coverage->n_blocks);
- coverage->ref_count = 1;
-
- return coverage;
+ return g_object_new (PANGO_TYPE_COVERAGE, NULL);
}
/**
@@ -92,30 +129,7 @@ pango_coverage_new (void)
PangoCoverage *
pango_coverage_copy (PangoCoverage *coverage)
{
- int i;
- PangoCoverage *result;
-
- g_return_val_if_fail (coverage != NULL, NULL);
-
- result = g_slice_new (PangoCoverage);
- result->n_blocks = coverage->n_blocks;
- result->blocks = g_new (PangoBlockInfo, coverage->n_blocks);
- result->ref_count = 1;
-
- for (i=0; i<coverage->n_blocks; i++)
- {
- if (coverage->blocks[i].data)
- {
- result->blocks[i].data = g_new (guchar, 64);
- memcpy (result->blocks[i].data, coverage->blocks[i].data, 64);
- }
- else
- result->blocks[i].data = NULL;
-
- result->blocks[i].level = coverage->blocks[i].level;
- }
-
- return result;
+ return PANGO_COVERAGE_GET_CLASS (coverage)->copy (coverage);
}
/**
@@ -129,11 +143,7 @@ pango_coverage_copy (PangoCoverage *coverage)
PangoCoverage *
pango_coverage_ref (PangoCoverage *coverage)
{
- g_return_val_if_fail (coverage != NULL, NULL);
-
- g_atomic_int_inc ((int *) &coverage->ref_count);
-
- return coverage;
+ return g_object_ref (coverage);
}
/**
@@ -146,19 +156,7 @@ pango_coverage_ref (PangoCoverage *coverage)
void
pango_coverage_unref (PangoCoverage *coverage)
{
- int i;
-
- g_return_if_fail (coverage != NULL);
- g_return_if_fail (coverage->ref_count > 0);
-
- if (g_atomic_int_dec_and_test ((int *) &coverage->ref_count))
- {
- for (i=0; i<coverage->n_blocks; i++)
- g_slice_free1 (64, coverage->blocks[i].data);
-
- g_free (coverage->blocks);
- g_slice_free (PangoCoverage, coverage);
- }
+ g_object_unref (coverage);
}
/**
@@ -174,33 +172,7 @@ PangoCoverageLevel
pango_coverage_get (PangoCoverage *coverage,
int index)
{
- int block_index;
-
- g_return_val_if_fail (coverage != NULL, PANGO_COVERAGE_NONE);
-
- /* index should really have been defined unsigned. Work around
- * it by just returning NONE.
- */
- if (G_UNLIKELY (index < 0))
- return PANGO_COVERAGE_NONE;
-
- block_index = index / 256;
-
- if (block_index >= coverage->n_blocks)
- return PANGO_COVERAGE_NONE;
- else
- {
- guchar *data = coverage->blocks[block_index].data;
- if (data)
- {
- int i = index % 256;
- int shift = (i % 4) * 2;
-
- return (data[i/4] >> shift) & 0x3;
- }
- else
- return coverage->blocks[block_index].level;
- }
+ return PANGO_COVERAGE_GET_CLASS (coverage)->get (coverage, index);
}
/**
@@ -216,48 +188,7 @@ pango_coverage_set (PangoCoverage *coverage,
int index,
PangoCoverageLevel level)
{
- int block_index, i;
- guchar *data;
-
- g_return_if_fail (coverage != NULL);
- g_return_if_fail (index >= 0);
- g_return_if_fail ((guint) level <= 3);
-
- block_index = index / 256;
-
- if (block_index >= coverage->n_blocks)
- {
- int old_n_blocks = coverage->n_blocks;
-
- coverage->n_blocks =
- N_BLOCKS_INCREMENT * ((block_index + N_BLOCKS_INCREMENT) / N_BLOCKS_INCREMENT);
-
- coverage->blocks = g_renew (PangoBlockInfo, coverage->blocks, coverage->n_blocks);
- memset (coverage->blocks + old_n_blocks, 0,
- sizeof (PangoBlockInfo) * (coverage->n_blocks - old_n_blocks));
- }
-
- data = coverage->blocks[block_index].data;
- if (!data)
- {
- guchar byte;
-
- if (level == coverage->blocks[block_index].level)
- return;
-
- data = g_slice_alloc (64);
- coverage->blocks[block_index].data = 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);
-
- memset (data, byte, 64);
- }
-
- i = index % 256;
- data[i/4] |= level << ((i % 4) * 2);
+ PANGO_COVERAGE_GET_CLASS (coverage)->set (coverage, index, level);
}
/**
@@ -268,97 +199,15 @@ pango_coverage_set (PangoCoverage *coverage,
* Set the coverage for each index in @coverage to be the max (better)
* value of the current coverage for the index and the coverage for
* the corresponding index in @other.
+ *
+ * Deprecated: 1.44: This function does nothing
**/
void
pango_coverage_max (PangoCoverage *coverage,
PangoCoverage *other)
{
- int block_index, i;
- int old_blocks;
-
- g_return_if_fail (coverage != NULL);
-
- old_blocks = MIN (coverage->n_blocks, other->n_blocks);
-
- if (other->n_blocks > coverage->n_blocks)
- {
- coverage->n_blocks = other->n_blocks;
- coverage->blocks = g_renew (PangoBlockInfo, coverage->blocks, coverage->n_blocks);
-
- for (block_index = old_blocks; block_index < coverage->n_blocks; block_index++)
- {
- if (other->blocks[block_index].data)
- {
- coverage->blocks[block_index].data = g_new (guchar, 64);
- memcpy (coverage->blocks[block_index].data, other->blocks[block_index].data, 64);
- }
- else
- coverage->blocks[block_index].data = NULL;
-
- coverage->blocks[block_index].level = other->blocks[block_index].level;
- }
- }
-
- for (block_index = 0; block_index < old_blocks; block_index++)
- {
- if (!coverage->blocks[block_index].data && !other->blocks[block_index].data)
- {
- coverage->blocks[block_index].level = MAX (coverage->blocks[block_index].level, other->blocks[block_index].level);
- }
- else if (coverage->blocks[block_index].data && other->blocks[block_index].data)
- {
- guchar *data = coverage->blocks[block_index].data;
-
- for (i=0; i<64; i++)
- {
- int byte1 = data[i];
- int byte2 = other->blocks[block_index].data[i];
-
- /* There are almost certainly some clever logical ops to do this */
- data[i] =
- MAX (byte1 & 0x3, byte2 & 0x3) |
- MAX (byte1 & 0xc, byte2 & 0xc) |
- MAX (byte1 & 0x30, byte2 & 0x30) |
- MAX (byte1 & 0xc0, byte2 & 0xc0);
- }
- }
- else
- {
- guchar *src, *dest;
- int level, byte2;
-
- if (coverage->blocks[block_index].data)
- {
- src = dest = coverage->blocks[block_index].data;
- level = other->blocks[block_index].level;
- }
- else
- {
- src = other->blocks[block_index].data;
- dest = g_new (guchar, 64);
- coverage->blocks[block_index].data = dest;
- level = coverage->blocks[block_index].level;
- }
-
- byte2 = level | (level << 2) | (level << 4) | (level << 6);
-
- for (i=0; i<64; i++)
- {
- int byte1 = src[i];
-
- /* There are almost certainly some clever logical ops to do this */
- dest[i] =
- MAX (byte1 & 0x3, byte2 & 0x3) |
- MAX (byte1 & 0xc, byte2 & 0xc) |
- MAX (byte1 & 0x30, byte2 & 0x30) |
- MAX (byte1 & 0xc0, byte2 & 0xc0);
- }
- }
- }
}
-#define PANGO_COVERAGE_MAGIC 0xc89dbd5e
-
/**
* pango_coverage_to_bytes:
* @coverage: a #PangoCoverage
@@ -367,85 +216,16 @@ pango_coverage_max (PangoCoverage *coverage,
* @n_bytes: (out): location to store size of result
*
* Convert a #PangoCoverage structure into a flat binary format
+ *
+ * Deprecated: 1.44: This returns %NULL
**/
void
-pango_coverage_to_bytes (PangoCoverage *coverage,
- guchar **bytes,
- int *n_bytes)
-{
- int i, j;
- int size = 8 + 4 * coverage->n_blocks;
- guchar *data;
- int offset;
-
- for (i=0; i<coverage->n_blocks; i++)
- {
- if (coverage->blocks[i].data)
- size += 64;
- }
-
- data = g_malloc (size);
-
- *(guint32 *)&data[0] = g_htonl (PANGO_COVERAGE_MAGIC); /* Magic */
- *(guint32 *)&data[4] = g_htonl (coverage->n_blocks);
- offset = 8;
-
- for (i=0; i<coverage->n_blocks; i++)
- {
- guint32 header_val;
-
- /* Check for solid blocks. This is a sort of random place
- * to do the optimization, but we care most about getting
- * it right when storing it somewhere persistant.
- */
- if (coverage->blocks[i].data != NULL)
- {
- guchar *data = coverage->blocks[i].data;
- guchar first_val = data[0];
-
- if (first_val == 0 || first_val == 0xff)
- {
- for (j = 1 ; j < 64; j++)
- if (data[j] != first_val)
- break;
-
- if (j == 64)
- {
- g_slice_free1 (64, data);
- coverage->blocks[i].data = NULL;
- coverage->blocks[i].level = first_val & 0x3;
- }
- }
- }
-
- if (coverage->blocks[i].data != NULL)
- header_val = (guint32)-1;
- else
- header_val = coverage->blocks[i].level;
-
- *(guint32 *)&data[offset] = g_htonl (header_val);
- offset += 4;
-
- if (coverage->blocks[i].data)
- {
- memcpy (data + offset, coverage->blocks[i].data, 64);
- offset += 64;
- }
- }
-
- *bytes = data;
- *n_bytes = size;
-}
-
-static guint32
-pango_coverage_get_uint32 (guchar **ptr)
+pango_coverage_to_bytes (PangoCoverage *coverage,
+ guchar **bytes,
+ int *n_bytes)
{
- guint32 val;
-
- memcpy (&val, *ptr, 4);
- *ptr += 4;
-
- return g_ntohl (val);
+ *bytes = NULL;
+ *n_bytes = 0;
}
/**
@@ -459,53 +239,12 @@ pango_coverage_get_uint32 (guchar **ptr)
*
* Return value: (transfer full) (nullable): a newly allocated
* #PangoCoverage, or %NULL if the data was invalid.
+ *
+ * Deprecated: 1.44: This returns %NULL
**/
PangoCoverage *
pango_coverage_from_bytes (guchar *bytes,
int n_bytes)
{
- PangoCoverage *coverage = g_slice_new0 (PangoCoverage);
- guchar *ptr = bytes;
- int i;
-
- coverage->ref_count = 1;
-
- if (n_bytes < 8)
- goto error;
-
- if (pango_coverage_get_uint32 (&ptr) != PANGO_COVERAGE_MAGIC)
- goto error;
-
- coverage->n_blocks = pango_coverage_get_uint32 (&ptr);
- coverage->blocks = g_new0 (PangoBlockInfo, coverage->n_blocks);
-
- for (i = 0; i < coverage->n_blocks; i++)
- {
- guint val;
-
- if (ptr + 4 > bytes + n_bytes)
- goto error;
-
- val = pango_coverage_get_uint32 (&ptr);
- if (val == (guint32)-1)
- {
- if (ptr + 64 > bytes + n_bytes)
- goto error;
-
- coverage->blocks[i].data = g_new (guchar, 64);
- memcpy (coverage->blocks[i].data, ptr, 64);
- ptr += 64;
- }
- else
- coverage->blocks[i].level = val;
- }
-
- return coverage;
-
- error:
-
- pango_coverage_unref (coverage);
return NULL;
}
-
-
diff --git a/pango/pango-coverage.h b/pango/pango-coverage.h
index b83d5108..e46f34d1 100644
--- a/pango/pango-coverage.h
+++ b/pango/pango-coverage.h
@@ -25,6 +25,7 @@
#include <glib.h>
#include <pango/pango-version-macros.h>
+#include <harfbuzz/hb.h>
G_BEGIN_DECLS
@@ -50,6 +51,9 @@ typedef struct _PangoCoverage PangoCoverage;
*
* Used to indicate how well a font can represent a particular Unicode
* character point for a particular script.
+ *
+ * Since 1.44, only %PANGO_COVERAGE_NONE and %PANGO_COVERAGE_EXACT
+ * will be returned.
*/
typedef enum {
PANGO_COVERAGE_NONE,
@@ -73,15 +77,15 @@ PANGO_AVAILABLE_IN_ALL
void pango_coverage_set (PangoCoverage *coverage,
int index_,
PangoCoverageLevel level);
-PANGO_AVAILABLE_IN_ALL
+PANGO_DEPRECATED_IN_1_44
void pango_coverage_max (PangoCoverage *coverage,
PangoCoverage *other);
-PANGO_AVAILABLE_IN_ALL
+PANGO_DEPRECATED_IN_1_44
void pango_coverage_to_bytes (PangoCoverage *coverage,
guchar **bytes,
int *n_bytes);
-PANGO_AVAILABLE_IN_ALL
+PANGO_DEPRECATED_IN_1_44
PangoCoverage *pango_coverage_from_bytes (guchar *bytes,
int n_bytes);
diff --git a/pango/pango-font-private.h b/pango/pango-font-private.h
index 44d19dee..5d7bb4de 100644
--- a/pango/pango-font-private.h
+++ b/pango/pango-font-private.h
@@ -30,7 +30,6 @@
G_BEGIN_DECLS
-
PANGO_AVAILABLE_IN_ALL
PangoFontMetrics *pango_font_metrics_new (void);
diff --git a/pango/pango-font.h b/pango/pango-font.h
index ceaf9643..84d4e122 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -484,6 +484,9 @@ void pango_font_get_glyph_extents (PangoFont *font,
PANGO_AVAILABLE_IN_1_10
PangoFontMap *pango_font_get_font_map (PangoFont *font);
+PANGO_AVAILABLE_IN_1_44
+gboolean pango_font_covers (PangoFont *font,
+ gunichar unichar);
/**
* PANGO_GLYPH_EMPTY:
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index e88ac431..20ef6c04 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -51,6 +51,7 @@
#include "pangofc-private.h"
#include "pango-impl-utils.h"
#include "pango-enum-types.h"
+#include "pango-coverage-private.h"
/* Overview:
@@ -1978,6 +1979,82 @@ _pango_fc_font_map_get_cmap_cache (PangoFcFontMap *fcfontmap,
return _pango_fc_cmap_cache_ref (data->cmap_cache);
}
+typedef struct {
+ PangoCoverage parent_instance;
+
+ FcCharSet *charset;
+} PangoFcCoverage;
+
+typedef struct {
+ PangoCoverageClass parent_class;
+} PangoFcCoverageClass;
+
+GType pango_fc_coverage_get_type (void) G_GNUC_CONST;
+
+G_DEFINE_TYPE (PangoFcCoverage, pango_fc_coverage, PANGO_TYPE_COVERAGE)
+
+static void
+pango_fc_coverage_init (PangoFcCoverage *coverage)
+{
+}
+
+static PangoCoverageLevel
+pango_fc_coverage_real_get (PangoCoverage *coverage,
+ int index)
+{
+ PangoFcCoverage *fc_coverage = (PangoFcCoverage*)coverage;
+
+ return FcCharSetHasChar (fc_coverage->charset, index);
+}
+
+static void
+pango_fc_coverage_real_set (PangoCoverage *coverage,
+ int index,
+ PangoCoverageLevel level)
+{
+ PangoFcCoverage *fc_coverage = (PangoFcCoverage*)coverage;
+
+ if (level == PANGO_COVERAGE_NONE)
+ FcCharSetDelChar (fc_coverage->charset, index);
+ else
+ FcCharSetAddChar (fc_coverage->charset, index);
+}
+
+static PangoCoverage *
+pango_fc_coverage_real_copy (PangoCoverage *coverage)
+{
+ PangoFcCoverage *fc_coverage = (PangoFcCoverage*)coverage;
+ PangoFcCoverage *copy;
+
+ copy = g_object_new (pango_fc_coverage_get_type (), NULL);
+ copy->charset = FcCharSetCopy (fc_coverage->charset);
+
+ return (PangoCoverage *)copy;
+}
+
+static void
+pango_fc_coverage_finalize (GObject *object)
+{
+ PangoFcCoverage *fc_coverage = (PangoFcCoverage*)object;
+
+ FcCharSetDestroy (fc_coverage->charset);
+
+ G_OBJECT_CLASS (pango_fc_coverage_parent_class)->finalize (object);
+}
+
+static void
+pango_fc_coverage_class_init (PangoFcCoverageClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ PangoCoverageClass *coverage_class = PANGO_COVERAGE_CLASS (class);
+
+ object_class->finalize = pango_fc_coverage_finalize;
+
+ coverage_class->get = pango_fc_coverage_real_get;
+ coverage_class->set = pango_fc_coverage_real_set;
+ coverage_class->copy = pango_fc_coverage_real_copy;
+}
+
PangoCoverage *
_pango_fc_font_map_get_coverage (PangoFcFontMap *fcfontmap,
PangoFcFont *fcfont)
@@ -1985,9 +2062,6 @@ _pango_fc_font_map_get_coverage (PangoFcFontMap *fcfontmap,
PangoFcFontFaceData *data;
FcCharSet *charset;
- if (G_UNLIKELY (!fcfont->font_pattern))
- return NULL;
-
data = pango_fc_font_map_get_font_face_data (fcfontmap, fcfont->font_pattern);
if (G_UNLIKELY (!data))
return NULL;
@@ -1999,7 +2073,7 @@ _pango_fc_font_map_get_coverage (PangoFcFontMap *fcfontmap,
* doesn't require loading the font
*/
if (FcPatternGetCharSet (fcfont->font_pattern, FC_CHARSET, 0, &charset) != FcResultMatch)
- return NULL;
+ return NULL;
data->coverage = _pango_fc_font_map_fc_to_coverage (charset);
}
@@ -2019,50 +2093,12 @@ _pango_fc_font_map_get_coverage (PangoFcFontMap *fcfontmap,
PangoCoverage *
_pango_fc_font_map_fc_to_coverage (FcCharSet *charset)
{
- PangoCoverage *coverage;
- FcChar32 ucs4, pos;
- FcChar32 map[FC_CHARSET_MAP_SIZE];
- int i;
-
- /*
- * Convert an Fc CharSet into a pango coverage structure. Sure
- * would be nice to just use the Fc structure in place...
- */
- coverage = pango_coverage_new ();
- for (ucs4 = FcCharSetFirstPage (charset, map, &pos);
- ucs4 != FC_CHARSET_DONE;
- ucs4 = FcCharSetNextPage (charset, map, &pos))
- {
- for (i = 0; i < FC_CHARSET_MAP_SIZE; i++)
- {
- FcChar32 bits = map[i];
- FcChar32 base = ucs4 + i * 32;
- int b = 0;
-
- while (bits)
- {
- if (bits & 1)
- pango_coverage_set (coverage, base + b, PANGO_COVERAGE_EXACT);
+ PangoFcCoverage *coverage;
- bits >>= 1;
- b++;
- }
- }
- }
-
- /* Awful hack so Hangul Tone marks get rendered with the same
- * font and in the same run as other Hangul characters. If a font
- * covers the first composed Hangul glyph, then it is declared to cover
- * the Hangul tone marks. This hack probably needs to be formalized
- * by choosing fonts for scripts rather than individual code points.
- */
- if (pango_coverage_get (coverage, 0xac00) == PANGO_COVERAGE_EXACT)
- {
- pango_coverage_set (coverage, 0x302e, PANGO_COVERAGE_EXACT);
- pango_coverage_set (coverage, 0x302f, PANGO_COVERAGE_EXACT);
- }
+ coverage = g_object_new (pango_fc_coverage_get_type (), NULL);
+ coverage->charset = FcCharSetCopy (charset);
- return coverage;
+ return (PangoCoverage *)coverage;
}
/**