2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
2004-11-03 05:29:01 +03:00
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2004-02-14 02:07:42 +03:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2003-06-30 16:44:03 +04:00
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2004-07-06 00:19:52 +04:00
|
|
|
* Copyright 2004 John Tytgat <John.Tytgat@aaug.net>
|
2004-09-29 07:33:24 +04:00
|
|
|
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
2002-07-28 01:10:45 +04:00
|
|
|
*/
|
|
|
|
|
2004-01-22 02:57:19 +03:00
|
|
|
/** \file
|
|
|
|
* Font handling (RISC OS implementation).
|
|
|
|
*
|
|
|
|
* The Font Manager is used to handle and render fonts.
|
|
|
|
*/
|
|
|
|
|
2002-09-27 01:38:33 +04:00
|
|
|
#include <assert.h>
|
2002-07-28 01:10:45 +04:00
|
|
|
#include <stdio.h>
|
2003-07-18 03:01:02 +04:00
|
|
|
#include "oslib/font.h"
|
2004-07-21 00:02:59 +04:00
|
|
|
#include "oslib/os.h"
|
2003-04-04 19:19:32 +04:00
|
|
|
#include "netsurf/css/css.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
#include "netsurf/desktop/gui.h"
|
2003-07-18 03:01:02 +04:00
|
|
|
#include "netsurf/render/font.h"
|
2003-12-27 03:11:57 +03:00
|
|
|
#include "netsurf/riscos/gui.h"
|
2004-07-06 00:19:52 +04:00
|
|
|
#include "netsurf/riscos/options.h"
|
|
|
|
#include "netsurf/riscos/ufont.h"
|
2002-10-05 21:50:21 +04:00
|
|
|
#include "netsurf/utils/log.h"
|
2003-07-18 03:01:02 +04:00
|
|
|
#include "netsurf/utils/utils.h"
|
|
|
|
|
2004-09-14 03:56:18 +04:00
|
|
|
#define FONT_MAX_NAME 128 /* max length of a font name */
|
|
|
|
|
|
|
|
#define FONT_FAMILIES 6 /* Number of families */
|
2004-11-03 05:29:01 +03:00
|
|
|
#define FONT_FACES 4 /* Number of faces per family */
|
2004-01-31 01:28:32 +03:00
|
|
|
|
|
|
|
/* Font Variants */
|
|
|
|
#define FONT_SMALLCAPS 4
|
2004-01-29 00:48:10 +03:00
|
|
|
|
|
|
|
/* Font Styles */
|
2003-07-18 03:01:02 +04:00
|
|
|
#define FONT_BOLD 2
|
|
|
|
#define FONT_SLANTED 1
|
|
|
|
|
2004-01-29 00:48:10 +03:00
|
|
|
/* Font families */
|
2004-11-03 05:29:01 +03:00
|
|
|
#define FONT_DEFAULT (0 * FONT_FACES)
|
2004-09-14 03:56:18 +04:00
|
|
|
#define FONT_SANS_SERIF (1 * FONT_FACES)
|
2004-11-03 05:29:01 +03:00
|
|
|
#define FONT_SERIF (2 * FONT_FACES)
|
2004-09-14 03:56:18 +04:00
|
|
|
#define FONT_MONOSPACE (3 * FONT_FACES)
|
2004-11-03 05:29:01 +03:00
|
|
|
#define FONT_CURSIVE (4 * FONT_FACES)
|
|
|
|
#define FONT_FANTASY (5 * FONT_FACES)
|
2004-01-29 00:48:10 +03:00
|
|
|
|
2003-07-18 03:01:02 +04:00
|
|
|
/* a font_set is just a linked list of font_data for each face for now */
|
|
|
|
struct font_set {
|
2004-01-31 01:28:32 +03:00
|
|
|
struct font_data *font[FONT_FAMILIES * FONT_FACES];
|
2003-07-18 03:01:02 +04:00
|
|
|
};
|
2002-07-28 01:10:45 +04:00
|
|
|
|
2004-09-29 07:33:24 +04:00
|
|
|
static os_error *nsfont_open_ufont(const char *fontNameP, const char *fbFontNameP, int size, int *handleP, bool *using_fb, bool log_errors);
|
|
|
|
static os_error *nsfont_open_standard(const char *fontNameP, const char *fbFontNameP, int size, int *handleP, bool *using_fb, bool log_errors);
|
|
|
|
static char *nsfont_create_font_name(char *base, int id);
|
2004-07-06 00:19:52 +04:00
|
|
|
|
2004-09-29 07:33:24 +04:00
|
|
|
/** Table of font names.
|
2004-01-22 02:57:19 +03:00
|
|
|
*
|
2004-09-29 07:33:24 +04:00
|
|
|
* font id = font family * 4 + bold * 2 + slanted
|
2004-01-29 00:48:10 +03:00
|
|
|
*
|
2004-09-14 03:56:18 +04:00
|
|
|
* font family: 1 = sans-serif, 2 = serif, 3 = monospace, 4 = cursive,
|
|
|
|
* 5 = fantasy.
|
2004-07-06 00:19:52 +04:00
|
|
|
* Font family 0 must be available as it is the replacement font when
|
|
|
|
* the other font families can not be found.
|
2002-09-27 01:38:33 +04:00
|
|
|
*/
|
2004-09-29 07:33:24 +04:00
|
|
|
static char font_table[FONT_FAMILIES * FONT_FACES][FONT_MAX_NAME] = {
|
|
|
|
/* default */ /* ---bs */
|
|
|
|
/*0*/ "Homerton.Medium", /* 00000 */
|
|
|
|
/*1*/ "Homerton.Medium.Oblique", /* 00001 */
|
|
|
|
/*2*/ "Homerton.Bold", /* 00010 */
|
|
|
|
/*3*/ "Homerton.Bold.Oblique", /* 00011 */
|
2004-09-14 03:56:18 +04:00
|
|
|
/* sans-serif */
|
2004-09-29 07:33:24 +04:00
|
|
|
/*4*/ "Homerton.Medium", /* 00100 */
|
|
|
|
/*5*/ "Homerton.Medium.Oblique", /* 00101 */
|
|
|
|
/*6*/ "Homerton.Bold", /* 00110 */
|
|
|
|
/*7*/ "Homerton.Bold.Oblique", /* 00111 */
|
2004-07-06 00:19:52 +04:00
|
|
|
/* serif */
|
2004-09-29 07:33:24 +04:00
|
|
|
/*8*/ "Trinity.Medium", /* 01000 */
|
|
|
|
/*9*/ "Trinity.Medium.Italic", /* 01001 */
|
|
|
|
/*10*/ "Trinity.Bold", /* 01010 */
|
|
|
|
/*11*/ "Trinity.Bold.Italic", /* 01011 */
|
2004-07-06 00:19:52 +04:00
|
|
|
/* monospace */
|
2004-09-29 07:33:24 +04:00
|
|
|
/*12*/ "Corpus.Medium", /* 01100 */
|
|
|
|
/*13*/ "Corpus.Medium.Oblique", /* 01101 */
|
|
|
|
/*14*/ "Corpus.Bold", /* 01110 */
|
|
|
|
/*15*/ "Corpus.Bold.Oblique", /* 01111 */
|
2004-07-06 00:19:52 +04:00
|
|
|
/* cursive */
|
2004-09-29 07:33:24 +04:00
|
|
|
/*16*/ "Churchill.Medium", /* 10000 */
|
|
|
|
/*17*/ "Churchill.Medium.Italic", /* 10001 */
|
|
|
|
/*18*/ "Churchill.Bold", /* 10010 */
|
|
|
|
/*19*/ "Churchill.Bold.Italic", /* 10011 */
|
2004-07-06 00:19:52 +04:00
|
|
|
/* fantasy */
|
2004-09-29 07:33:24 +04:00
|
|
|
/*20*/ "Sassoon.Primary", /* 10100 */
|
|
|
|
/*21*/ "Sassoon.Primary.Oblique", /* 10101 */
|
|
|
|
/*22*/ "Sassoon.Primary.Bold", /* 10110 */
|
|
|
|
/*23*/ "Sassoon.Primary.Bold.Oblique", /* 10111 */
|
2004-07-06 00:19:52 +04:00
|
|
|
};
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2002-09-27 01:38:33 +04:00
|
|
|
/**
|
2004-01-22 02:57:19 +03:00
|
|
|
* Create an empty font_set.
|
|
|
|
*
|
|
|
|
* \return an opaque struct font_set.
|
2002-09-27 01:38:33 +04:00
|
|
|
*/
|
2004-07-06 00:19:52 +04:00
|
|
|
struct font_set *nsfont_new_set(void)
|
2002-09-27 01:38:33 +04:00
|
|
|
{
|
2004-07-06 00:19:52 +04:00
|
|
|
struct font_set *set;
|
2002-09-27 01:38:33 +04:00
|
|
|
unsigned int i;
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
LOG(("nsfont_new_set()\n"));
|
2002-09-27 01:38:33 +04:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
if ((set = malloc(sizeof(*set))) == NULL)
|
|
|
|
return NULL;
|
2004-02-16 01:19:43 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
for (i = 0; i < FONT_FAMILIES * FONT_FACES; i++)
|
|
|
|
set->font[i] = NULL;
|
2004-02-16 01:19:43 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
return set;
|
2004-02-16 01:19:43 +03:00
|
|
|
}
|
2002-09-27 01:38:33 +04:00
|
|
|
|
2004-01-22 02:57:19 +03:00
|
|
|
/**
|
|
|
|
* Open a font for use based on a css_style.
|
|
|
|
*
|
2004-07-06 00:19:52 +04:00
|
|
|
* \param set a font_set, as returned by nsfont_new_set()
|
2004-01-22 02:57:19 +03:00
|
|
|
* \param style a css_style which describes the font
|
2004-07-06 00:19:52 +04:00
|
|
|
* \return a struct font_data, with an opaque font handle in handle
|
2004-01-22 02:57:19 +03:00
|
|
|
*
|
|
|
|
* The set is updated to include the font, if it was not present.
|
|
|
|
*/
|
2004-07-06 00:19:52 +04:00
|
|
|
struct font_data *nsfont_open(struct font_set *set, struct css_style *style)
|
2002-09-27 01:38:33 +04:00
|
|
|
{
|
|
|
|
struct font_data *data;
|
2004-02-14 02:07:42 +03:00
|
|
|
unsigned int size = option_font_size * 1.6;
|
2002-09-27 01:38:33 +04:00
|
|
|
unsigned int f = 0;
|
2004-07-06 00:19:52 +04:00
|
|
|
int fhandle;
|
2004-01-22 02:57:19 +03:00
|
|
|
os_error *error;
|
2004-07-06 00:19:52 +04:00
|
|
|
bool using_fb;
|
2002-09-27 01:38:33 +04:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
assert(set != NULL);
|
|
|
|
assert(style != NULL);
|
2002-09-27 01:38:33 +04:00
|
|
|
|
|
|
|
if (style->font_size.size == CSS_FONT_SIZE_LENGTH)
|
2004-08-14 19:07:21 +04:00
|
|
|
size = (int)(css_len2px(&style->font_size.value.length,
|
|
|
|
style) * 72.0 / 90.0 * 16.);
|
2004-02-14 02:07:42 +03:00
|
|
|
if (size < option_font_min_size * 1.6)
|
|
|
|
size = option_font_min_size * 1.6;
|
|
|
|
if (1600 < size)
|
|
|
|
size = 1600;
|
2002-09-27 01:38:33 +04:00
|
|
|
|
2004-01-29 00:48:10 +03:00
|
|
|
switch (style->font_family) {
|
2004-07-06 00:19:52 +04:00
|
|
|
case CSS_FONT_FAMILY_SANS_SERIF:
|
|
|
|
f += FONT_SANS_SERIF;
|
|
|
|
break;
|
|
|
|
case CSS_FONT_FAMILY_SERIF:
|
|
|
|
f += FONT_SERIF;
|
|
|
|
break;
|
|
|
|
case CSS_FONT_FAMILY_MONOSPACE:
|
|
|
|
f += FONT_MONOSPACE;
|
|
|
|
break;
|
|
|
|
case CSS_FONT_FAMILY_CURSIVE:
|
|
|
|
f += FONT_CURSIVE;
|
|
|
|
break;
|
|
|
|
case CSS_FONT_FAMILY_FANTASY:
|
|
|
|
f += FONT_FANTASY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-01-29 00:48:10 +03:00
|
|
|
}
|
2004-09-29 07:33:24 +04:00
|
|
|
/** \todo (re)implement smallcaps */
|
|
|
|
/* switch (style->font_variant) {
|
2004-07-06 00:19:52 +04:00
|
|
|
case CSS_FONT_VARIANT_SMALL_CAPS:
|
|
|
|
f += FONT_SMALLCAPS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-01-31 01:28:32 +03:00
|
|
|
}
|
2004-09-29 07:33:24 +04:00
|
|
|
*/
|
2004-01-31 01:28:32 +03:00
|
|
|
|
2002-09-27 01:38:33 +04:00
|
|
|
switch (style->font_weight) {
|
|
|
|
case CSS_FONT_WEIGHT_BOLD:
|
|
|
|
case CSS_FONT_WEIGHT_600:
|
|
|
|
case CSS_FONT_WEIGHT_700:
|
|
|
|
case CSS_FONT_WEIGHT_800:
|
|
|
|
case CSS_FONT_WEIGHT_900:
|
|
|
|
f += FONT_BOLD;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (style->font_style) {
|
|
|
|
case CSS_FONT_STYLE_ITALIC:
|
|
|
|
case CSS_FONT_STYLE_OBLIQUE:
|
|
|
|
f += FONT_SLANTED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
for (data = set->font[f]; data != NULL; data = data->next)
|
2002-09-27 01:38:33 +04:00
|
|
|
if (data->size == size)
|
2004-07-06 00:19:52 +04:00
|
|
|
return data;
|
|
|
|
|
|
|
|
if ((data = malloc(sizeof(*data))) == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Strategy : first try the UFont font code with given font name
|
|
|
|
* or the default font name if the former fails.
|
|
|
|
* If this still fails, try the use the default RISC OS font open
|
|
|
|
* in UTF-8 encoding (again first with given font name, then with
|
|
|
|
* the default font name).
|
|
|
|
* If this still fails, we repeat the previous step but now using
|
|
|
|
* the Latin 1 encoding.
|
|
|
|
*/
|
2004-09-29 07:33:24 +04:00
|
|
|
if (!option_font_ufont || (error = nsfont_open_ufont(font_table[f], font_table[f % 4], (int)size, &fhandle, &using_fb, true)) != NULL) {
|
2004-09-14 03:56:18 +04:00
|
|
|
char fontName1[FONT_MAX_NAME+10];
|
|
|
|
char fontName2[FONT_MAX_NAME+10];
|
2004-07-06 00:19:52 +04:00
|
|
|
/* Go for the UTF-8 encoding with standard FontManager */
|
2004-09-29 07:33:24 +04:00
|
|
|
strcpy(fontName1, font_table[f]);
|
2004-07-06 00:19:52 +04:00
|
|
|
strcat(fontName1, "\\EUTF8");
|
2004-09-29 07:33:24 +04:00
|
|
|
strcpy(fontName2, font_table[f % 4]);
|
2004-07-06 00:19:52 +04:00
|
|
|
strcat(fontName2, "\\EUTF8");
|
2004-09-29 07:33:24 +04:00
|
|
|
|
|
|
|
if ((error = nsfont_open_standard(fontName1, fontName2, (int)size, &fhandle, &using_fb, true)) != NULL) {
|
2004-07-06 00:19:52 +04:00
|
|
|
/* All UTF-8 font methods failed, only support Latin 1 */
|
2004-09-29 07:33:24 +04:00
|
|
|
strcpy(fontName1, font_table[f]);
|
2004-09-14 03:56:18 +04:00
|
|
|
strcat(fontName1, "\\ELatin1");
|
2004-09-29 07:33:24 +04:00
|
|
|
strcpy(fontName2, font_table[f % 4]);
|
2004-09-14 03:56:18 +04:00
|
|
|
strcat(fontName2, "\\ELatin1");
|
2004-09-29 07:33:24 +04:00
|
|
|
|
|
|
|
if ((error = nsfont_open_standard(fontName1, fontName2, (int)size, &fhandle, &using_fb, true)) != NULL) {
|
2004-07-06 00:19:52 +04:00
|
|
|
LOG(("(u)font_find_font failed : %s\n", error->errmess));
|
|
|
|
die("(u)font_find_font failed");
|
|
|
|
}
|
|
|
|
data->ftype = FONTTYPE_STANDARD_LATIN1;
|
|
|
|
} else
|
|
|
|
data->ftype = FONTTYPE_STANDARD_UTF8ENC;
|
|
|
|
} else
|
|
|
|
data->ftype = FONTTYPE_UFONT;
|
|
|
|
|
|
|
|
data->id = (using_fb) ? f % 4 : f;
|
|
|
|
data->handle = fhandle;
|
2002-09-27 01:38:33 +04:00
|
|
|
data->size = size;
|
2004-07-06 00:19:52 +04:00
|
|
|
data->space_width = nsfont_width(data, " ", sizeof(" ")-1);
|
2002-09-27 01:38:33 +04:00
|
|
|
|
|
|
|
data->next = set->font[f];
|
|
|
|
set->font[f] = data;
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-22 02:57:19 +03:00
|
|
|
/**
|
2004-07-06 00:19:52 +04:00
|
|
|
* Open font via UFont code.
|
2004-01-22 02:57:19 +03:00
|
|
|
*
|
2004-07-06 00:19:52 +04:00
|
|
|
* \param fontNameP UFont font name
|
|
|
|
* \param fbFontNameP fallback UFont font name
|
|
|
|
* \param size font size
|
|
|
|
* \param handle returning UFont handle in case there isn't an error.
|
|
|
|
* \param using_fb returning whether the fallback font was used or not.
|
|
|
|
* \return error in case there was one.
|
2004-01-22 02:57:19 +03:00
|
|
|
*/
|
2004-09-29 07:33:24 +04:00
|
|
|
static os_error *nsfont_open_ufont(const char *fontNameP, const char *fbFontNameP, int size, int *handleP, bool *using_fb, bool log_errors)
|
2004-07-06 00:19:52 +04:00
|
|
|
{
|
|
|
|
os_error *errorP;
|
|
|
|
*handleP = 0; *using_fb = false;
|
|
|
|
if ((errorP = xufont_find_font(fontNameP, size, size, 0, 0, (ufont_f *)handleP, NULL, NULL)) == NULL)
|
|
|
|
return NULL;
|
2004-09-29 07:33:24 +04:00
|
|
|
if (log_errors)
|
|
|
|
LOG(("ufont_find_font(<%s>) failed <%s> (case 1)", fontNameP, errorP->errmess));
|
2004-07-06 00:19:52 +04:00
|
|
|
/* If the fallback font is the same as the first font name, return */
|
|
|
|
if (strcmp(fontNameP, fbFontNameP) == 0)
|
|
|
|
return errorP;
|
|
|
|
*using_fb = true;
|
|
|
|
if ((errorP = xufont_find_font(fbFontNameP, size, size, 0, 0, (ufont_f *)handleP, NULL, NULL)) == NULL)
|
|
|
|
return NULL;
|
2004-09-29 07:33:24 +04:00
|
|
|
if (log_errors)
|
|
|
|
LOG(("ufont_find_font(<%s>) failed <%s> (case 2)", fbFontNameP, errorP->errmess));
|
2004-07-06 00:19:52 +04:00
|
|
|
return errorP;
|
|
|
|
}
|
|
|
|
|
2004-01-22 02:57:19 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
/**
|
|
|
|
* Open font via standard FontManager.
|
|
|
|
*
|
|
|
|
* \param fontNameP RISC OS font name
|
|
|
|
* \param fbFontNameP fallback RISC OS font name
|
|
|
|
* \param size font size
|
|
|
|
* \param handle RISC OS handle in case there isn't an error.
|
|
|
|
* \param using_fb returning whether the fallback font was used or not.
|
|
|
|
* \return error in case there was one.
|
|
|
|
*/
|
2004-09-29 07:33:24 +04:00
|
|
|
static os_error *nsfont_open_standard(const char *fontNameP, const char *fbFontNameP, int size, int *handleP, bool *using_fb, bool log_errors)
|
2004-07-06 00:19:52 +04:00
|
|
|
{
|
|
|
|
os_error *errorP;
|
|
|
|
*handleP = 0; *using_fb = false;
|
|
|
|
if ((errorP = xfont_find_font(fontNameP, size, size, 0, 0, (font_f *)handleP, NULL, NULL)) == NULL)
|
|
|
|
return NULL;
|
2004-09-29 07:33:24 +04:00
|
|
|
if (log_errors)
|
|
|
|
LOG(("font_find_font(<%s>) failed <%s> (case 1)", fontNameP, errorP->errmess));
|
2004-07-06 00:19:52 +04:00
|
|
|
/* If the fallback font is the same as the first font name, return */
|
|
|
|
if (strcmp(fontNameP, fbFontNameP) == 0)
|
|
|
|
return errorP;
|
|
|
|
*using_fb = true;
|
|
|
|
if ((errorP = xfont_find_font(fbFontNameP, size, size, 0, 0, (font_f *)handleP, NULL, NULL)) == NULL)
|
|
|
|
return NULL;
|
2004-09-29 07:33:24 +04:00
|
|
|
if (log_errors)
|
|
|
|
LOG(("font_find_font(<%s>) failed <%s> (case 2)", fbFontNameP, errorP->errmess));
|
2004-07-06 00:19:52 +04:00
|
|
|
return errorP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Frees all the fonts in a font_set.
|
|
|
|
*
|
|
|
|
* \param set a font_set as returned by nsfont_new_set()
|
|
|
|
*/
|
|
|
|
void nsfont_free_set(struct font_set *set)
|
2002-09-27 01:38:33 +04:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
LOG(("nsfont_free_set()\n"));
|
|
|
|
assert(set != NULL);
|
2002-09-27 01:38:33 +04:00
|
|
|
|
2004-01-31 01:28:32 +03:00
|
|
|
for (i = 0; i < FONT_FAMILIES * FONT_FACES; i++) {
|
2004-07-06 00:19:52 +04:00
|
|
|
struct font_data *data, *next;
|
|
|
|
for (data = set->font[i]; data != NULL; data = next) {
|
|
|
|
os_error *error;
|
2002-09-27 01:38:33 +04:00
|
|
|
next = data->next;
|
2004-07-06 00:19:52 +04:00
|
|
|
switch (data->ftype) {
|
|
|
|
case FONTTYPE_UFONT:
|
|
|
|
error = xufont_lose_font((ufont_f)data->handle);
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_UTF8ENC:
|
|
|
|
case FONTTYPE_STANDARD_LATIN1:
|
|
|
|
error = xfont_lose_font((font_f)data->handle);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (error != NULL)
|
|
|
|
LOG(("(u)font_lose_font() failed : 0x%x <%s>\n", error->errnum, error->errmess));
|
2004-01-22 02:57:19 +03:00
|
|
|
free(data);
|
2002-09-27 01:38:33 +04:00
|
|
|
}
|
2004-07-06 00:19:52 +04:00
|
|
|
}
|
2002-09-27 01:38:33 +04:00
|
|
|
|
|
|
|
free(set);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-22 02:57:19 +03:00
|
|
|
/**
|
|
|
|
* Find the width of some text in a font.
|
|
|
|
*
|
2004-07-06 00:19:52 +04:00
|
|
|
* \param font a font_data, as returned by nsfont_open()
|
2004-01-22 02:57:19 +03:00
|
|
|
* \param text string to measure
|
|
|
|
* \param length length of text
|
|
|
|
* \return width of text in pixels
|
|
|
|
*/
|
2004-07-06 00:19:52 +04:00
|
|
|
unsigned long nsfont_width(struct font_data *font, const char *text,
|
2004-08-14 16:57:02 +04:00
|
|
|
size_t length)
|
2004-01-22 02:57:19 +03:00
|
|
|
{
|
|
|
|
int width;
|
2004-07-06 00:19:52 +04:00
|
|
|
os_error *error;
|
2004-01-22 02:57:19 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
assert(font != NULL && text != NULL);
|
2004-01-22 02:57:19 +03:00
|
|
|
|
|
|
|
if (length == 0)
|
|
|
|
return 0;
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
switch (font->ftype) {
|
|
|
|
case FONTTYPE_UFONT:
|
|
|
|
error = xufont_scan_string((ufont_f)font->handle,
|
|
|
|
text,
|
|
|
|
font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_GIVEN_LENGTH,
|
|
|
|
0x7fffffff, 0x7fffffff,
|
|
|
|
NULL,
|
|
|
|
NULL, (int)length,
|
|
|
|
NULL, &width, NULL, NULL);
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_UTF8ENC:
|
|
|
|
error = xfont_scan_string((font_f)font->handle,
|
|
|
|
text,
|
|
|
|
font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_GIVEN_LENGTH,
|
|
|
|
0x7fffffff, 0x7fffffff,
|
|
|
|
NULL,
|
|
|
|
NULL, (int)length,
|
|
|
|
NULL, &width, NULL, NULL);
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_LATIN1: {
|
|
|
|
const char *loc_text = cnv_strn_local_enc(text, length, NULL);
|
|
|
|
error = xfont_scan_string((font_f)font->handle,
|
|
|
|
loc_text,
|
|
|
|
font_GIVEN_FONT
|
|
|
|
| font_KERN,
|
|
|
|
0x7fffffff, 0x7fffffff,
|
|
|
|
NULL,
|
|
|
|
NULL, 0,
|
|
|
|
NULL, &width, NULL, NULL);
|
2004-07-09 00:14:54 +04:00
|
|
|
free((void *)loc_text);
|
2004-07-06 00:19:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (error != NULL) {
|
2004-09-14 03:56:18 +04:00
|
|
|
LOG(("(u)font_scan_string failed : %s", error->errmess));
|
2004-07-06 00:19:52 +04:00
|
|
|
die("nsfont_width: (u)font_scan_string failed");
|
2004-01-22 02:57:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return width / 800;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find where in a string a x coordinate falls.
|
|
|
|
*
|
2004-01-29 00:48:10 +03:00
|
|
|
* For example, used to find where to position the caret in response to mouse
|
2004-01-22 02:57:19 +03:00
|
|
|
* click.
|
|
|
|
*
|
2004-07-06 00:19:52 +04:00
|
|
|
* \param font a font_data, as returned by nsfont_open()
|
2004-01-22 02:57:19 +03:00
|
|
|
* \param text a string
|
|
|
|
* \param length length of text
|
|
|
|
* \param x horizontal position in pixels
|
|
|
|
* \param char_offset updated to give the offset in the string
|
|
|
|
* \param pixel_offset updated to give the coordinate of the character in pixels
|
|
|
|
*/
|
2004-07-06 00:19:52 +04:00
|
|
|
void nsfont_position_in_string(struct font_data *font, const char *text,
|
2004-08-14 16:57:02 +04:00
|
|
|
size_t length, unsigned long x,
|
2004-01-22 02:57:19 +03:00
|
|
|
int *char_offset, int *pixel_offset)
|
2002-09-27 01:38:33 +04:00
|
|
|
{
|
2004-01-22 02:57:19 +03:00
|
|
|
os_error *error;
|
2004-07-06 00:19:52 +04:00
|
|
|
font_scan_block block;
|
2004-07-09 00:14:54 +04:00
|
|
|
const char *split;
|
2004-07-06 00:19:52 +04:00
|
|
|
int x_out;
|
2004-01-22 02:57:19 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
assert(font != NULL && text != NULL);
|
2002-09-27 01:38:33 +04:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
block.space.x = block.space.y = block.letter.x = block.letter.y = 0;
|
2004-01-22 02:57:19 +03:00
|
|
|
block.split_char = -1;
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
switch (font->ftype) {
|
|
|
|
case FONTTYPE_UFONT:
|
|
|
|
error = xufont_scan_string((ufont_f)font->handle,
|
|
|
|
text,
|
|
|
|
font_GIVEN_BLOCK
|
|
|
|
| font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_RETURN_CARET_POS
|
|
|
|
| font_GIVEN_LENGTH,
|
|
|
|
x * 2 * 400, 0x7fffffff,
|
|
|
|
&block, NULL, (int)length,
|
2004-09-29 07:33:24 +04:00
|
|
|
(unsigned const char **)&split,
|
|
|
|
&x_out, NULL, NULL);
|
2004-07-06 00:19:52 +04:00
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_UTF8ENC:
|
|
|
|
error = xfont_scan_string((font_f)font->handle,
|
|
|
|
text,
|
|
|
|
font_GIVEN_BLOCK
|
|
|
|
| font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_RETURN_CARET_POS
|
|
|
|
| font_GIVEN_LENGTH,
|
|
|
|
x * 2 * 400, 0x7fffffff,
|
|
|
|
&block, NULL, (int)length,
|
2004-09-29 07:33:24 +04:00
|
|
|
(char **)&split,
|
|
|
|
&x_out, NULL, NULL);
|
2004-07-06 00:19:52 +04:00
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_LATIN1: {
|
|
|
|
const ptrdiff_t *back_mapP;
|
|
|
|
const char *loc_text = cnv_strn_local_enc(text, length, &back_mapP);
|
|
|
|
error = xfont_scan_string((font_f)font->handle,
|
|
|
|
loc_text,
|
|
|
|
font_GIVEN_BLOCK
|
|
|
|
| font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_RETURN_CARET_POS,
|
|
|
|
x * 2 * 400, 0x7fffffff,
|
|
|
|
&block, NULL, 0,
|
2004-09-29 07:33:24 +04:00
|
|
|
(char **)&split,
|
|
|
|
&x_out, NULL, NULL);
|
2004-07-06 00:19:52 +04:00
|
|
|
split = &text[back_mapP[split - loc_text]];
|
2004-07-09 00:14:54 +04:00
|
|
|
free((void *)loc_text); free((void *)back_mapP);
|
2004-07-06 00:19:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (error != NULL) {
|
|
|
|
LOG(("(u)font_scan_string failed : %s\n", error->errmess));
|
|
|
|
die("nsfont_position_in_string: (u)font_scan_string failed");
|
2004-01-22 02:57:19 +03:00
|
|
|
}
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
*char_offset = (int)(split - text);
|
|
|
|
*pixel_offset = x_out / 800;
|
2002-09-27 01:38:33 +04:00
|
|
|
}
|
|
|
|
|
2002-10-12 17:05:16 +04:00
|
|
|
|
2004-01-22 02:57:19 +03:00
|
|
|
/**
|
|
|
|
* Find where to split a string to fit in a width.
|
|
|
|
*
|
|
|
|
* For example, used when wrapping paragraphs.
|
|
|
|
*
|
2004-07-06 00:19:52 +04:00
|
|
|
* \param font a font_data, as returned by nsfont_open()
|
2004-01-22 02:57:19 +03:00
|
|
|
* \param text string to split
|
|
|
|
* \param length length of text
|
|
|
|
* \param width available width
|
|
|
|
* \param used_width updated to actual width used
|
|
|
|
* \return pointer to character which does not fit
|
|
|
|
*/
|
2004-07-06 00:19:52 +04:00
|
|
|
char *nsfont_split(struct font_data *font, const char *text,
|
2004-08-14 16:57:02 +04:00
|
|
|
size_t length, unsigned int width, unsigned int *used_width)
|
2002-10-12 17:05:16 +04:00
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
font_scan_block block;
|
2004-07-09 00:14:54 +04:00
|
|
|
const char *split;
|
2002-10-12 17:05:16 +04:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
assert(font != NULL && text != NULL);
|
|
|
|
|
2002-10-12 17:05:16 +04:00
|
|
|
block.space.x = block.space.y = block.letter.x = block.letter.y = 0;
|
|
|
|
block.split_char = ' ';
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
switch (font->ftype) {
|
|
|
|
case FONTTYPE_UFONT:
|
|
|
|
error = xufont_scan_string((ufont_f)font->handle,
|
|
|
|
text,
|
|
|
|
font_GIVEN_BLOCK
|
|
|
|
| font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_GIVEN_LENGTH,
|
|
|
|
width * 2 * 400, 0x7fffffff,
|
|
|
|
&block,
|
|
|
|
NULL,
|
|
|
|
(int)length,
|
2004-09-29 07:33:24 +04:00
|
|
|
(unsigned const char **)&split,
|
2004-07-06 00:19:52 +04:00
|
|
|
used_width, NULL, NULL);
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_UTF8ENC:
|
|
|
|
error = xfont_scan_string((font_f)font->handle,
|
|
|
|
text,
|
|
|
|
font_GIVEN_BLOCK
|
|
|
|
| font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_GIVEN_LENGTH,
|
|
|
|
width * 2 * 400, 0x7fffffff,
|
|
|
|
&block,
|
|
|
|
NULL,
|
|
|
|
(int)length,
|
2004-09-29 07:33:24 +04:00
|
|
|
(char **)&split,
|
2004-07-06 00:19:52 +04:00
|
|
|
used_width, NULL, NULL);
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_LATIN1: {
|
|
|
|
const ptrdiff_t *back_mapP;
|
|
|
|
const char *loc_text = cnv_strn_local_enc(text, length, &back_mapP);
|
|
|
|
error = xfont_scan_string((font_f)font->handle,
|
|
|
|
loc_text,
|
|
|
|
font_GIVEN_BLOCK
|
|
|
|
| font_GIVEN_FONT
|
|
|
|
| font_KERN,
|
|
|
|
width * 2 * 400, 0x7fffffff,
|
|
|
|
&block,
|
|
|
|
NULL,
|
|
|
|
0,
|
2004-09-29 07:33:24 +04:00
|
|
|
(char **)&split,
|
2004-07-06 00:19:52 +04:00
|
|
|
used_width, NULL, NULL);
|
|
|
|
split = &text[back_mapP[split - loc_text]];
|
2004-07-09 00:14:54 +04:00
|
|
|
free((void *)loc_text); free((void *)back_mapP);
|
2004-07-06 00:19:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
2002-10-12 17:05:16 +04:00
|
|
|
}
|
2004-07-06 00:19:52 +04:00
|
|
|
if (error != NULL) {
|
|
|
|
LOG(("(u)font_scan_string failed : %s\n", error->errmess));
|
|
|
|
die("nsfont_split: (u)font_scan_string failed");
|
|
|
|
}
|
|
|
|
|
2004-09-14 03:56:18 +04:00
|
|
|
assert(split == &text[length] || *split == ' ' || *split == '\t');
|
2002-12-27 20:28:19 +03:00
|
|
|
|
2004-01-22 02:57:19 +03:00
|
|
|
*used_width = *used_width / 2 / 400;
|
2002-12-27 20:28:19 +03:00
|
|
|
|
2004-09-29 07:33:24 +04:00
|
|
|
return (char*)split;
|
2002-10-12 17:05:16 +04:00
|
|
|
}
|
|
|
|
|
2004-01-22 02:57:19 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
void nsfont_paint(struct font_data *data, const char *text,
|
2004-08-14 16:57:02 +04:00
|
|
|
size_t length, int xpos, int ypos, void *trfm)
|
2004-01-22 02:57:19 +03:00
|
|
|
{
|
2004-07-06 00:19:52 +04:00
|
|
|
os_error *error;
|
|
|
|
unsigned int flags;
|
2004-07-21 00:02:59 +04:00
|
|
|
const int var_input[3] = {136, 137, -1}; /* XOrig, YOrig, Terminator */
|
|
|
|
int var_output[3];
|
|
|
|
bool background_blending = option_background_blending;
|
2004-07-06 00:19:52 +04:00
|
|
|
|
|
|
|
flags = font_OS_UNITS | font_GIVEN_FONT | font_KERN;
|
|
|
|
if (trfm != NULL)
|
|
|
|
flags |= font_GIVEN_TRFM;
|
|
|
|
|
|
|
|
/* font background blending (RO3.7+) */
|
2004-07-21 00:02:59 +04:00
|
|
|
if (ro_gui_current_redraw_gui)
|
|
|
|
background_blending = ro_gui_current_redraw_gui->option.background_blending;
|
|
|
|
if (background_blending) {
|
2004-07-06 00:19:52 +04:00
|
|
|
int version;
|
|
|
|
|
|
|
|
/* Font manager versions below 3.35 complain
|
|
|
|
* about this flag being set.
|
|
|
|
*/
|
|
|
|
error = xfont_cache_addr(&version, 0, 0);
|
|
|
|
/**\todo should we do anything else on error? */
|
|
|
|
if (!error && version >= 335)
|
|
|
|
flags |= font_BLEND_FONT;
|
|
|
|
}
|
2004-01-22 02:57:19 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
assert(data != NULL);
|
|
|
|
assert(text != NULL);
|
2004-01-22 02:57:19 +03:00
|
|
|
|
2004-08-19 02:07:20 +04:00
|
|
|
/* adjust by the origin
|
|
|
|
* (not if printing as the result is undefined)
|
|
|
|
*/
|
|
|
|
if (!print_active) {
|
|
|
|
xos_read_vdu_variables((const os_vdu_var_list *)&var_input,
|
|
|
|
(int *)&var_output);
|
|
|
|
xpos += var_output[0];
|
|
|
|
ypos += var_output[1];
|
|
|
|
}
|
2004-08-14 16:57:02 +04:00
|
|
|
|
2004-07-21 00:02:59 +04:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
switch (data->ftype) {
|
|
|
|
case FONTTYPE_UFONT:
|
|
|
|
flags |= font_GIVEN_LENGTH;
|
|
|
|
error = xufont_paint((ufont_f)data->handle, text,
|
|
|
|
flags, xpos, ypos, NULL,
|
|
|
|
trfm, length);
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_UTF8ENC:
|
|
|
|
flags |= font_GIVEN_LENGTH;
|
|
|
|
error = xfont_paint((font_f)data->handle, text,
|
|
|
|
flags, xpos, ypos, NULL,
|
|
|
|
trfm, length);
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_LATIN1: {
|
|
|
|
const char *loc_text = cnv_strn_local_enc(text, length, NULL);
|
|
|
|
error = xfont_paint((font_f)data->handle, loc_text,
|
|
|
|
flags, xpos, ypos, NULL,
|
|
|
|
trfm, 0);
|
2004-07-09 00:14:54 +04:00
|
|
|
free((void *)loc_text);
|
2004-07-06 00:19:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
2004-01-22 02:57:19 +03:00
|
|
|
}
|
2004-07-06 00:19:52 +04:00
|
|
|
if (error != NULL) {
|
|
|
|
LOG(("(u)font_paint failed : %s\n", error->errmess));
|
|
|
|
die("nsfont_paint: (u)font_paint failed");
|
|
|
|
}
|
|
|
|
}
|
2004-01-22 02:57:19 +03:00
|
|
|
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
/**
|
|
|
|
* Given a text line, return the number of bytes which can be set using
|
|
|
|
* one RISC OS font and the bounding box fitting that part of the text
|
|
|
|
* only.
|
|
|
|
*
|
|
|
|
* \param font a font_data, as returned by nsfont_open()
|
|
|
|
* \param text string text. Does not have to be NUL terminated.
|
|
|
|
* \param length length in bytes of the text to consider.
|
|
|
|
* \param width returned width of the text which can be set with one RISC OS font. If 0, then error happened or initial text length was 0.
|
|
|
|
* \param rofontname returned name of the RISC OS font which can be used to set the text. If NULL, then error happened or initial text length was 0.
|
|
|
|
* \param rotext returned string containing the characters in returned RISC OS font. Not necessary NUL terminated. free() after use. If NULL, then error happened or initial text length was 0.
|
|
|
|
* \param rolength length of return rotext string. If 0, then error happened or initial text length was 0.
|
|
|
|
* \param consumed number of bytes of the given text which can be set with one RISC OS font. If 0, then error happened or initial text length was 0.
|
|
|
|
*/
|
|
|
|
void nsfont_txtenum(struct font_data *font, const char *text,
|
2004-08-14 16:57:02 +04:00
|
|
|
size_t length,
|
2004-07-06 00:19:52 +04:00
|
|
|
unsigned int *width,
|
|
|
|
const char **rofontname,
|
|
|
|
const char **rotext,
|
2004-08-14 16:57:02 +04:00
|
|
|
size_t *rolength,
|
|
|
|
size_t *consumed)
|
2004-07-06 00:19:52 +04:00
|
|
|
{
|
2004-09-29 07:33:24 +04:00
|
|
|
static char *fontname[FONT_MAX_NAME]; /** \todo: not nice */
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
assert(font != NULL && text != NULL && rofontname != NULL && rotext != NULL && rolength != NULL && consumed != NULL);
|
2004-01-22 02:57:19 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
*rotext = *rofontname = NULL;
|
|
|
|
*consumed = *rolength = *width = 0;
|
2004-01-22 02:57:19 +03:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
if (length == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (font->ftype) {
|
|
|
|
case FONTTYPE_UFONT:
|
|
|
|
(void)xufont_txtenum((ufont_f)font->handle,
|
|
|
|
text,
|
|
|
|
font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_GIVEN_LENGTH,
|
|
|
|
length,
|
|
|
|
(int *)width,
|
2004-09-29 07:33:24 +04:00
|
|
|
(unsigned const char **)rofontname,
|
|
|
|
(unsigned const char **)rotext,
|
2004-07-06 00:19:52 +04:00
|
|
|
rolength,
|
|
|
|
consumed);
|
|
|
|
*width /= 800;
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_UTF8ENC: {
|
|
|
|
int rowidth;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xfont_scan_string((font_f)font->handle,
|
|
|
|
text,
|
|
|
|
font_GIVEN_FONT
|
|
|
|
| font_KERN
|
|
|
|
| font_GIVEN_LENGTH,
|
|
|
|
0x7fffffff, 0x7fffffff,
|
|
|
|
NULL,
|
|
|
|
NULL, (int)length,
|
|
|
|
NULL, &rowidth, NULL, NULL);
|
|
|
|
if (error != NULL)
|
|
|
|
return;
|
|
|
|
|
2004-09-29 07:33:24 +04:00
|
|
|
strcpy(fontname, font_table[font->id]);
|
2004-07-06 00:19:52 +04:00
|
|
|
strcat(fontname, "\\EUTF8");
|
|
|
|
if ((*rotext = strndup(text, length)) == NULL)
|
|
|
|
return;
|
|
|
|
*rolength = length;
|
|
|
|
*rofontname = fontname;
|
|
|
|
*consumed = length;
|
2004-07-09 00:14:54 +04:00
|
|
|
*width = (unsigned int)rowidth / 800;
|
2004-07-06 00:19:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FONTTYPE_STANDARD_LATIN1: {
|
|
|
|
int rowidth;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
if ((*rotext = cnv_strn_local_enc(text, length, NULL)) == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
error = xfont_scan_string((font_f)font->handle,
|
|
|
|
*rotext,
|
|
|
|
font_GIVEN_FONT
|
|
|
|
| font_KERN,
|
|
|
|
0x7fffffff, 0x7fffffff,
|
|
|
|
NULL,
|
|
|
|
NULL, 0,
|
2004-07-09 00:14:54 +04:00
|
|
|
NULL, &rowidth, NULL, NULL);
|
2004-07-06 00:19:52 +04:00
|
|
|
if (error != NULL) {
|
2004-07-09 00:14:54 +04:00
|
|
|
free((void *)*rotext); *rotext = NULL;
|
2004-07-06 00:19:52 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
*rolength = strlen(*rotext);
|
2004-09-29 07:33:24 +04:00
|
|
|
strcpy(fontname, font_table[font->id]);
|
2004-09-14 03:56:18 +04:00
|
|
|
strcat(fontname, "\\ELatin1");
|
|
|
|
*rofontname = fontname;
|
2004-07-06 00:19:52 +04:00
|
|
|
*consumed = length;
|
2004-07-09 00:14:54 +04:00
|
|
|
*width = (unsigned int)rowidth / 800;
|
2004-07-06 00:19:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-09-14 03:56:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in the font_table, based on the user's options
|
2004-09-30 00:13:42 +04:00
|
|
|
*
|
|
|
|
* \param force_rescan Indicate whether to rescan font names
|
|
|
|
* and update options
|
2004-09-14 03:56:18 +04:00
|
|
|
*/
|
2004-09-30 00:13:42 +04:00
|
|
|
void nsfont_fill_nametable(bool force_rescan)
|
2004-09-14 03:56:18 +04:00
|
|
|
{
|
2004-09-29 07:33:24 +04:00
|
|
|
int i;
|
|
|
|
char *name = NULL, *created = NULL;
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-09-29 07:33:24 +04:00
|
|
|
for (i = 0; i != FONT_FAMILIES * FONT_FACES; i++) {
|
|
|
|
/* read the relevant option string */
|
2004-09-14 03:56:18 +04:00
|
|
|
switch (i) {
|
2004-09-29 07:33:24 +04:00
|
|
|
/* default */
|
|
|
|
case FONT_DEFAULT:
|
2004-09-14 03:56:18 +04:00
|
|
|
name = option_font_default;
|
|
|
|
break;
|
2004-09-29 07:33:24 +04:00
|
|
|
case FONT_DEFAULT + FONT_SLANTED:
|
|
|
|
name = option_font_default_italic;
|
|
|
|
break;
|
|
|
|
case FONT_DEFAULT + FONT_BOLD:
|
|
|
|
name = option_font_default_bold;
|
|
|
|
break;
|
|
|
|
case FONT_DEFAULT + FONT_BOLD + FONT_SLANTED:
|
|
|
|
name = option_font_default_bold_italic;
|
|
|
|
break;
|
|
|
|
/* sans */
|
|
|
|
case FONT_SANS_SERIF:
|
2004-09-14 03:56:18 +04:00
|
|
|
name = option_font_sans;
|
|
|
|
break;
|
2004-09-29 07:33:24 +04:00
|
|
|
case FONT_SANS_SERIF + FONT_SLANTED:
|
|
|
|
name = option_font_sans_italic;
|
|
|
|
break;
|
|
|
|
case FONT_SANS_SERIF + FONT_BOLD:
|
|
|
|
name = option_font_sans_bold;
|
|
|
|
break;
|
|
|
|
case FONT_SANS_SERIF + FONT_BOLD + FONT_SLANTED:
|
|
|
|
name = option_font_sans_bold_italic;
|
|
|
|
break;
|
|
|
|
/* serif */
|
|
|
|
case FONT_SERIF:
|
2004-09-14 03:56:18 +04:00
|
|
|
name = option_font_serif;
|
|
|
|
break;
|
2004-09-29 07:33:24 +04:00
|
|
|
case FONT_SERIF + FONT_SLANTED:
|
|
|
|
name = option_font_serif_italic;
|
|
|
|
break;
|
|
|
|
case FONT_SERIF + FONT_BOLD:
|
|
|
|
name = option_font_serif_bold;
|
|
|
|
break;
|
|
|
|
case FONT_SERIF + FONT_BOLD + FONT_SLANTED:
|
|
|
|
name = option_font_serif_bold_italic;
|
|
|
|
break;
|
|
|
|
/* mono */
|
|
|
|
case FONT_MONOSPACE:
|
2004-09-14 03:56:18 +04:00
|
|
|
name = option_font_mono;
|
|
|
|
break;
|
2004-09-29 07:33:24 +04:00
|
|
|
case FONT_MONOSPACE + FONT_SLANTED:
|
|
|
|
name = option_font_mono_italic;
|
|
|
|
break;
|
|
|
|
case FONT_MONOSPACE + FONT_BOLD:
|
|
|
|
name = option_font_mono_bold;
|
|
|
|
break;
|
|
|
|
case FONT_MONOSPACE + FONT_BOLD + FONT_SLANTED:
|
|
|
|
name = option_font_mono_bold_italic;
|
|
|
|
break;
|
|
|
|
/* cursive */
|
|
|
|
case FONT_CURSIVE:
|
2004-09-14 03:56:18 +04:00
|
|
|
name = option_font_cursive;
|
|
|
|
break;
|
2004-09-29 07:33:24 +04:00
|
|
|
case FONT_CURSIVE + FONT_SLANTED:
|
|
|
|
name = option_font_cursive_italic;
|
|
|
|
break;
|
|
|
|
case FONT_CURSIVE + FONT_BOLD:
|
|
|
|
name = option_font_cursive_bold;
|
|
|
|
break;
|
|
|
|
case FONT_CURSIVE + FONT_BOLD + FONT_SLANTED:
|
|
|
|
name = option_font_cursive_bold_italic;
|
|
|
|
break;
|
|
|
|
/* fantasy */
|
|
|
|
case FONT_FANTASY:
|
2004-09-14 03:56:18 +04:00
|
|
|
name = option_font_fantasy;
|
|
|
|
break;
|
2004-09-29 07:33:24 +04:00
|
|
|
case FONT_FANTASY + FONT_SLANTED:
|
|
|
|
name = option_font_fantasy_italic;
|
|
|
|
break;
|
|
|
|
case FONT_FANTASY + FONT_BOLD:
|
|
|
|
name = option_font_fantasy_bold;
|
|
|
|
break;
|
|
|
|
case FONT_FANTASY + FONT_BOLD + FONT_SLANTED:
|
|
|
|
name = option_font_fantasy_bold_italic;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-09-30 00:13:42 +04:00
|
|
|
if ((!force_rescan || (force_rescan && i == ((i / FONT_FACES) * FONT_FACES))) && name && name[0] != '\0') {
|
2004-09-29 07:33:24 +04:00
|
|
|
/* got a configured font name => use it */
|
|
|
|
strncpy(font_table[i], name, FONT_MAX_NAME);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
char *dot, *next_segment;
|
|
|
|
|
|
|
|
/* no configured name => try to create one */
|
|
|
|
|
|
|
|
/* get the base font for the family */
|
|
|
|
name = strdup(font_table[(i/FONT_FACES)*FONT_FACES]);
|
|
|
|
next_segment = name;
|
|
|
|
|
|
|
|
do {
|
|
|
|
dot = strchr(next_segment, '.');
|
|
|
|
|
|
|
|
/* restore '.' */
|
|
|
|
if (next_segment != name)
|
|
|
|
*(next_segment-1) = '.';
|
|
|
|
|
|
|
|
if (dot) {
|
|
|
|
*dot = '\0';
|
|
|
|
next_segment = dot+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
created = nsfont_create_font_name(name, i);
|
|
|
|
|
|
|
|
} while(!created && dot);
|
|
|
|
|
|
|
|
/* now fill in the table entry */
|
|
|
|
if (created) {
|
|
|
|
strncpy(font_table[i], created,
|
|
|
|
FONT_MAX_NAME);
|
|
|
|
free(created);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(name);
|
2004-09-30 00:13:42 +04:00
|
|
|
|
|
|
|
/* don't modify options if not rescanning */
|
|
|
|
if (!force_rescan)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* write the relevant option string */
|
|
|
|
switch (i) {
|
|
|
|
/* default */
|
|
|
|
case FONT_DEFAULT:
|
|
|
|
if (option_font_default)
|
|
|
|
free(option_font_default);
|
|
|
|
option_font_default = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_DEFAULT + FONT_SLANTED:
|
|
|
|
if (option_font_default_italic)
|
|
|
|
free(option_font_default_italic);
|
|
|
|
option_font_default_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_DEFAULT + FONT_BOLD:
|
|
|
|
if (option_font_default_bold)
|
|
|
|
free(option_font_default_bold);
|
|
|
|
option_font_default_bold = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_DEFAULT + FONT_BOLD + FONT_SLANTED:
|
|
|
|
if (option_font_default_bold_italic)
|
|
|
|
free(option_font_default_bold_italic);
|
|
|
|
option_font_default_bold_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
/* sans */
|
|
|
|
case FONT_SANS_SERIF:
|
|
|
|
if (option_font_sans)
|
|
|
|
free(option_font_sans);
|
|
|
|
option_font_sans = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_SANS_SERIF + FONT_SLANTED:
|
|
|
|
if (option_font_sans_italic)
|
|
|
|
free(option_font_sans_italic);
|
|
|
|
option_font_sans_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_SANS_SERIF + FONT_BOLD:
|
|
|
|
if (option_font_sans_bold)
|
|
|
|
free(option_font_sans_bold);
|
|
|
|
option_font_sans_bold = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_SANS_SERIF + FONT_BOLD + FONT_SLANTED:
|
|
|
|
if (option_font_sans_bold_italic)
|
|
|
|
free(option_font_sans_bold_italic);
|
|
|
|
option_font_sans_bold_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
/* serif */
|
|
|
|
case FONT_SERIF:
|
|
|
|
if (option_font_serif)
|
|
|
|
free(option_font_serif);
|
|
|
|
option_font_serif = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_SERIF + FONT_SLANTED:
|
|
|
|
if (option_font_serif_italic)
|
|
|
|
free(option_font_serif_italic);
|
|
|
|
option_font_serif_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_SERIF + FONT_BOLD:
|
|
|
|
if (option_font_serif_bold)
|
|
|
|
free(option_font_serif_bold);
|
|
|
|
option_font_serif_bold = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_SERIF + FONT_BOLD + FONT_SLANTED:
|
|
|
|
if (option_font_serif_bold_italic)
|
|
|
|
free(option_font_serif_bold_italic);
|
|
|
|
option_font_serif_bold_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
/* mono */
|
|
|
|
case FONT_MONOSPACE:
|
|
|
|
if (option_font_mono)
|
|
|
|
free(option_font_mono);
|
|
|
|
option_font_mono = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_MONOSPACE + FONT_SLANTED:
|
|
|
|
if (option_font_mono_italic)
|
|
|
|
free(option_font_mono_italic);
|
|
|
|
option_font_mono_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_MONOSPACE + FONT_BOLD:
|
|
|
|
if (option_font_mono_bold)
|
|
|
|
free(option_font_mono_bold);
|
|
|
|
option_font_mono_bold = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_MONOSPACE + FONT_BOLD + FONT_SLANTED:
|
|
|
|
if (option_font_mono_bold_italic)
|
|
|
|
free(option_font_mono_bold_italic);
|
|
|
|
option_font_mono_bold_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
/* cursive */
|
|
|
|
case FONT_CURSIVE:
|
|
|
|
if (option_font_cursive)
|
|
|
|
free(option_font_cursive);
|
|
|
|
option_font_cursive = strdup(font_table[i]);;
|
|
|
|
break;
|
|
|
|
case FONT_CURSIVE + FONT_SLANTED:
|
|
|
|
if (option_font_cursive_italic)
|
|
|
|
free(option_font_cursive_italic);
|
|
|
|
option_font_cursive_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_CURSIVE + FONT_BOLD:
|
|
|
|
if (option_font_cursive_bold)
|
|
|
|
free(option_font_cursive_bold);
|
|
|
|
option_font_cursive_bold = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_CURSIVE + FONT_BOLD + FONT_SLANTED:
|
|
|
|
if (option_font_cursive_bold_italic)
|
|
|
|
free(option_font_cursive_bold_italic);
|
|
|
|
option_font_cursive_bold_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
/* fantasy */
|
|
|
|
case FONT_FANTASY:
|
|
|
|
if (option_font_fantasy)
|
|
|
|
free(option_font_fantasy);
|
|
|
|
option_font_fantasy = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_FANTASY + FONT_SLANTED:
|
|
|
|
if (option_font_fantasy_italic)
|
|
|
|
free(option_font_fantasy_italic);
|
|
|
|
option_font_fantasy_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_FANTASY + FONT_BOLD:
|
|
|
|
if (option_font_fantasy_bold)
|
|
|
|
free(option_font_fantasy_bold);
|
|
|
|
option_font_fantasy_bold = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
case FONT_FANTASY + FONT_BOLD + FONT_SLANTED:
|
|
|
|
if (option_font_fantasy_bold_italic)
|
|
|
|
free(option_font_fantasy_bold_italic);
|
|
|
|
option_font_fantasy_bold_italic = strdup(font_table[i]);
|
|
|
|
break;
|
|
|
|
}
|
2004-09-29 07:33:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lookup table used by nsfont_create_font_name.
|
|
|
|
* Italic entries *must* precede bold entries
|
|
|
|
*/
|
|
|
|
static const char *style_lookup[] = {
|
|
|
|
#define ITALIC_COUNT 3
|
|
|
|
"Italic", "Oblique", "Slant",
|
|
|
|
#define BOLD_COUNT 5
|
|
|
|
"Bold", "Demi", "ExtraBold", "Ultra", "Heavy"
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a valid font name, testing for presence on the system
|
|
|
|
*
|
|
|
|
* \param base The base name
|
|
|
|
* \param id The id of the font (entry into font_table)
|
|
|
|
* \return The font name, or NULL on failure
|
|
|
|
*/
|
|
|
|
char *nsfont_create_font_name(char *base, int id)
|
|
|
|
{
|
|
|
|
char *created, tempname[FONT_MAX_NAME+10];
|
|
|
|
int bold, italic;
|
|
|
|
os_error *error;
|
|
|
|
int fhandle;
|
|
|
|
bool using_fb, found = false;
|
|
|
|
|
|
|
|
created = malloc(FONT_MAX_NAME);
|
|
|
|
if (!created)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Font presence testing strategy is as-per nsfont_open */
|
|
|
|
|
|
|
|
/* try bold-italic first */
|
|
|
|
if ((id & FONT_BOLD) && (id & FONT_SLANTED)) {
|
|
|
|
for (bold = 0; bold != BOLD_COUNT; bold++) {
|
|
|
|
for (italic = 0; italic != ITALIC_COUNT; italic++) {
|
|
|
|
snprintf(created, FONT_MAX_NAME,
|
|
|
|
"%s.%s.%s", base,
|
|
|
|
style_lookup[bold+ITALIC_COUNT],
|
|
|
|
style_lookup[italic]);
|
|
|
|
|
|
|
|
/* try ufont first */
|
|
|
|
if (option_font_ufont && (error = nsfont_open_ufont(created, created, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xufont_lose_font((ufont_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then UTF8 encoding */
|
|
|
|
strcpy(tempname, created);
|
|
|
|
strcat(tempname, "\\EUTF8");
|
|
|
|
if ((error = nsfont_open_standard(tempname, tempname, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xfont_lose_font((font_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then Latin1 */
|
|
|
|
strcpy(tempname, created);
|
|
|
|
strcat(tempname, "\\ELatin1");
|
|
|
|
if ((error = nsfont_open_standard(tempname, tempname, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xfont_lose_font((font_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* bold */
|
|
|
|
else if (id & FONT_BOLD) {
|
|
|
|
for (bold = 0; bold != BOLD_COUNT; bold++) {
|
|
|
|
snprintf(created, FONT_MAX_NAME, "%s.%s", base,
|
|
|
|
style_lookup[bold+ITALIC_COUNT]);
|
|
|
|
|
|
|
|
/* try ufont first */
|
|
|
|
if (option_font_ufont && (error = nsfont_open_ufont(created, created, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xufont_lose_font((ufont_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then UTF8 encoding */
|
|
|
|
strcpy(tempname, created);
|
|
|
|
strcat(tempname, "\\EUTF8");
|
|
|
|
if ((error = nsfont_open_standard(tempname, tempname, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xfont_lose_font((font_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then Latin1 */
|
|
|
|
strcpy(tempname, created);
|
|
|
|
strcat(tempname, "\\ELatin1");
|
|
|
|
if ((error = nsfont_open_standard(tempname, tempname, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xfont_lose_font((font_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
2004-09-14 03:56:18 +04:00
|
|
|
}
|
2004-09-29 07:33:24 +04:00
|
|
|
}
|
|
|
|
/* italic */
|
|
|
|
else if (id & FONT_SLANTED) {
|
|
|
|
for (italic = 0; italic != ITALIC_COUNT; italic++) {
|
|
|
|
snprintf(created, FONT_MAX_NAME, "%s.%s", base,
|
|
|
|
style_lookup[italic]);
|
|
|
|
|
|
|
|
/* try ufont first */
|
|
|
|
if (option_font_ufont && (error = nsfont_open_ufont(created, created, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xufont_lose_font((ufont_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then UTF8 encoding */
|
|
|
|
strcpy(tempname, created);
|
|
|
|
strcat(tempname, "\\EUTF8");
|
|
|
|
if ((error = nsfont_open_standard(tempname, tempname, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xfont_lose_font((font_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then Latin1 */
|
|
|
|
strcpy(tempname, created);
|
|
|
|
strcat(tempname, "\\ELatin1");
|
|
|
|
if ((error = nsfont_open_standard(tempname, tempname, 160, &fhandle, &using_fb, false)) == NULL) {
|
|
|
|
xfont_lose_font((font_f)fhandle);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
2004-09-14 03:56:18 +04:00
|
|
|
}
|
|
|
|
}
|
2004-09-29 07:33:24 +04:00
|
|
|
|
|
|
|
if (found)
|
|
|
|
return created;
|
|
|
|
|
|
|
|
free(created);
|
|
|
|
return NULL;
|
2004-09-14 03:56:18 +04:00
|
|
|
}
|
2004-11-03 05:29:01 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reopens all font handles to the current screen resolution
|
|
|
|
*/
|
|
|
|
void nsfont_reopen_set(struct font_set *fonts) {
|
|
|
|
os_error *error;
|
|
|
|
char fontName1[FONT_MAX_NAME+10];
|
|
|
|
char fontName2[FONT_MAX_NAME+10];
|
|
|
|
struct font_data *f;
|
|
|
|
bool using_fb;
|
|
|
|
|
|
|
|
for (int i = 0; i < (FONT_FAMILIES * FONT_FACES); i++) {
|
|
|
|
for (f = fonts->font[i]; f; f = f->next) {
|
|
|
|
switch (f->ftype) {
|
|
|
|
case FONTTYPE_UFONT:
|
|
|
|
error = xufont_lose_font((ufont_f)f->handle);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xufont_lose_font: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
}
|
|
|
|
error = nsfont_open_ufont(fontName1, fontName2, (int)f->size,
|
|
|
|
&f->handle, &using_fb, true);
|
|
|
|
if (error) {
|
|
|
|
LOG(("nsfont_open_standard: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_LATIN1:
|
|
|
|
error = xfont_lose_font((font_f)f->handle);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xfont_lose_font: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
}
|
|
|
|
strcpy(fontName1, font_table[f->id]);
|
|
|
|
strcat(fontName1, "\\ELatin1");
|
|
|
|
strcpy(fontName2, font_table[f->id % 4]);
|
|
|
|
strcat(fontName2, "\\ELatin1");
|
|
|
|
error = nsfont_open_standard(fontName1, fontName2, (int)f->size,
|
|
|
|
&f->handle, &using_fb, true);
|
|
|
|
if (error) {
|
|
|
|
LOG(("nsfont_open_standard: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FONTTYPE_STANDARD_UTF8ENC:
|
|
|
|
error = xfont_lose_font((font_f)f->handle);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xfont_lose_font: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
}
|
|
|
|
strcpy(fontName1, font_table[f->id]);
|
|
|
|
strcat(fontName1, "\\EUTF8");
|
|
|
|
strcpy(fontName2, font_table[f->id % 4]);
|
|
|
|
strcat(fontName2, "\\EUTF8");
|
|
|
|
error = nsfont_open_standard(fontName1, fontName2, (int)f->size,
|
|
|
|
&f->handle, &using_fb, true);
|
|
|
|
if (error) {
|
|
|
|
LOG(("nsfont_open_standard: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
f->space_width = nsfont_width(f, " ", sizeof(" ")-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|