[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Pango change, first^Wsecond baby step !



Le Fri, Jun 21, 2002, à 07:22:04PM +0200, Hans Breuer a écrit:

> Yepp. Result attached.

Wonderful ! 
It looks like something is lying to pango-win32 the same way it does to
pango-xft. I highly suspect the Courier(New) font to overstate its coverage
map...

Here's the result of a discussion with Lars on #dia on irc.debian.org, on
how to rebuild dia's font API around Pango. I'll start implementing this in
a couple hours (expect tomorrow's snapshot to break), then we'll fix the
objects to comply with this new API (Lars had a very valid point about not
trusting the PFD's size field, and carrying our own height attribute. We'll
resolve inefficiencies through caching, when the need arises. It will.)

Major thing is, we get rid of the hardcoded big ugly list of fonts (though
objects may hardcode a family name -- Pango will always find sensible
defaults, at least for Roman script).

(behind the scenes, most diafont_* functions will actually build layouts.
There should be a one or two-slot cache to avoid rebuilding the same layout
several times in a row)

	-- Cyrille  

-- 
Grumpf.

/* Dia -- an diagram creation/manipulation program
 * Copyright (C) 1998 Alexander Larsson
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
#ifndef FONT_H
#define FONT_H

#include <pango/pango.h>
#include "geometry.h"
#include "diavar.h"

typedef enum {
  ALIGN_LEFT,
  ALIGN_CENTER,
  ALIGN_RIGHT
} Alignment;

typedef enum {
  STYLE_NORMAL,
  STYLE_ITALIC,
  STYLE_BOLD,
  STYLE_BOLD_ITALIC
} Style;

typedef struct {
    PangoFontDescription* pfd;
} DiaFont;

void diafont_init(PangoContext* pcontext);


    /* Get a font matching family,style,height. MUST be freed with
       diafont_free(). */
DiaFont *diafont_get_font(const char *family, Style style,
                          real height);
    /* Get a font matching family,style,height. MUST be freed with
       diafont_free(). "family" is guaranteed to be a static string. */
DiaFont *diafont_get_font_static(const char *family, Style style,
                                 real height);

    /* Same attributes, except height */
DiaFont *diafont_get_similar_font(DiaFont* font, real height);

    /* Destroys previous font */
DiaFont *diafont_change_height(DiaFont* font, real height);

    /* Frees a font obtained by diafont_get_font */
void diafont_free(DiaFont *font); 

    /* Retrieves the style of the font */
Style diafont_get_style(DiaFont* font);

    /* Retrieves the family of the font */
G_CONST_RETURN char* diafont_get_style(DiaFont* font);

    /* Retrieves the height of the font */
real diafont_get_height(DiaFont* font);

    /* FIXME: what do we do with this, actually ? */
char *diafont_get_psfontname(DiaFont *font);


/* -------- Font and string functions - unscaled versions.
   Use these version in Objects, primarily. */

    /* Get the width of the string with the given font in cm */
real diafont_string_width(const char *string, DiaFont *font,
                       real height);
    /* Get the max ascent of the font in cm (a positive number).

    FIXME: may turn out that we need to pass a string here as well. */
real diafont_ascent(DiaFont *font, real height);
    /* Get the max descent of the font in cm (a positive number) 
       FIXME: may turn out that we need to pass a string here as well. */
real diafont_descent(DiaFont *font, real height);
    /* Get the base line of the font, for a given string. 
       FIXME: may turn out that we need to pass a string here as well. */
real diafont_get_baseline(char *text, DiaFont* font, real height);

    /* prepares a layout of the text, in font 'font'.
     */
PangoLayout* diafont_build_layout(char *string, DiaFont* font,
                                  real height);

/* -------- Font and string functions - scaled versions.
   Use these version in Renderers, exclusively. */

    /* Get the width of the string with the given font in cm */
real diafont_string_scaled_width(const char *string, DiaFont *font,
                                 real height, real zoom_factor);
    /* Get the max ascent of the font in cm (a positive number).

    FIXME: may turn out that we need to pass a string here as well. */
real diafont_scaled_ascent(DiaFont *font, real height, real zoom_factor);
    /* Get the max descent of the font in cm (a positive number) 
       FIXME: may turn out that we need to pass a string here as well. */
real diafont_scaled_descent(DiaFont *font, real height, real zoom_factor);
    /* Get the base line of the font, for a given string. 
       FIXME: may turn out that we need to pass a string here as well. */
real diafont_get_scaled_baseline(char *text, DiaFont* font,
                                 real height, real zoom_factor);

    /* prepares a layout of the text, in font 'font'.

    When zoom_factor != 1.0, may tweak the font's size or stretch so that its
    bounding box is actually linear with respect to the zoom factor (kerning,
    ligaturing and other wild beasts usually get in the way of linear
    scaling). */
PangoLayout* diafont_build_scaled_layout(char *string, DiaFont* font,
                                         real height, real zoom_factor);


#endif /* FONT_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK