summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-02-12 09:22:21 -0500
committerMatthias Clasen <mclasen@redhat.com>2022-02-17 14:01:45 -0600
commitde3a34fc72ce83d75c84e640a47e1f5cf4b46dbe (patch)
tree33fac6b1a73152ba590da1b3f6de85a4261609f4
parentb2a37b16b4773eefbc8edcadef15cd8bb677659c (diff)
downloadpango-de3a34fc72ce83d75c84e640a47e1f5cf4b46dbe.tar.gz
Drop pangoft2
-rw-r--r--examples/meson.build4
-rw-r--r--pango/meson.build37
-rw-r--r--pango/pangoft2-fontmap.c233
-rw-r--r--pango/pangoft2-private.h106
-rw-r--r--pango/pangoft2-render.c761
-rw-r--r--pango/pangoft2.c453
-rw-r--r--pango/pangoft2.h108
-rw-r--r--pango/pangoft2.rc.in30
-rw-r--r--tests/cxx-test.cpp8
-rw-r--r--tests/meson.build4
-rw-r--r--utils/meson.build9
-rw-r--r--utils/pango-view.c4
-rw-r--r--utils/viewer-pangoft2.c167
13 files changed, 5 insertions, 1919 deletions
diff --git a/examples/meson.build b/examples/meson.build
index 0ec3860e..19d72457 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -10,10 +10,6 @@ endif
examples_deps = [ libpango_dep, libpangocairo_dep, ]
-if pango_font_backends.contains('freetype')
- examples_deps += libpangoft2_dep
-endif
-
# somebody will have to fix this
# if host_system == 'windows'
# # This hasn't been built in years, most likely, but try now
diff --git a/pango/meson.build b/pango/meson.build
index 76b282f3..6ea922cd 100644
--- a/pango/meson.build
+++ b/pango/meson.build
@@ -202,13 +202,9 @@ if build_pangoft2
]
pangoft2_headers = [
- 'pangoft2.h',
]
pangoft2_public_sources = [
- 'pangoft2-fontmap.c',
- 'pangoft2-render.c',
- 'pangoft2.c',
]
pangoft2_sources = pangofc_public_sources + pangoft2_public_sources
@@ -259,23 +255,6 @@ if build_pangoft2
)
pangofc_gir_dep = declare_dependency(sources: pangofc_gir)
pangoft2_dep_sources += pangofc_gir
-
- pangoft2_gir = gnome.generate_gir(
- libpangoft2,
- sources: pangoft2_headers + pangoft2_public_sources,
- dependencies: [ libpango_dep, pango_gir_dep, pangofc_gir_dep ],
- namespace: 'PangoFT2',
- nsversion: pango_api_version,
- identifier_prefix: 'PangoFT2',
- symbol_prefix: 'pango_ft2',
- export_packages: 'pangoft2',
- includes: [ pangofc_gir[0], 'freetype2-2.0', ],
- header: 'pango/pangoft2.h',
- install: true,
- extra_args: gir_args,
- )
- pangoft2_gir_dep = declare_dependency(sources: pangoft2_gir)
- pangoft2_dep_sources += pangoft2_gir
endif
libpangoft2_dep = declare_dependency(
@@ -286,14 +265,6 @@ if build_pangoft2
)
meson.override_dependency('pangoft2', libpangoft2_dep)
- pkgconfig.generate(libpangoft2,
- name: 'Pango FT2 and Pango Fc',
- description: 'Freetype 2.0 and fontconfig font support for Pango',
- filebase: 'pangoft2',
- subdirs: pango_api_name,
- requires: [ 'pango', freetype2_pc, fontconfig_pc ],
- )
-
pkgconfig.generate(
name: 'Pango FC',
description: 'Fontconfig support for Pango',
@@ -301,12 +272,6 @@ if build_pangoft2
subdirs: pango_api_name,
requires: [ 'pangoft2' ],
)
-else
- # For usage as a subproject
- libpangoft2_dep = dependency('', required : false)
- # Needed for making ft2 no-op while generating pangoxft_gir below
- pangoft2_gir_dep = dependency('', required : false)
- pangoft2_gir = [[]]
endif
# Win32
@@ -390,7 +355,7 @@ if cairo_dep.found()
'pangocairo-fcfontmap.c',
]
- pangocairo_deps += libpangoft2_dep
+ pangocairo_deps += [ libpangoft2_dep ]
endif
if host_system == 'windows' and pango_font_backends.contains('win32')
diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c
deleted file mode 100644
index 94a69925..00000000
--- a/pango/pangoft2-fontmap.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* Pango
- * pangoft2-fontmap.c:
- *
- * Copyright (C) 2000 Red Hat Software
- * Copyright (C) 2000 Tor Lillqvist
- *
- * 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 "config.h"
-
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include <fontconfig/fontconfig.h>
-
-#include "pango-impl-utils.h"
-#include "pangoft2-private.h"
-#include "pangofc-fontmap.h"
-
-typedef struct _PangoFT2Family PangoFT2Family;
-typedef struct _PangoFT2FontMapClass PangoFT2FontMapClass;
-
-/**
- * PangoFT2FontMap:
- *
- * The `PangoFT2FontMap` is the `PangoFontMap` implementation for FreeType fonts.
- */
-struct _PangoFT2FontMap
-{
- PangoFcFontMap parent_instance;
-
- FT_Library library;
-
- guint serial;
- double dpi_x;
- double dpi_y;
-
- PangoRenderer *renderer;
-};
-
-struct _PangoFT2FontMapClass
-{
- PangoFcFontMapClass parent_class;
-};
-
-static void pango_ft2_font_map_finalize (GObject *object);
-static PangoFcFont * pango_ft2_font_map_new_font (PangoFcFontMap *fcfontmap,
- FcPattern *pattern);
-static double pango_ft2_font_map_get_resolution (PangoFcFontMap *fcfontmap,
- PangoContext *context);
-static guint pango_ft2_font_map_get_serial (PangoFontMap *fontmap);
-static void pango_ft2_font_map_changed (PangoFontMap *fontmap);
-
-G_DEFINE_TYPE (PangoFT2FontMap, pango_ft2_font_map, PANGO_TYPE_FC_FONT_MAP)
-
-static void
-pango_ft2_font_map_class_init (PangoFT2FontMapClass *class)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class);
- PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class);
-
- gobject_class->finalize = pango_ft2_font_map_finalize;
- fontmap_class->get_serial = pango_ft2_font_map_get_serial;
- fontmap_class->changed = pango_ft2_font_map_changed;
- fcfontmap_class->default_substitute = _pango_ft2_font_map_default_substitute;
- fcfontmap_class->new_font = pango_ft2_font_map_new_font;
- fcfontmap_class->get_resolution = pango_ft2_font_map_get_resolution;
-}
-
-static void
-pango_ft2_font_map_init (PangoFT2FontMap *fontmap)
-{
- FT_Error error;
-
- fontmap->serial = 1;
- fontmap->library = NULL;
- fontmap->dpi_x = 72.0;
- fontmap->dpi_y = 72.0;
-
- error = FT_Init_FreeType (&fontmap->library);
- if (error != FT_Err_Ok)
- g_critical ("pango_ft2_font_map_init: Could not initialize freetype");
-}
-
-static void
-pango_ft2_font_map_finalize (GObject *object)
-{
- PangoFT2FontMap *ft2fontmap = PANGO_FT2_FONT_MAP (object);
-
- if (ft2fontmap->renderer)
- g_object_unref (ft2fontmap->renderer);
-
- G_OBJECT_CLASS (pango_ft2_font_map_parent_class)->finalize (object);
-
- FT_Done_FreeType (ft2fontmap->library);
-}
-
-/**
- * pango_ft2_font_map_new:
- *
- * Create a new `PangoFT2FontMap` object.
- *
- * A fontmap is used to cache information about available fonts,
- * and holds certain global parameters such as the resolution and
- * the default substitute function (see
- * [method@PangoFT2.FontMap.set_default_substitute]).
- *
- * Return value: the newly created fontmap object. Unref
- * with g_object_unref() when you are finished with it.
- *
- * Since: 1.2
- **/
-PangoFontMap *
-pango_ft2_font_map_new (void)
-{
- return (PangoFontMap *) g_object_new (PANGO_TYPE_FT2_FONT_MAP, NULL);
-}
-
-static guint
-pango_ft2_font_map_get_serial (PangoFontMap *fontmap)
-{
- PangoFT2FontMap *ft2fontmap = PANGO_FT2_FONT_MAP (fontmap);
-
- return ft2fontmap->serial;
-}
-
-static void
-pango_ft2_font_map_changed (PangoFontMap *fontmap)
-{
- PangoFT2FontMap *ft2fontmap = PANGO_FT2_FONT_MAP (fontmap);
-
- ft2fontmap->serial++;
- if (ft2fontmap->serial == 0)
- ft2fontmap->serial++;
-}
-
-/**
- * pango_ft2_font_map_set_resolution:
- * @fontmap: a `PangoFT2FontMap`
- * @dpi_x: dots per inch in the X direction
- * @dpi_y: dots per inch in the Y direction
- *
- * Sets the horizontal and vertical resolutions for the fontmap.
- *
- * Since: 1.2
- **/
-void
-pango_ft2_font_map_set_resolution (PangoFT2FontMap *fontmap,
- double dpi_x,
- double dpi_y)
-{
- g_return_if_fail (PANGO_FT2_IS_FONT_MAP (fontmap));
-
- fontmap->dpi_x = dpi_x;
- fontmap->dpi_y = dpi_y;
-
- pango_fc_font_map_substitute_changed (PANGO_FC_FONT_MAP (fontmap));
-}
-
-FT_Library
-_pango_ft2_font_map_get_library (PangoFontMap *fontmap)
-{
- PangoFT2FontMap *ft2fontmap = (PangoFT2FontMap *)fontmap;
-
- return ft2fontmap->library;
-}
-
-
-/**
- * _pango_ft2_font_map_get_renderer:
- * @fontmap: a `PangoFT2FontMap`
- *
- * Gets the singleton PangoFT2Renderer for this fontmap.
- *
- * Return value: the renderer.
- **/
-PangoRenderer *
-_pango_ft2_font_map_get_renderer (PangoFT2FontMap *ft2fontmap)
-{
- if (!ft2fontmap->renderer)
- ft2fontmap->renderer = g_object_new (PANGO_TYPE_FT2_RENDERER, NULL);
-
- return ft2fontmap->renderer;
-}
-
-void
-_pango_ft2_font_map_default_substitute (PangoFcFontMap *fcfontmap,
- FcPattern *pattern)
-{
- PangoFT2FontMap *ft2fontmap = PANGO_FT2_FONT_MAP (fcfontmap);
- FcValue v;
-
- FcConfigSubstitute (NULL, pattern, FcMatchPattern);
-
- if (fcfontmap->substitute_func)
- fcfontmap->substitute_func (pattern, fcfontmap->substitute_data);
-
- if (FcPatternGet (pattern, FC_DPI, 0, &v) == FcResultNoMatch)
- FcPatternAddDouble (pattern, FC_DPI, ft2fontmap->dpi_y);
- FcDefaultSubstitute (pattern);
-}
-
-static double
-pango_ft2_font_map_get_resolution (PangoFcFontMap *fcfontmap,
- PangoContext *context G_GNUC_UNUSED)
-{
- return ((PangoFT2FontMap *)fcfontmap)->dpi_y;
-}
-
-static PangoFcFont *
-pango_ft2_font_map_new_font (PangoFcFontMap *fcfontmap,
- FcPattern *pattern)
-{
- return (PangoFcFont *)_pango_ft2_font_new (PANGO_FT2_FONT_MAP (fcfontmap), pattern);
-}
diff --git a/pango/pangoft2-private.h b/pango/pangoft2-private.h
deleted file mode 100644
index ba16d2de..00000000
--- a/pango/pangoft2-private.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Pango
- * pangoft2-private.h:
- *
- * Copyright (C) 1999 Red Hat Software
- * Copyright (C) 2000 Tor Lillqvist
- *
- * 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 __PANGOFT2_PRIVATE_H__
-#define __PANGOFT2_PRIVATE_H__
-
-#include <pango/pangoft2.h>
-#include <pango/pangofc-fontmap-private.h>
-#include <pango/pango-renderer.h>
-#include <fontconfig/fontconfig.h>
-
-/* Debugging... */
-/*#define DEBUGGING 1*/
-
-#if defined(DEBUGGING) && DEBUGGING
-#ifdef __GNUC__
-#define PING(printlist) \
-(g_print ("%s:%d ", __PRETTY_FUNCTION__, __LINE__), \
- g_print printlist, \
- g_print ("\n"))
-#else
-#define PING(printlist) \
-(g_print ("%s:%d ", __FILE__, __LINE__), \
- g_print printlist, \
- g_print ("\n"))
-#endif
-#else /* !DEBUGGING */
-#define PING(printlist)
-#endif
-
-typedef struct _PangoFT2Font PangoFT2Font;
-typedef struct _PangoFT2GlyphInfo PangoFT2GlyphInfo;
-typedef struct _PangoFT2Renderer PangoFT2Renderer;
-
-struct _PangoFT2Font
-{
- PangoFcFont font;
-
- FT_Face face;
- int load_flags;
-
- int size;
-
- GSList *metrics_by_lang;
-
- GHashTable *glyph_info;
- GDestroyNotify glyph_cache_destroy;
-};
-
-struct _PangoFT2GlyphInfo
-{
- PangoRectangle logical_rect;
- PangoRectangle ink_rect;
- void *cached_glyph;
-};
-
-#define PANGO_TYPE_FT2_FONT (pango_ft2_font_get_type ())
-#define PANGO_FT2_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FT2_FONT, PangoFT2Font))
-#define PANGO_FT2_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FT2_FONT))
-
-_PANGO_EXTERN
-GType pango_ft2_font_get_type (void) G_GNUC_CONST;
-
-PangoFT2Font * _pango_ft2_font_new (PangoFT2FontMap *ft2fontmap,
- FcPattern *pattern);
-FT_Library _pango_ft2_font_map_get_library (PangoFontMap *fontmap);
-void _pango_ft2_font_map_default_substitute (PangoFcFontMap *fcfontmap,
- FcPattern *pattern);
-
-void *_pango_ft2_font_get_cache_glyph_data (PangoFont *font,
- int glyph_index);
-void _pango_ft2_font_set_cache_glyph_data (PangoFont *font,
- int glyph_index,
- void *cached_glyph);
-void _pango_ft2_font_set_glyph_cache_destroy (PangoFont *font,
- GDestroyNotify destroy_notify);
-
-#define PANGO_TYPE_FT2_RENDERER (pango_ft2_renderer_get_type())
-#define PANGO_FT2_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FT2_RENDERER, PangoFT2Renderer))
-#define PANGO_IS_FT2_RENDERER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FT2_RENDERER))
-
-_PANGO_EXTERN
-GType pango_ft2_renderer_get_type (void) G_GNUC_CONST;
-
-PangoRenderer *_pango_ft2_font_map_get_renderer (PangoFT2FontMap *ft2fontmap);
-
-#endif /* __PANGOFT2_PRIVATE_H__ */
diff --git a/pango/pangoft2-render.c b/pango/pangoft2-render.c
deleted file mode 100644
index ebe0e0e3..00000000
--- a/pango/pangoft2-render.c
+++ /dev/null
@@ -1,761 +0,0 @@
-/* Pango
- * pangoft2-render.c: Rendering routines to FT_Bitmap objects
- *
- * Copyright (C) 2004 Red Hat Software
- * Copyright (C) 2000 Tor Lillqvist
- *
- * 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 "config.h"
-#include <math.h>
-
-#include "pango-font-private.h"
-#include "pangoft2-private.h"
-#include "pango-impl-utils.h"
-
-/* for compatibility with older freetype versions */
-#ifndef FT_LOAD_TARGET_MONO
-#define FT_LOAD_TARGET_MONO FT_LOAD_MONOCHROME
-#endif
-
-typedef struct _PangoFT2RendererClass PangoFT2RendererClass;
-
-#define PANGO_FT2_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FT2_RENDERER, PangoFT2RendererClass))
-#define PANGO_IS_FT2_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FT2_RENDERER))
-#define PANGO_FT2_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FT2_RENDERER, PangoFT2RendererClass))
-
-struct _PangoFT2Renderer
-{
- PangoRenderer parent_instance;
-
- FT_Bitmap *bitmap;
-};
-
-struct _PangoFT2RendererClass
-{
- PangoRendererClass parent_class;
-};
-
-static void pango_ft2_renderer_draw_glyph (PangoRenderer *renderer,
- PangoFont *font,
- PangoGlyph glyph,
- double x,
- double y);
-static void pango_ft2_renderer_draw_trapezoid (PangoRenderer *renderer,
- PangoRenderPart part,
- double y1,
- double x11,
- double x21,
- double y2,
- double x12,
- double x22);
-
-G_DEFINE_TYPE (PangoFT2Renderer, pango_ft2_renderer, PANGO_TYPE_RENDERER)
-
-static void
-pango_ft2_renderer_init (PangoFT2Renderer *renderer G_GNUC_UNUSED)
-{
-}
-
-static void
-pango_ft2_renderer_class_init (PangoFT2RendererClass *klass)
-{
- PangoRendererClass *renderer_class = PANGO_RENDERER_CLASS (klass);
-
- renderer_class->draw_glyph = pango_ft2_renderer_draw_glyph;
- renderer_class->draw_trapezoid = pango_ft2_renderer_draw_trapezoid;
-}
-
-static void
-pango_ft2_renderer_set_bitmap (PangoFT2Renderer *renderer,
- FT_Bitmap *bitmap)
-{
- renderer->bitmap = bitmap;
-}
-
-typedef struct
-{
- FT_Bitmap bitmap;
- int bitmap_left;
- int bitmap_top;
-} PangoFT2RenderedGlyph;
-
-static void
-pango_ft2_free_rendered_glyph (PangoFT2RenderedGlyph *rendered)
-{
- g_free (rendered->bitmap.buffer);
- g_slice_free (PangoFT2RenderedGlyph, rendered);
-}
-
-static PangoFT2RenderedGlyph *
-pango_ft2_font_render_box_glyph (int width,
- int height,
- int top,
- gboolean invalid)
-{
- PangoFT2RenderedGlyph *box;
- int i, j, offset1, offset2, line_width;
-
- line_width = MAX ((height + 43) / 44, 1);
- if (width < 1 || height < 1)
- line_width = 0;
-
- box = g_slice_new (PangoFT2RenderedGlyph);
-
- box->bitmap_left = 0;
- box->bitmap_top = top;
-
- box->bitmap.pixel_mode = ft_pixel_mode_grays;
-
- box->bitmap.width = width;
- box->bitmap.rows = height;
- box->bitmap.pitch = width;
-
- box->bitmap.buffer = g_malloc0_n (box->bitmap.rows, box->bitmap.pitch);
-
- if (G_UNLIKELY (!box->bitmap.buffer)) {
- g_slice_free (PangoFT2RenderedGlyph, box);
- return NULL;
- }
-
- /* draw the box */
- for (j = 0; j < line_width; j++)
- {
- offset1 = box->bitmap.pitch * (MIN (1 + j, height - 1));
- offset2 = box->bitmap.pitch * (MAX (box->bitmap.rows - 2 - j, 0));
- for (i = 1;
- i < (int) box->bitmap.width - 1;
- i++)
- {
- box->bitmap.buffer[offset1 + i] = 0xff;
- box->bitmap.buffer[offset2 + i] = 0xff;
- }
- }
- for (j = 0; j < line_width; j++)
- {
- offset1 = MIN (1 + j, width - 1);
- offset2 = MAX ((int) box->bitmap.width - 2 - j, 0);
- for (i = box->bitmap.pitch;
- i < (int) (box->bitmap.rows - 1) * box->bitmap.pitch;
- i += box->bitmap.pitch)
- {
- box->bitmap.buffer[offset1 + i] = 0xff;
- box->bitmap.buffer[offset2 + i] = 0xff;
- }
- }
-
- if (invalid)
- {
- /* XXX This may scrabble memory. Didn't check close enough */
- int inc = PANGO_SCALE * MAX (width - line_width, 0) / (height + 1);
- offset1 = PANGO_SCALE;
- offset2 = PANGO_SCALE * MAX (width - line_width - 1, 0) ;
- for (i = box->bitmap.pitch;
- i < (int) (box->bitmap.rows - 1) * box->bitmap.pitch;
- i += box->bitmap.pitch)
- {
- for (j = 0; j < line_width; j++)
- {
- box->bitmap.buffer[PANGO_PIXELS (offset1) + i + j] = 0xff;
- box->bitmap.buffer[PANGO_PIXELS (offset2) + i + j] = 0xff;
- }
- offset1 += inc;
- offset2 -= inc;
- }
-
- }
-
- return box;
-}
-
-static PangoFT2RenderedGlyph *
-pango_ft2_font_render_glyph (PangoFont *font,
- PangoGlyph glyph_index)
-{
- FT_Face face;
- gboolean invalid_input;
-
- invalid_input = glyph_index == PANGO_GLYPH_INVALID_INPUT || (glyph_index & ~PANGO_GLYPH_UNKNOWN_FLAG) > 0x10FFFF;
-
- if (glyph_index & PANGO_GLYPH_UNKNOWN_FLAG)
- {
- PangoFT2RenderedGlyph *box;
- PangoFontMetrics *metrics;
-
- if (!font)
- goto generic_box;
-
- metrics = pango_font_get_metrics (font, NULL);
- if (!metrics)
- goto generic_box;
-
- box = pango_ft2_font_render_box_glyph (PANGO_PIXELS (metrics->approximate_char_width),
- PANGO_PIXELS (metrics->ascent + metrics->descent),
- PANGO_PIXELS (metrics->ascent),
- invalid_input);
- pango_font_metrics_unref (metrics);
-
- return box;
- }
-
- face = pango_fc_font_lock_face (PANGO_FC_FONT (font));
-
- if (face)
- {
- PangoFT2RenderedGlyph *rendered;
- PangoFT2Font *ft2font = (PangoFT2Font *) font;
-
- rendered = g_slice_new (PangoFT2RenderedGlyph);
-
- /* Draw glyph */
- FT_Load_Glyph (face, glyph_index, ft2font->load_flags);
- FT_Render_Glyph (face->glyph,
- (ft2font->load_flags & FT_LOAD_TARGET_MONO ?
- ft_render_mode_mono : ft_render_mode_normal));
-
- rendered->bitmap = face->glyph->bitmap;
- rendered->bitmap.buffer = g_memdup2 (face->glyph->bitmap.buffer,
- face->glyph->bitmap.rows * face->glyph->bitmap.pitch);
- rendered->bitmap_left = face->glyph->bitmap_left;
- rendered->bitmap_top = face->glyph->bitmap_top;
-
- pango_fc_font_unlock_face (PANGO_FC_FONT (font));
-
- if (G_UNLIKELY (!rendered->bitmap.buffer)) {
- g_slice_free (PangoFT2RenderedGlyph, rendered);
- return NULL;
- }
-
- return rendered;
- }
- else
- {
-generic_box:
- return pango_ft2_font_render_box_glyph (PANGO_UNKNOWN_GLYPH_WIDTH,
- PANGO_UNKNOWN_GLYPH_HEIGHT,
- PANGO_UNKNOWN_GLYPH_HEIGHT,
- invalid_input);
- }
-}
-
-static void
-pango_ft2_renderer_draw_glyph (PangoRenderer *renderer,
- PangoFont *font,
- PangoGlyph glyph,
- double x,
- double y)
-{
- FT_Bitmap *bitmap = PANGO_FT2_RENDERER (renderer)->bitmap;
- PangoFT2RenderedGlyph *rendered_glyph;
- gboolean add_glyph_to_cache;
- guchar *src, *dest;
-
- int x_start, x_limit;
- int y_start, y_limit;
- int ixoff = floor (x + 0.5);
- int iyoff = floor (y + 0.5);
- int ix, iy;
-
- if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
- {
- /* Since we don't draw hexbox for FT2 renderer,
- * unifiy the rendered bitmap in the cache by converting
- * all missing glyphs to either INVALID_INPUT or UNKNOWN_FLAG.
- */
-
- gunichar wc = glyph & (~PANGO_GLYPH_UNKNOWN_FLAG);
-
- if (G_UNLIKELY (glyph == PANGO_GLYPH_INVALID_INPUT || wc > 0x10FFFF))
- glyph = PANGO_GLYPH_INVALID_INPUT;
- else
- glyph = PANGO_GLYPH_UNKNOWN_FLAG;
- }
-
- rendered_glyph = _pango_ft2_font_get_cache_glyph_data (font, glyph);
- add_glyph_to_cache = FALSE;
- if (rendered_glyph == NULL)
- {
- rendered_glyph = pango_ft2_font_render_glyph (font, glyph);
- if (rendered_glyph == NULL)
- return;
- add_glyph_to_cache = TRUE;
- }
-
- x_start = MAX (0, - (ixoff + rendered_glyph->bitmap_left));
- x_limit = MIN ((int) rendered_glyph->bitmap.width,
- (int) (bitmap->width - (ixoff + rendered_glyph->bitmap_left)));
-
- y_start = MAX (0, - (iyoff - rendered_glyph->bitmap_top));
- y_limit = MIN ((int) rendered_glyph->bitmap.rows,
- (int) (bitmap->rows - (iyoff - rendered_glyph->bitmap_top)));
-
- src = rendered_glyph->bitmap.buffer +
- y_start * rendered_glyph->bitmap.pitch;
-
- dest = bitmap->buffer +
- (y_start + iyoff - rendered_glyph->bitmap_top) * bitmap->pitch +
- x_start + ixoff + rendered_glyph->bitmap_left;
-
- switch (rendered_glyph->bitmap.pixel_mode)
- {
- case ft_pixel_mode_grays:
- src += x_start;
- for (iy = y_start; iy < y_limit; iy++)
- {
- guchar *s = src;
- guchar *d = dest;
-
- for (ix = x_start; ix < x_limit; ix++)
- {
- switch (*s)
- {
- case 0:
- break;
- case 0xff:
- *d = 0xff;
- break;
- default:
- *d = MIN ((gushort) *d + (gushort) *s, 0xff);
- break;
- }
-
- s++;
- d++;
- }
-
- dest += bitmap->pitch;
- src += rendered_glyph->bitmap.pitch;
- }
- break;
-
- case ft_pixel_mode_mono:
- src += x_start / 8;
- for (iy = y_start; iy < y_limit; iy++)
- {
- guchar *s = src;
- guchar *d = dest;
-
- for (ix = x_start; ix < x_limit; ix++)
- {
- if ((*s) & (1 << (7 - (ix % 8))))
- *d |= 0xff;
-
- if ((ix % 8) == 7)
- s++;
- d++;
- }
-
- dest += bitmap->pitch;
- src += rendered_glyph->bitmap.pitch;
- }
- break;
-
- default:
- g_warning ("pango_ft2_render: "
- "Unrecognized glyph bitmap pixel mode %d\n",
- rendered_glyph->bitmap.pixel_mode);
- break;
- }
-
- if (add_glyph_to_cache)
- {
- _pango_ft2_font_set_glyph_cache_destroy (font,
- (GDestroyNotify) pango_ft2_free_rendered_glyph);
- _pango_ft2_font_set_cache_glyph_data (font,
- glyph, rendered_glyph);
- }
-}
-
-typedef struct {
- double y;
- double x1;
- double x2;
-} Position;
-
-static void
-draw_simple_trap (PangoRenderer *renderer,
- Position *t,
- Position *b)
-{
- FT_Bitmap *bitmap = PANGO_FT2_RENDERER (renderer)->bitmap;
- int iy = floor (t->y);
- int x1, x2, x;
- double dy = b->y - t->y;
- guchar *dest;
-
- if (iy < 0 || iy >= (int) bitmap->rows)
- return;
- dest = bitmap->buffer + iy * bitmap->pitch;
-
- if (t->x1 < b->x1)
- x1 = floor (t->x1);
- else
- x1 = floor (b->x1);
-
- if (t->x2 > b->x2)
- x2 = ceil (t->x2);
- else
- x2 = ceil (b->x2);
-
- x1 = CLAMP (x1, 0, (int) bitmap->width);
- x2 = CLAMP (x2, 0, (int) bitmap->width);
-
- for (x = x1; x < x2; x++)
- {
- double top_left = MAX (t->x1, x);
- double top_right = MIN (t->x2, x + 1);
- double bottom_left = MAX (b->x1, x);
- double bottom_right = MIN (b->x2, x + 1);
- double c = 0.5 * dy * ((top_right - top_left) + (bottom_right - bottom_left));
-
- /* When converting to [0,255], we round up. This is intended
- * to prevent the problem of pixels that get divided into
- * multiple slices not being fully black.
- */
- int ic = c * 256;
-
- dest[x] = MIN (dest[x] + ic, 255);
- }
-}
-
-static void
-interpolate_position (Position *result,
- Position *top,
- Position *bottom,
- double val,
- double val1,
- double val2)
-{
- result->y = (top->y * (val2 - val) + bottom->y * (val - val1)) / (val2 - val1);
- result->x1 = (top->x1 * (val2 - val) + bottom->x1 * (val - val1)) / (val2 - val1);
- result->x2 = (top->x2 * (val2 - val) + bottom->x2 * (val - val1)) / (val2 - val1);
-}
-
-/* This draws a trapezoid with the parallel sides aligned with
- * the X axis. We do this by subdividing the trapezoid vertically
- * into thin slices (themselves trapezoids) where two edge sides are each
- * contained within a single pixel and then rasterizing each
- * slice. There are frequently multiple slices within a single
- * line so we have to accumulate to get the final result.
- */
-static void
-pango_ft2_renderer_draw_trapezoid (PangoRenderer *renderer,
- PangoRenderPart part G_GNUC_UNUSED,
- double y1,
- double x11,
- double x21,
- double y2,
- double x12,
- double x22)
-{
- Position pos;
- Position t;
- Position b;
- gboolean done = FALSE;
-
- if (y1 == y2)
- return;
-
- pos.y = t.y = y1;
- pos.x1 = t.x1 = x11;
- pos.x2 = t.x2 = x21;
- b.y = y2;
- b.x1 = x12;
- b.x2 = x22;
-
- while (!done)
- {
- Position pos_next;
- double y_next, x1_next, x2_next;
- double ix1, ix2;
-
- /* The algorithm here is written to emphasize simplicity and
- * numerical stability as opposed to speed.
- *
- * While the end result is slicing up the polygon vertically,
- * conceptually we aren't walking in the X direction, rather we
- * are walking along the edges. When we compute crossing of
- * horizontal pixel boundaries, we use the X coordinate as the
- * interpolating variable, when we compute crossing for vertical
- * pixel boundaries, we use the Y coordinate.
- *
- * This allows us to handle almost exactly horizontal edges without
- * running into difficulties. (Almost exactly horizontal edges
- * come up frequently due to inexactness in computing, say,
- * a 90 degree rotation transformation)
- */
-
- pos_next = b;
- done = TRUE;
-
- /* Check for crossing vertical pixel boundaries */
- y_next = floor (pos.y) + 1;
- if (y_next < pos_next.y)
- {
- interpolate_position (&pos_next, &t, &b,
- y_next, t.y, b.y);
- pos_next.y = y_next;
- done = FALSE;
- }
-
- /* Check left side for crossing horizontal pixel boundaries */
- ix1 = floor (pos.x1);
-
- if (b.x1 < t.x1)
- {
- if (ix1 == pos.x1)
- x1_next = ix1 - 1;
- else
- x1_next = ix1;
-
- if (x1_next > pos_next.x1)
- {
- interpolate_position (&pos_next, &t, &b,
- x1_next, t.x1, b.x1);
- pos_next.x1 = x1_next;
- done = FALSE;
- }
- }
- else if (b.x1 > t.x1)
- {
- x1_next = ix1 + 1;
-
- if (x1_next < pos_next.x1)
- {
- interpolate_position (&pos_next, &t, &b,
- x1_next, t.x1, b.x1);
- pos_next.x1 = x1_next;
- done = FALSE;
- }
- }
-
- /* Check right side for crossing horizontal pixel boundaries */
- ix2 = floor (pos.x2);
-
- if (b.x2 < t.x2)
- {
- if (ix2 == pos.x2)
- x2_next = ix2 - 1;
- else
- x2_next = ix2;
-
- if (x2_next > pos_next.x2)
- {
- interpolate_position (&pos_next, &t, &b,
- x2_next, t.x2, b.x2);
- pos_next.x2 = x2_next;
- done = FALSE;
- }
- }
- else if (x22 > x21)
- {
- x2_next = ix2 + 1;
-
- if (x2_next < pos_next.x2)
- {
- interpolate_position (&pos_next, &t, &b,
- x2_next, t.x2, b.x2);
- pos_next.x2 = x2_next;
- done = FALSE;
- }
- }
-
- draw_simple_trap (renderer, &pos, &pos_next);
- pos = pos_next;
- }
-}
-
-/**
- * pango_ft2_render_layout_subpixel:
- * @bitmap: a FT_Bitmap to render the layout onto
- * @layout: a `PangoLayout`
- * @x: the X position of the left of the layout (in Pango units)
- * @y: the Y position of the top of the layout (in Pango units)
- *
- * Render a `PangoLayout` onto a FreeType2 bitmap, with he
- * location specified in fixed-point Pango units rather than
- * pixels.
- *
- * (Using this will avoid extra inaccuracies from rounding
- * to integer pixels multiple times, even if the final glyph
- * positions are integers.)
- *
- * Since: 1.6
- */
-void
-pango_ft2_render_layout_subpixel (FT_Bitmap *bitmap,
- PangoLayout *layout,
- int x,
- int y)
-{
- PangoContext *context;
- PangoFontMap *fontmap;
- PangoRenderer *renderer;
-
- g_return_if_fail (bitmap != NULL);
- g_return_if_fail (PANGO_IS_LAYOUT (layout));
-
- context = pango_layout_get_context (layout);
- fontmap = pango_context_get_font_map (context);
- renderer = _pango_ft2_font_map_get_renderer (PANGO_FT2_FONT_MAP (fontmap));
-
- pango_ft2_renderer_set_bitmap (PANGO_FT2_RENDERER (renderer), bitmap);
-
- pango_renderer_draw_layout (renderer, layout, x, y);
-}
-
-/**
- * pango_ft2_render_layout:
- * @bitmap: a FT_Bitmap to render the layout onto
- * @layout: a `PangoLayout`
- * @x: the X position of the left of the layout (in pixels)
- * @y: the Y position of the top of the layout (in pixels)
- *
- * Render a `PangoLayout` onto a FreeType2 bitmap
- */
-void
-pango_ft2_render_layout (FT_Bitmap *bitmap,
- PangoLayout *layout,
- int x,
- int y)
-{
- pango_ft2_render_layout_subpixel (bitmap, layout, x * PANGO_SCALE, y * PANGO_SCALE);
-}
-
-/**
- * pango_ft2_render_layout_line_subpixel:
- * @bitmap: a FT_Bitmap to render the line onto
- * @line: a `PangoLayoutLine`
- * @x: the x position of start of string (in Pango units)
- * @y: the y position of baseline (in Pango units)
- *
- * Render a `PangoLayoutLine` onto a FreeType2 bitmap, with he
- * location specified in fixed-point Pango units rather than
- * pixels.
- *
- * (Using this will avoid extra inaccuracies from rounding
- * to integer pixels multiple times, even if the final glyph
- * positions are integers.)
- *
- * Since: 1.6
- */
-void
-pango_ft2_render_layout_line_subpixel (FT_Bitmap *bitmap,
- PangoLayoutLine *line,
- int x,
- int y)
-{
- PangoContext *context;
- PangoFontMap *fontmap;
- PangoRenderer *renderer;
-
- g_return_if_fail (bitmap != NULL);
- g_return_if_fail (line != NULL);
-
- context = pango_layout_get_context (line->layout);
- fontmap = pango_context_get_font_map (context);
- renderer = _pango_ft2_font_map_get_renderer (PANGO_FT2_FONT_MAP (fontmap));
-
- pango_ft2_renderer_set_bitmap (PANGO_FT2_RENDERER (renderer), bitmap);
-
- pango_renderer_draw_layout_line (renderer, line, x, y);
-}
-
-/**
- * pango_ft2_render_layout_line:
- * @bitmap: a FT_Bitmap to render the line onto
- * @line: a `PangoLayoutLine`
- * @x: the x position of start of string (in pixels)
- * @y: the y position of baseline (in pixels)
- *
- * Render a `PangoLayoutLine` onto a FreeType2 bitmap
- */
-void
-pango_ft2_render_layout_line (FT_Bitmap *bitmap,
- PangoLayoutLine *line,
- int x,
- int y)
-{
- pango_ft2_render_layout_line_subpixel (bitmap, line, x * PANGO_SCALE, y * PANGO_SCALE);
-}
-
-/**
- * pango_ft2_render_transformed:
- * @bitmap: the FreeType2 bitmap onto which to draw the string
- * @font: the font in which to draw the string
- * @matrix: (nullable): a `PangoMatrix`
- * @glyphs: the glyph string to draw
- * @x: the x position of the start of the string (in Pango
- * units in user space coordinates)
- * @y: the y position of the baseline (in Pango units
- * in user space coordinates)
- *
- * Renders a `PangoGlyphString` onto a FreeType2 bitmap, possibly
- * transforming the layed-out coordinates through a transformation
- * matrix.
- *
- * Note that the transformation matrix for @font is not
- * changed, so to produce correct rendering results, the @font
- * must have been loaded using a `PangoContext` with an identical
- * transformation matrix to that passed in to this function.
- *
- * Since: 1.6
- */
-void
-pango_ft2_render_transformed (FT_Bitmap *bitmap,
- const PangoMatrix *matrix,
- PangoFont *font,
- PangoGlyphString *glyphs,
- int x,
- int y)
-{
- PangoFontMap *fontmap;
- PangoRenderer *renderer;
-
- g_return_if_fail (bitmap != NULL);
- g_return_if_fail (glyphs != NULL);
- g_return_if_fail (PANGO_FT2_IS_FONT (font));
-
- fontmap = PANGO_FC_FONT (font)->fontmap;
- renderer = _pango_ft2_font_map_get_renderer (PANGO_FT2_FONT_MAP (fontmap));
-
- pango_ft2_renderer_set_bitmap (PANGO_FT2_RENDERER (renderer), bitmap);
- pango_renderer_set_matrix (renderer, matrix);
-
- pango_renderer_draw_glyphs (renderer, font, glyphs, x, y);
-}
-
-/**
- * pango_ft2_render:
- * @bitmap: the FreeType2 bitmap onto which to draw the string
- * @font: the font in which to draw the string
- * @glyphs: the glyph string to draw
- * @x: the x position of the start of the string (in pixels)
- * @y: the y position of the baseline (in pixels)
- *
- * Renders a `PangoGlyphString` onto a FreeType2 bitmap.
- */
-void
-pango_ft2_render (FT_Bitmap *bitmap,
- PangoFont *font,
- PangoGlyphString *glyphs,
- int x,
- int y)
-{
- pango_ft2_render_transformed (bitmap, NULL, font, glyphs, x * PANGO_SCALE, y * PANGO_SCALE);
-}
-
diff --git a/pango/pangoft2.c b/pango/pangoft2.c
deleted file mode 100644
index d768fcd8..00000000
--- a/pango/pangoft2.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/* Pango
- * pangoft2.c: Routines for handling FreeType2 fonts
- *
- * Copyright (C) 1999 Red Hat Software
- * Copyright (C) 2000 Tor Lillqvist
- *
- * 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 "config.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-#include <glib.h>
-#include <glib/gprintf.h>
-
-#include "pangoft2.h"
-#include "pangoft2-private.h"
-#include "pangofc-fontmap-private.h"
-#include "pangofc-private.h"
-
-/* for compatibility with older freetype versions */
-#ifndef FT_LOAD_TARGET_MONO
-#define FT_LOAD_TARGET_MONO FT_LOAD_MONOCHROME
-#endif
-
-#define PANGO_FT2_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FT2_FONT, PangoFT2FontClass))
-#define PANGO_FT2_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FT2_FONT))
-#define PANGO_FT2_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FT2_FONT, PangoFT2FontClass))
-
-typedef struct _PangoFT2FontClass PangoFT2FontClass;
-
-struct _PangoFT2FontClass
-{
- PangoFcFontClass parent_class;
-};
-
-static void pango_ft2_font_finalize (GObject *object);
-
-static void pango_ft2_font_get_glyph_extents (PangoFont *font,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect);
-
-static FT_Face pango_ft2_font_real_lock_face (PangoFcFont *font);
-static void pango_ft2_font_real_unlock_face (PangoFcFont *font);
-
-
-PangoFT2Font *
-_pango_ft2_font_new (PangoFT2FontMap *ft2fontmap,
- FcPattern *pattern)
-{
- PangoFontMap *fontmap = PANGO_FONT_MAP (ft2fontmap);
- PangoFT2Font *ft2font;
- double d;
-
- g_return_val_if_fail (fontmap != NULL, NULL);
- g_return_val_if_fail (pattern != NULL, NULL);
-
- ft2font = (PangoFT2Font *)g_object_new (PANGO_TYPE_FT2_FONT,
- "pattern", pattern,
- "fontmap", fontmap,
- NULL);
-
- if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &d) == FcResultMatch)
- ft2font->size = d*PANGO_SCALE;
-
- return ft2font;
-}
-
-static void
-load_fallback_face (PangoFT2Font *ft2font,
- const char *original_file)
-{
- PangoFcFont *fcfont = PANGO_FC_FONT (ft2font);
- FcPattern *sans;
- FcPattern *matched;
- FcResult result;
- FT_Error error;
- FcChar8 *filename2 = NULL;
- gchar *name;
- int id;
-
- sans = FcPatternBuild (NULL,
- FC_FAMILY, FcTypeString, "sans",
- FC_PIXEL_SIZE, FcTypeDouble, (double)ft2font->size / PANGO_SCALE,
- NULL);
-
- _pango_ft2_font_map_default_substitute ((PangoFcFontMap *)fcfont->fontmap, sans);
-
- matched = FcFontMatch (pango_fc_font_map_get_config ((PangoFcFontMap *)fcfont->fontmap), sans, &result);
-
- if (FcPatternGetString (matched, FC_FILE, 0, &filename2) != FcResultMatch)
- goto bail1;
-
- if (FcPatternGetInteger (matched, FC_INDEX, 0, &id) != FcResultMatch)
- goto bail1;
-
- error = FT_New_Face (_pango_ft2_font_map_get_library (fcfont->fontmap),
- (char *) filename2, id, &ft2font->face);
-
-
- if (error)
- {
- bail1:
- name = pango_font_description_to_string (fcfont->description);
- g_error ("Unable to open font file %s for font %s, exiting\n", filename2, name);
- }
- else
- {
- name = pango_font_description_to_string (fcfont->description);
- g_warning ("Unable to open font file %s for font %s, falling back to %s\n", original_file, name, filename2);
- g_free (name);
- }
-
- FcPatternDestroy (sans);
- FcPatternDestroy (matched);
-}
-
-static void
-set_transform (PangoFT2Font *ft2font)
-{
- PangoFcFont *fcfont = (PangoFcFont *)ft2font;
- FcMatrix *fc_matrix;
-
- if (FcPatternGetMatrix (fcfont->font_pattern, FC_MATRIX, 0, &fc_matrix) == FcResultMatch)
- {
- FT_Matrix ft_matrix;
-
- ft_matrix.xx = 0x10000L * fc_matrix->xx;
- ft_matrix.yy = 0x10000L * fc_matrix->yy;
- ft_matrix.xy = 0x10000L * fc_matrix->xy;
- ft_matrix.yx = 0x10000L * fc_matrix->yx;
-
- FT_Set_Transform (ft2font->face, &ft_matrix, NULL);
- }
-}
-
-static FT_Face
-pango_ft2_font_get_face (PangoFont *font)
-{
- PangoFT2Font *ft2font = (PangoFT2Font *)font;
- PangoFcFont *fcfont = (PangoFcFont *)font;
- FT_Error error;
- FcPattern *pattern;
- FcChar8 *filename;
- FcBool antialias, hinting, autohint;
- int hintstyle;
- int id;
-
- if (G_UNLIKELY (!font))
- return NULL;
-
- pattern = fcfont->font_pattern;
-
- if (!ft2font->face)
- {
- ft2font->load_flags = 0;
-
- /* disable antialiasing if requested */
- if (FcPatternGetBool (pattern,
- FC_ANTIALIAS, 0, &antialias) != FcResultMatch)
- antialias = FcTrue;
-
- if (antialias)
- 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)
- hinting = FcTrue;
-
-#ifdef FC_HINT_STYLE
- if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hintstyle) != FcResultMatch)
- hintstyle = FC_HINT_FULL;
-
- if (!hinting || hintstyle == FC_HINT_NONE)
- ft2font->load_flags |= FT_LOAD_NO_HINTING;
-
- switch (hintstyle) {
- case FC_HINT_SLIGHT:
- case FC_HINT_MEDIUM:
- ft2font->load_flags |= FT_LOAD_TARGET_LIGHT;
- break;
- default:
- ft2font->load_flags |= FT_LOAD_TARGET_NORMAL;
- break;
- }
-#else
- if (!hinting)
- ft2font->load_flags |= FT_LOAD_NO_HINTING;
-#endif
-
- /* force autohinting if requested */
- if (FcPatternGetBool (pattern,
- FC_AUTOHINT, 0, &autohint) != FcResultMatch)
- autohint = FcFalse;
-
- if (autohint)
- ft2font->load_flags |= FT_LOAD_FORCE_AUTOHINT;
-
- if (FcPatternGetString (pattern, FC_FILE, 0, &filename) != FcResultMatch)
- goto bail0;
-
- if (FcPatternGetInteger (pattern, FC_INDEX, 0, &id) != FcResultMatch)
- goto bail0;
-
- error = FT_New_Face (_pango_ft2_font_map_get_library (fcfont->fontmap),
- (char *) filename, id, &ft2font->face);
- if (error != FT_Err_Ok)
- {
- bail0:
- load_fallback_face (ft2font, (char *) filename);
- }
-
- g_assert (ft2font->face);
-
- set_transform (ft2font);
-
- error = FT_Set_Char_Size (ft2font->face,
- PANGO_PIXELS_26_6 (ft2font->size),
- PANGO_PIXELS_26_6 (ft2font->size),
- 0, 0);
- if (error)
- g_warning ("Error in FT_Set_Char_Size: %d", error);
- }
-
- return ft2font->face;
-}
-
-G_DEFINE_TYPE (PangoFT2Font, pango_ft2_font, PANGO_TYPE_FC_FONT)
-
-static void
-pango_ft2_font_init (PangoFT2Font *ft2font)
-{
- ft2font->face = NULL;
-
- ft2font->size = 0;
-
- ft2font->glyph_info = g_hash_table_new (NULL, NULL);
-}
-
-static void
-pango_ft2_font_class_init (PangoFT2FontClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- PangoFontClass *font_class = PANGO_FONT_CLASS (class);
- PangoFcFontClass *fc_font_class = PANGO_FC_FONT_CLASS (class);
-
- object_class->finalize = pango_ft2_font_finalize;
-
- font_class->get_glyph_extents = pango_ft2_font_get_glyph_extents;
-
- fc_font_class->lock_face = pango_ft2_font_real_lock_face;
- fc_font_class->unlock_face = pango_ft2_font_real_unlock_face;
-}
-
-static PangoFT2GlyphInfo *
-pango_ft2_font_get_glyph_info (PangoFont *font,
- PangoGlyph glyph,
- gboolean create)
-{
- PangoFT2Font *ft2font = (PangoFT2Font *)font;
- PangoFcFont *fcfont = (PangoFcFont *)font;
- PangoFT2GlyphInfo *info;
-
- info = g_hash_table_lookup (ft2font->glyph_info, GUINT_TO_POINTER (glyph));
-
- if ((info == NULL) && create)
- {
- info = g_slice_new0 (PangoFT2GlyphInfo);
-
- pango_fc_font_get_raw_extents (fcfont,
- glyph,
- &info->ink_rect,
- &info->logical_rect);
-
- g_hash_table_insert (ft2font->glyph_info, GUINT_TO_POINTER(glyph), info);
- }
-
- return info;
-}
-
-static void
-pango_ft2_font_get_glyph_extents (PangoFont *font,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
-{
- PangoFT2GlyphInfo *info;
- gboolean empty = FALSE;
-
- if (glyph == PANGO_GLYPH_EMPTY)
- {
- glyph = pango_fc_font_get_glyph ((PangoFcFont *) font, ' ');
- empty = TRUE;
- }
-
- if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
- {
- PangoFontMetrics *metrics = pango_font_get_metrics (font, NULL);
-
- if (metrics)
- {
- if (ink_rect)
- {
- ink_rect->x = PANGO_SCALE;
- ink_rect->width = metrics->approximate_char_width - 2 * PANGO_SCALE;
- ink_rect->y = - (metrics->ascent - PANGO_SCALE);
- ink_rect->height = metrics->ascent + metrics->descent - 2 * PANGO_SCALE;
- }
- if (logical_rect)
- {
- logical_rect->x = 0;
- logical_rect->width = metrics->approximate_char_width;
- logical_rect->y = -metrics->ascent;
- logical_rect->height = metrics->ascent + metrics->descent;
- }
-
- pango_font_metrics_unref (metrics);
- }
- else
- {
- if (ink_rect)
- ink_rect->x = ink_rect->y = ink_rect->height = ink_rect->width = 0;
- if (logical_rect)
- logical_rect->x = logical_rect->y = logical_rect->height = logical_rect->width = 0;
- }
- return;
- }
-
- info = pango_ft2_font_get_glyph_info (font, glyph, TRUE);
-
- if (ink_rect)
- *ink_rect = info->ink_rect;
- if (logical_rect)
- *logical_rect = info->logical_rect;
-
- if (empty)
- {
- if (ink_rect)
- ink_rect->x = ink_rect->y = ink_rect->height = ink_rect->width = 0;
- if (logical_rect)
- logical_rect->x = logical_rect->width = 0;
- return;
- }
-}
-
-static FT_Face
-pango_ft2_font_real_lock_face (PangoFcFont *font)
-{
- return pango_ft2_font_get_face ((PangoFont *)font);
-}
-
-static void
-pango_ft2_font_real_unlock_face (PangoFcFont *font G_GNUC_UNUSED)
-{
-}
-
-static gboolean
-pango_ft2_free_glyph_info_callback (gpointer key G_GNUC_UNUSED,
- gpointer value,
- gpointer data)
-{
- PangoFT2Font *font = PANGO_FT2_FONT (data);
- PangoFT2GlyphInfo *info = value;
-
- if (font->glyph_cache_destroy && info->cached_glyph)
- (*font->glyph_cache_destroy) (info->cached_glyph);
-
- g_slice_free (PangoFT2GlyphInfo, info);
- return TRUE;
-}
-
-static void
-pango_ft2_font_finalize (GObject *object)
-{
- PangoFT2Font *ft2font = (PangoFT2Font *)object;
-
- if (ft2font->face)
- {
- FT_Done_Face (ft2font->face);
- ft2font->face = NULL;
- }
-
- g_hash_table_foreach_remove (ft2font->glyph_info,
- pango_ft2_free_glyph_info_callback, object);
- g_hash_table_destroy (ft2font->glyph_info);
-
- G_OBJECT_CLASS (pango_ft2_font_parent_class)->finalize (object);
-}
-
-/* Utility functions */
-
-void *
-_pango_ft2_font_get_cache_glyph_data (PangoFont *font,
- int glyph_index)
-{
- PangoFT2GlyphInfo *info;
-
- if (!PANGO_FT2_IS_FONT (font))
- return NULL;
-
- info = pango_ft2_font_get_glyph_info (font, glyph_index, FALSE);
-
- if (info == NULL)
- return NULL;
-
- return info->cached_glyph;
-}
-
-void
-_pango_ft2_font_set_cache_glyph_data (PangoFont *font,
- int glyph_index,
- void *cached_glyph)
-{
- PangoFT2GlyphInfo *info;
-
- if (!PANGO_FT2_IS_FONT (font))
- return;
-
- info = pango_ft2_font_get_glyph_info (font, glyph_index, TRUE);
-
- info->cached_glyph = cached_glyph;
-
- /* TODO: Implement limiting of the number of cached glyphs */
-}
-
-void
-_pango_ft2_font_set_glyph_cache_destroy (PangoFont *font,
- GDestroyNotify destroy_notify)
-{
- if (!PANGO_FT2_IS_FONT (font))
- return;
-
- PANGO_FT2_FONT (font)->glyph_cache_destroy = destroy_notify;
-}
diff --git a/pango/pangoft2.h b/pango/pangoft2.h
deleted file mode 100644
index b3367816..00000000
--- a/pango/pangoft2.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Pango
- * pangoft2.h:
- *
- * Copyright (C) 1999 Red Hat Software
- * Copyright (C) 2000 Tor Lillqvist
- *
- * 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 __PANGOFT2_H__
-#define __PANGOFT2_H__
-
-#include <fontconfig/fontconfig.h>
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#include <pango/pangofc-fontmap.h>
-#include <pango/pango-layout.h>
-#include <pango/pangofc-font.h>
-
-G_BEGIN_DECLS
-
-#ifdef __GI_SCANNER__
-#define PANGO_FT2_TYPE_FONT_MAP (pango_ft2_font_map_get_type ())
-#define PANGO_FT2_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_FT2_TYPE_FONT_MAP, PangoFT2FontMap))
-#define PANGO_FT2_IS_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_FT2_TYPE_FONT_MAP))
-#else
-#define PANGO_TYPE_FT2_FONT_MAP (pango_ft2_font_map_get_type ())
-#define PANGO_FT2_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FT2_FONT_MAP, PangoFT2FontMap))
-#define PANGO_FT2_IS_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FT2_FONT_MAP))
-#endif
-
-typedef struct _PangoFT2FontMap PangoFT2FontMap;
-
-/**
- * PangoFT2SubstituteFunc:
- * @pattern: the FcPattern to tweak.
- * @data: user data.
- *
- * Function type for doing final config tweaking on prepared FcPatterns.
- */
-typedef void (*PangoFT2SubstituteFunc) (FcPattern *pattern,
- gpointer data);
-
-/* Calls for applications */
-
-PANGO_AVAILABLE_IN_ALL
-void pango_ft2_render (FT_Bitmap *bitmap,
- PangoFont *font,
- PangoGlyphString *glyphs,
- gint x,
- gint y);
-PANGO_AVAILABLE_IN_1_6
-void pango_ft2_render_transformed (FT_Bitmap *bitmap,
- const PangoMatrix *matrix,
- PangoFont *font,
- PangoGlyphString *glyphs,
- int x,
- int y);
-
-PANGO_AVAILABLE_IN_ALL
-void pango_ft2_render_layout_line (FT_Bitmap *bitmap,
- PangoLayoutLine *line,
- int x,
- int y);
-PANGO_AVAILABLE_IN_1_6
-void pango_ft2_render_layout_line_subpixel (FT_Bitmap *bitmap,
- PangoLayoutLine *line,
- int x,
- int y);
-PANGO_AVAILABLE_IN_ALL
-void pango_ft2_render_layout (FT_Bitmap *bitmap,
- PangoLayout *layout,
- int x,
- int y);
-PANGO_AVAILABLE_IN_1_6
-void pango_ft2_render_layout_subpixel (FT_Bitmap *bitmap,
- PangoLayout *layout,
- int x,
- int y);
-
-PANGO_AVAILABLE_IN_ALL
-GType pango_ft2_font_map_get_type (void) G_GNUC_CONST;
-
-PANGO_AVAILABLE_IN_1_2
-PangoFontMap *pango_ft2_font_map_new (void);
-PANGO_AVAILABLE_IN_1_2
-void pango_ft2_font_map_set_resolution (PangoFT2FontMap *fontmap,
- double dpi_x,
- double dpi_y);
-
-G_END_DECLS
-
-#endif /* __PANGOFT2_H__ */
diff --git a/pango/pangoft2.rc.in b/pango/pangoft2.rc.in
deleted file mode 100644
index d9367aee..00000000
--- a/pango/pangoft2.rc.in
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <winver.h>
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION @PANGO_VERSION_MAJOR@,@PANGO_VERSION_MINOR@,@PANGO_VERSION_MICRO@,0
- PRODUCTVERSION @PANGO_VERSION_MAJOR@,@PANGO_VERSION_MINOR@,@PANGO_VERSION_MICRO@,0
- FILEFLAGSMASK 0
- FILEFLAGS 0
- FILEOS VOS__WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
- BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904B0"
- BEGIN
- VALUE "CompanyName", "Red Hat Software"
- VALUE "FileDescription", "PangoFT2"
- VALUE "FileVersion", "@PANGO_VERSION_MAJOR@.@PANGO_VERSION_MINOR@.@PANGO_VERSION_MICRO@.0"
- VALUE "InternalName", "pangoft2-@PANGO_API_VERSION@-@PANGO_CURRENT_MINUS_AGE@"
- VALUE "LegalCopyright", "Copyright 1999 Red Hat Software. Copyright 2000 Tor Lillqvist"
- VALUE "OriginalFilename", "pangoft2-@PANGO_API_VERSION@-@PANGO_CURRENT_MINUS_AGE@.dll"
- VALUE "ProductName", "PangoFT2"
- VALUE "ProductVersion", "@PANGO_VERSION_MAJOR@.@PANGO_VERSION_MINOR@.@PANGO_VERSION_MICRO@"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
- END
diff --git a/tests/cxx-test.cpp b/tests/cxx-test.cpp
index 3e4e476e..436d42cd 100644
--- a/tests/cxx-test.cpp
+++ b/tests/cxx-test.cpp
@@ -8,14 +8,6 @@
#include <pango/pangowin32.h>
#endif
-#ifdef HAVE_XFT
-#include <pango/pangoxft.h>
-#endif
-
-#ifdef HAVE_FREETYPE
-#include <pango/pangoft2.h>
-#endif
-
#ifdef HAVE_CAIRO
#include <pango/pangocairo.h>
#endif
diff --git a/tests/meson.build b/tests/meson.build
index 67d6e550..5cd3a0ab 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -48,8 +48,8 @@ if cairo_dep.found()
if build_pangoft2
tests += [
- [ 'testmisc', [ 'testmisc.c' ], [ libpangocairo_dep, libpangoft2_dep, glib_dep, harfbuzz_dep ] ],
- [ 'testserialize', [ 'testserialize.c' ], [ libpangocairo_dep, libpangoft2_dep ] ],
+ [ 'testmisc', [ 'testmisc.c' ], [ libpangocairo_dep, glib_dep, harfbuzz_dep ] ],
+ [ 'testserialize', [ 'testserialize.c' ], [ libpangocairo_dep, libpangoft2_dep ] ],
]
if host_system != 'darwin'
diff --git a/utils/meson.build b/utils/meson.build
index 4a16df24..03a4eaf8 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -9,21 +9,16 @@ pango_view_deps = [
libpango_dep,
]
-if build_pangoft2
- pango_view_sources += 'viewer-pangoft2.c'
- pango_view_deps += libpangoft2_dep
-endif
-
extra_cflags = [
'-DPACKAGE_NAME="@0@"'.format(meson.project_name()),
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version())
]
-if build_pangoft2 and x11_dep.found()
+if x11_dep.found()
pango_view_sources += [
'viewer-x.c',
]
- pango_view_deps += [ libpangoft2_dep, x11_dep ]
+ pango_view_deps += [ x11_dep ]
extra_cflags += [ '-DHAVE_X' ]
endif
diff --git a/utils/pango-view.c b/utils/pango-view.c
index dbfb31ca..457a7a9a 100644
--- a/utils/pango-view.c
+++ b/utils/pango-view.c
@@ -2,16 +2,12 @@
#include "viewer.h"
extern const PangoViewer pangocairo_viewer;
-extern const PangoViewer pangoft2_viewer;
extern const PangoViewer pangox_viewer;
const PangoViewer *viewers[] = {
#ifdef HAVE_CAIRO
&pangocairo_viewer,
#endif
-#ifdef HAVE_FREETYPE
- &pangoft2_viewer,
-#endif
#ifdef HAVE_X
&pangox_viewer,
#endif
diff --git a/utils/viewer-pangoft2.c b/utils/viewer-pangoft2.c
deleted file mode 100644
index de948307..00000000
--- a/utils/viewer-pangoft2.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* viewer-pangoft2.c: PangoFT2 viewer backend.
- *
- * Copyright (C) 1999,2004,2005 Red Hat, Inc.
- * Copyright (C) 2001 Sun Microsystems
- *
- * 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 "config.h"
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "viewer-render.h"
-#include "viewer.h"
-
-#include <pango/pangoft2.h>
-
-static void
-substitute_func (FcPattern *pattern,
- gpointer data G_GNUC_UNUSED)
-{
- if (opt_antialias != ANTIALIAS_DEFAULT)
- {
- FcPatternDel (pattern, FC_ANTIALIAS);
- FcPatternAddBool (pattern, FC_ANTIALIAS, opt_antialias != ANTIALIAS_NONE);
- }
- if (opt_hinting != HINT_DEFAULT)
- {
- FcPatternDel (pattern, FC_HINTING);
- FcPatternAddBool (pattern, FC_HINTING, opt_hinting != HINT_NONE);
-
- FcPatternDel (pattern, FC_AUTOHINT);
- FcPatternAddBool (pattern, FC_AUTOHINT, opt_hinting == HINT_AUTO);
- }
-}
-
-static gpointer
-pangoft2_view_create (const PangoViewer *klass G_GNUC_UNUSED)
-{
- PangoFontMap *fontmap;
- fontmap = pango_ft2_font_map_new ();
-
- pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), opt_dpi, opt_dpi);
- pango_fc_font_map_set_default_substitute (PANGO_FC_FONT_MAP (fontmap), substitute_func, NULL, NULL);
-
- return fontmap;
-}
-
-static void
-pangoft2_view_destroy (gpointer instance)
-{
- g_object_unref (instance);
-}
-
-static PangoContext *
-pangoft2_view_get_context (gpointer instance)
-{
- return pango_font_map_create_context (PANGO_FONT_MAP (instance));
-}
-
-static gpointer
-pangoft2_view_create_surface (gpointer instance G_GNUC_UNUSED,
- int width,
- int height)
-{
- FT_Bitmap *bitmap;
-
- bitmap = g_slice_new (FT_Bitmap);
- bitmap->width = width;
- bitmap->pitch = (bitmap->width + 3) & ~3;
- bitmap->rows = height;
- bitmap->buffer = g_malloc (bitmap->pitch * bitmap->rows);
- bitmap->num_grays = 256;
- bitmap->pixel_mode = ft_pixel_mode_grays;
- memset (bitmap->buffer, 0x00, bitmap->pitch * bitmap->rows);
-
- return bitmap;
-}
-
-static void
-pangoft2_view_destroy_surface (gpointer instance G_GNUC_UNUSED,
- gpointer surface)
-{
- FT_Bitmap *bitmap = (FT_Bitmap *) surface;
-
- g_free (bitmap->buffer);
- g_slice_free (FT_Bitmap, bitmap);
-}
-
-static void
-render_callback (PangoLayout *layout,
- int x,
- int y,
- gpointer context,
- gpointer state G_GNUC_UNUSED)
-{
- pango_ft2_render_layout ((FT_Bitmap *)context,
- layout,
- x, y);
-}
-
-static void
-pangoft2_view_render (gpointer instance G_GNUC_UNUSED,
- gpointer surface,
- PangoContext *context,
- int *width,
- int *height,
- gpointer state)
-{
- int pix_idx;
- FT_Bitmap *bitmap = (FT_Bitmap *) surface;
-
- do_output (context, render_callback, NULL, surface, state, width, height);
-
- for (pix_idx=0; pix_idx<bitmap->pitch * bitmap->rows; pix_idx++)
- bitmap->buffer[pix_idx] = 255 - bitmap->buffer[pix_idx];
-}
-
-static void
-pangoft2_view_write (gpointer instance G_GNUC_UNUSED,
- gpointer surface,
- FILE *stream,
- int width,
- int height)
-{
- int row;
- FT_Bitmap *bitmap = (FT_Bitmap *) surface;
-
- /* Write it as pgm to output */
- fprintf(stream,
- "P5\n"
- "%d %d\n"
- "255\n", width, height);
- for (row = 0; row < height; row++)
- fwrite (bitmap->buffer + row * bitmap->pitch, 1, width, stream);
-}
-
-const PangoViewer pangoft2_viewer = {
- "PangoFT2",
- "ft2",
- ".pgm",
- pangoft2_view_create,
- pangoft2_view_destroy,
- pangoft2_view_get_context,
- pangoft2_view_create_surface,
- pangoft2_view_destroy_surface,
- pangoft2_view_render,
- pangoft2_view_write,
- NULL,
- NULL,
- NULL
-};