summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/basic/Makefile.am8
-rw-r--r--modules/basic/basic-ft2.c320
-rw-r--r--modules/basic/basic-win32.c21
-rw-r--r--modules/basic/makefile.mingw21
-rw-r--r--modules/basic/makefile.mingw.in31
5 files changed, 372 insertions, 29 deletions
diff --git a/modules/basic/Makefile.am b/modules/basic/Makefile.am
index db21f28c..4ccb4869 100644
--- a/modules/basic/Makefile.am
+++ b/modules/basic/Makefile.am
@@ -21,4 +21,10 @@ libpango_basic_la_SOURCES = $(sources)
EXTRA_DIST = \
tables-big.i \
tables-small.i \
- basic-win32.c
+ basic-win32.c \
+ basic-ft2.c \
+ makefile.mingw \
+ makefile.mingw.in
+
+makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/modules/basic/makefile.mingw.in
+ cd $(top_builddir) && CONFIG_FILES=modules/basic/$@ CONFIG_HEADERS= $(SHELL) ./config.status
diff --git a/modules/basic/basic-ft2.c b/modules/basic/basic-ft2.c
new file mode 100644
index 00000000..086ba420
--- /dev/null
+++ b/modules/basic/basic-ft2.c
@@ -0,0 +1,320 @@
+/* Pango
+ * basic-ft2.c:
+ *
+ * Copyright (C) 1999 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.
+ */
+
+#include <glib.h>
+
+#include "pango.h"
+#include "pangoft2.h"
+
+#include <fribidi/fribidi.h>
+
+static PangoEngineRange basic_ranges[] = {
+ /* Language characters */
+ { 0x0000, 0x02af, "*" },
+ { 0x02b0, 0x02ff, "" },
+ { 0x0380, 0x058f, "*" },
+ { 0x0591, 0x05f4, "*" }, /* Hebrew */
+ { 0x060c, 0x06f9, "" }, /* Arabic */
+ { 0x0e01, 0x0e5b, "" }, /* Thai */
+ { 0x1e00, 0x1fff, "*" },
+ { 0x2000, 0x9fff, "*" },
+ { 0xac00, 0xd7a3, "kr" },
+ { 0xf900, 0xfa0b, "kr" },
+ { 0xff00, 0xffe3, "*" }
+};
+
+static PangoEngineInfo script_engines[] = {
+ {
+ "BasicScriptEngineLang",
+ PANGO_ENGINE_TYPE_LANG,
+ PANGO_RENDER_TYPE_NONE,
+ basic_ranges, G_N_ELEMENTS(basic_ranges)
+ },
+ {
+ "BasicScriptEngineFT2",
+ PANGO_ENGINE_TYPE_SHAPE,
+ PANGO_RENDER_TYPE_FT2,
+ basic_ranges, G_N_ELEMENTS(basic_ranges)
+ }
+};
+
+static gint n_script_engines = G_N_ELEMENTS (script_engines);
+
+/*
+ * Language script engine
+ */
+
+static void
+basic_engine_break (const char *text,
+ gint len,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs)
+{
+}
+
+static PangoEngine *
+basic_engine_lang_new (void)
+{
+ PangoEngineLang *result;
+
+ result = g_new (PangoEngineLang, 1);
+
+ result->engine.id = "BasicScriptEngine";
+ result->engine.type = PANGO_ENGINE_TYPE_LANG;
+ result->engine.length = sizeof (result);
+ result->script_break = basic_engine_break;
+
+ return (PangoEngine *)result;
+}
+
+/*
+ * FT2 system script engine portion
+ */
+
+static PangoGlyph
+find_char (PangoFont *font,
+ gunichar wc)
+{
+ int i;
+ int n_subfonts;
+
+ n_subfonts = pango_ft2_n_subfonts (font);
+
+ for (i = 0; i < n_subfonts; i++)
+ {
+ PangoGlyph glyph;
+
+ glyph = PANGO_FT2_MAKE_GLYPH (i+1, wc);
+
+ if (pango_ft2_has_glyph (font, glyph))
+ return glyph;
+ }
+
+ return 0;
+}
+
+static void
+set_glyph (PangoFont *font,
+ PangoGlyphString *glyphs,
+ int i,
+ int offset,
+ PangoGlyph glyph)
+{
+ PangoRectangle logical_rect;
+
+ glyphs->glyphs[i].glyph = glyph;
+
+ glyphs->glyphs[i].geometry.x_offset = 0;
+ glyphs->glyphs[i].geometry.y_offset = 0;
+
+ glyphs->log_clusters[i] = offset;
+
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
+
+ if (i > 0)
+ {
+ glyphs->glyphs[i-1].geometry.width +=
+ pango_ft2_font_get_kerning (font,
+ glyphs->glyphs[i-1].glyph,
+ glyphs->glyphs[i].glyph);
+ }
+}
+
+static void
+swap_range (PangoGlyphString *glyphs,
+ int start,
+ int end)
+{
+ int i, j;
+
+ for (i = start, j = end - 1; i < j; i++, j--)
+ {
+ PangoGlyphInfo glyph_info;
+ gint log_cluster;
+
+ glyph_info = glyphs->glyphs[i];
+ glyphs->glyphs[i] = glyphs->glyphs[j];
+ glyphs->glyphs[j] = glyph_info;
+
+ log_cluster = glyphs->log_clusters[i];
+ glyphs->log_clusters[i] = glyphs->log_clusters[j];
+ glyphs->log_clusters[j] = log_cluster;
+ }
+}
+
+static void
+basic_engine_shape (PangoFont *font,
+ const char *text,
+ gint length,
+ PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
+{
+ int n_chars;
+ int i;
+ const char *p;
+
+ g_return_if_fail (font != NULL);
+ g_return_if_fail (text != NULL);
+ g_return_if_fail (length >= 0);
+ g_return_if_fail (analysis != NULL);
+
+ n_chars = g_utf8_strlen (text, length);
+ pango_glyph_string_set_size (glyphs, n_chars);
+
+ p = text;
+ for (i = 0; i < n_chars; i++)
+ {
+ gunichar wc;
+ FriBidiChar mirrored_ch;
+ PangoGlyph index;
+
+ wc = g_utf8_get_char (p);
+
+ if (analysis->level % 2)
+ if (fribidi_get_mirror_char (wc, &mirrored_ch))
+ wc = mirrored_ch;
+
+ if (wc == 0x200B || wc == 0x200E || wc == 0x200F) /* Zero-width characters */
+ {
+ set_glyph (font, glyphs, i, p - text, 0);
+ }
+ else
+ {
+ index = find_char (font, wc);
+ if (index)
+ {
+ set_glyph (font, glyphs, i, p - text, index);
+
+ if (g_unichar_type (wc) == G_UNICODE_NON_SPACING_MARK)
+ {
+ if (i > 0)
+ {
+ PangoRectangle logical_rect, ink_rect;
+
+ glyphs->glyphs[i].geometry.width = MAX (glyphs->glyphs[i-1].geometry.width,
+ glyphs->glyphs[i].geometry.width);
+ glyphs->glyphs[i-1].geometry.width = 0;
+ glyphs->log_clusters[i] = glyphs->log_clusters[i-1];
+
+ /* Some heuristics to try to guess how overstrike glyphs are
+ * done and compensate
+ */
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, &ink_rect, &logical_rect);
+ if (logical_rect.width == 0 && ink_rect.x == 0)
+ glyphs->glyphs[i].geometry.x_offset = (glyphs->glyphs[i].geometry.width - ink_rect.width) / 2;
+ }
+ }
+ }
+ else
+ set_glyph (font, glyphs, i, p - text, pango_ft2_get_unknown_glyph (font));
+ }
+
+ p = g_utf8_next_char (p);
+ }
+
+ /* Simple bidi support... may have separate modules later */
+
+ if (analysis->level % 2)
+ {
+ int start, end;
+
+ /* Swap all glyphs */
+ swap_range (glyphs, 0, n_chars);
+
+ /* Now reorder glyphs within each cluster back to LTR */
+ for (start = 0; start < n_chars;)
+ {
+ end = start;
+ while (end < n_chars &&
+ glyphs->log_clusters[end] == glyphs->log_clusters[start])
+ end++;
+
+ swap_range (glyphs, start, end);
+ start = end;
+ }
+ }
+}
+
+static PangoCoverage *
+basic_engine_get_coverage (PangoFont *font,
+ const char *lang)
+{
+ PangoCoverage *result = pango_coverage_new ();
+ gunichar wc;
+
+ for (wc = 0; wc < 65536; wc++)
+ if (find_char (font, wc))
+ pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT);
+
+ return result;
+}
+
+static PangoEngine *
+basic_engine_ft2_new (void)
+{
+ PangoEngineShape *result;
+
+ result = g_new (PangoEngineShape, 1);
+
+ result->engine.id = "BasicScriptEngine";
+ result->engine.type = PANGO_ENGINE_TYPE_LANG;
+ result->engine.length = sizeof (result);
+ result->script_shape = basic_engine_shape;
+ result->get_coverage = basic_engine_get_coverage;
+
+ return (PangoEngine *)result;
+}
+
+/* The following three functions provide the public module API for
+ * Pango
+ */
+#ifdef MODULE_PREFIX
+#define MODULE_ENTRY(func) _pango_basic_##func
+#else
+#define MODULE_ENTRY(func) func
+#endif
+
+void
+MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines,
+ gint *n_engines)
+{
+ *engines = script_engines;
+ *n_engines = n_script_engines;
+}
+
+PangoEngine *
+MODULE_ENTRY(script_engine_load) (const char *id)
+{
+ g_print ("basic-ft2: LOAD\n");
+ if (!strcmp (id, "BasicScriptEngineLang"))
+ return basic_engine_lang_new ();
+ else if (!strcmp (id, "BasicScriptEngineFT2"))
+ return basic_engine_ft2_new ();
+ else
+ return NULL;
+}
+
+void
+MODULE_ENTRY(script_engine_unload) (PangoEngine *engine)
+{
+ g_print ("basic-ft2: UNLOAD\n");
+}
diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c
index 410fa971..ea4f6f0f 100644
--- a/modules/basic/basic-win32.c
+++ b/modules/basic/basic-win32.c
@@ -69,7 +69,7 @@ basic_engine_break (const char *text,
}
static PangoEngine *
-basic_engine_lang_new ()
+basic_engine_lang_new (void)
{
PangoEngineLang *result;
@@ -88,7 +88,8 @@ basic_engine_lang_new ()
*/
static PangoGlyph
-find_char (PangoFont *font, gunichar wc)
+find_char (PangoFont *font,
+ gunichar wc)
{
PangoWin32UnicodeSubrange subrange;
PangoWin32Subfont *subfonts;
@@ -113,7 +114,11 @@ find_char (PangoFont *font, gunichar wc)
}
static void
-set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGlyph glyph)
+set_glyph (PangoFont *font,
+ PangoGlyphString *glyphs,
+ int i,
+ int offset,
+ PangoGlyph glyph)
{
PangoRectangle logical_rect;
@@ -129,7 +134,9 @@ set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGl
}
static void
-swap_range (PangoGlyphString *glyphs, int start, int end)
+swap_range (PangoGlyphString *glyphs,
+ int start,
+ int end)
{
int i, j;
@@ -256,7 +263,7 @@ basic_engine_get_coverage (PangoFont *font,
}
static PangoEngine *
-basic_engine_win32_new ()
+basic_engine_win32_new (void)
{
PangoEngineShape *result;
@@ -281,7 +288,8 @@ basic_engine_win32_new ()
#endif
void
-MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines)
+MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines,
+ gint *n_engines)
{
*engines = script_engines;
*n_engines = n_script_engines;
@@ -302,4 +310,3 @@ void
MODULE_ENTRY(script_engine_unload) (PangoEngine *engine)
{
}
-
diff --git a/modules/basic/makefile.mingw b/modules/basic/makefile.mingw
deleted file mode 100644
index 43d48465..00000000
--- a/modules/basic/makefile.mingw
+++ /dev/null
@@ -1,21 +0,0 @@
-PANGO_VER = 0.12
-
-TOP = ../../..
-
-include $(TOP)/build/win32/make.mingw
-
-OPTIMIZE = -g
-
-INCLUDES = -I ../../pango -I ../..
-DEFINES =
-DEPCFLAGS = $(GLIB_CFLAGS) $(FRIBIDI_CFLAGS)
-
-all : \
- ../../config.h \
- pango-basic-win32.dll
-
-../../config.h : ../../config.h.win32
- cp $< $@
-
-pango-basic-win32.dll : basic-win32.o
- $(GLIB)/build-dll pango-basic-win32 - ../module.def $< -L ../../pango -lpango-$(PANGO_VER) -lpangowin32-$(PANGO_VER) $(GLIB_LIBS) $(FRIBIDI_LIBS)
diff --git a/modules/basic/makefile.mingw.in b/modules/basic/makefile.mingw.in
new file mode 100644
index 00000000..64cb1a51
--- /dev/null
+++ b/modules/basic/makefile.mingw.in
@@ -0,0 +1,31 @@
+TOP = ../../..
+
+include $(TOP)/build/win32/make.mingw
+
+# Possibly override Pango version from build/win32/module.defs
+PANGO_VER = @VERSION@
+
+OPTIMIZE = -g -Wall
+
+INCLUDES = -I ../../pango -I ../..
+DEFINES =
+DEPCFLAGS = $(GLIB_CFLAGS) $(FRIBIDI_CFLAGS) $(FREETYPE2_CFLAGS)
+
+all : \
+ ../../config.h \
+ pango-basic-win32.dll \
+ pango-basic-ft2.dll
+
+../../config.h : ../../config.h.win32
+ cp $< $@
+
+pango-basic-win32.dll : basic-win32.o
+ $(GLIB)/build-dll pango-basic-win32 - ../module.def $< -L ../../pango -lpango-$(PANGO_VER) -lpangowin32-$(PANGO_VER) $(GLIB_LIBS) $(FRIBIDI_LIBS)
+
+pango-basic-ft2.dll : basic-ft2.o
+ $(GLIB)/build-dll pango-basic-ft2 - ../module.def $< -L ../../pango -lpango-$(PANGO_VER) -lpangoft2-$(PANGO_VER) $(GLIB_LIBS) $(FRIBIDI_LIBS) $(FREETYPE2_LIBS)
+
+# Hack to get an updated makefile.mingw automatically after updating
+# makefile.mingw.in. Only for developer use.
+makefile.mingw: makefile.mingw.in
+ sed -e 's,@VER[S]ION@,@VERSION@,' <$< >$@