mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 20:46:50 +03:00
[project @ 2004-01-30 22:28:32 by jmb]
Add font-variant support. Update TODO-CSS appropriately svn path=/import/netsurf/; revision=518
This commit is contained in:
parent
db56133900
commit
bf3e41a93d
@ -1,4 +1,4 @@
|
||||
$Id: TODO-CSS,v 1.5 2004/01/28 21:48:10 jmb Exp $
|
||||
$Id: TODO-CSS,v 1.6 2004/01/30 22:28:32 jmb Exp $
|
||||
|
||||
TODO-CSS file for NetSurf.
|
||||
|
||||
@ -37,13 +37,13 @@ See TODO-HTML for HTML related TODOs.
|
||||
+ display
|
||||
- empty-cells
|
||||
+ float
|
||||
= font (style, weight, size, line-spacing)
|
||||
= font-family
|
||||
= font (style, weight, size, line-spacing, family, variant)
|
||||
+ font-family
|
||||
+ font-size
|
||||
- font-size-adjust
|
||||
- font-stretch
|
||||
+ font-style
|
||||
- font-variant
|
||||
+ font-variant
|
||||
+ font-weight
|
||||
+ height
|
||||
- left
|
||||
|
@ -46,6 +46,7 @@ const struct css_style css_base_style = {
|
||||
CSS_FONT_FAMILY_SANS_SERIF,
|
||||
CSS_FONT_WEIGHT_NORMAL,
|
||||
CSS_FONT_STYLE_NORMAL,
|
||||
CSS_FONT_VARIANT_NORMAL,
|
||||
{ CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } },
|
||||
{ CSS_LINE_HEIGHT_ABSOLUTE, { 1.3 } },
|
||||
CSS_TEXT_ALIGN_LEFT,
|
||||
@ -65,6 +66,7 @@ const struct css_style css_empty_style = {
|
||||
CSS_FONT_FAMILY_INHERIT,
|
||||
CSS_FONT_WEIGHT_INHERIT,
|
||||
CSS_FONT_STYLE_INHERIT,
|
||||
CSS_FONT_VARIANT_INHERIT,
|
||||
{ CSS_HEIGHT_INHERIT, { 1, CSS_UNIT_EM } },
|
||||
{ CSS_LINE_HEIGHT_INHERIT, { 1.3 } },
|
||||
CSS_TEXT_ALIGN_INHERIT,
|
||||
@ -84,6 +86,7 @@ const struct css_style css_blank_style = {
|
||||
CSS_FONT_FAMILY_INHERIT,
|
||||
CSS_FONT_WEIGHT_INHERIT,
|
||||
CSS_FONT_STYLE_INHERIT,
|
||||
CSS_FONT_VARIANT_INHERIT,
|
||||
{ CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } },
|
||||
{ CSS_LINE_HEIGHT_INHERIT, { 1.3 } },
|
||||
CSS_TEXT_ALIGN_INHERIT,
|
||||
@ -658,6 +661,7 @@ void css_dump_style(const struct css_style * const style)
|
||||
default: fprintf(stderr, "UNKNOWN"); break;
|
||||
}
|
||||
fprintf(stderr, " %s", css_font_family_name[style->font_family]);
|
||||
fprintf(stderr, " %s", css_font_variant_name[style->font_variant]);
|
||||
fprintf(stderr, "; ");
|
||||
fprintf(stderr, "height: ");
|
||||
switch (style->height.height) {
|
||||
@ -758,6 +762,8 @@ void css_cascade(struct css_style * const style, const struct css_style * const
|
||||
style->font_style = apply->font_style;
|
||||
if (apply->font_weight != CSS_FONT_WEIGHT_INHERIT)
|
||||
style->font_weight = apply->font_weight;
|
||||
if (apply->font_variant != CSS_FONT_VARIANT_INHERIT)
|
||||
style->font_variant = apply->font_variant;
|
||||
if (apply->height.height != CSS_HEIGHT_INHERIT)
|
||||
style->height = apply->height;
|
||||
if (apply->line_height.size != CSS_LINE_HEIGHT_INHERIT)
|
||||
@ -831,6 +837,8 @@ void css_merge(struct css_style * const style, const struct css_style * const ap
|
||||
style->font_style = apply->font_style;
|
||||
if (apply->font_weight != CSS_FONT_WEIGHT_INHERIT)
|
||||
style->font_weight = apply->font_weight;
|
||||
if (apply->font_variant != CSS_FONT_VARIANT_INHERIT)
|
||||
style->font_variant = apply->font_variant;
|
||||
if (apply->height.height != CSS_HEIGHT_INHERIT)
|
||||
style->height = apply->height;
|
||||
if (apply->line_height.size != CSS_LINE_HEIGHT_INHERIT)
|
||||
|
@ -75,6 +75,7 @@ struct css_style {
|
||||
css_font_family font_family;
|
||||
css_font_weight font_weight;
|
||||
css_font_style font_style;
|
||||
css_font_variant font_variant;
|
||||
|
||||
struct {
|
||||
enum { CSS_HEIGHT_INHERIT,
|
||||
|
@ -9,7 +9,7 @@ css_display inherit inline block list-item run-in inline-block table inline-tabl
|
||||
css_float inherit none left right
|
||||
css_font_family inherit sans-serif serif monospace cursive fantasy
|
||||
css_font_style inherit normal italic oblique
|
||||
css_font_variant normal smallcaps
|
||||
css_font_variant inherit normal small-caps
|
||||
css_font_weight inherit normal bold bolder lighter 100 200 300 400 500 600 700 800 900
|
||||
css_letter_spacing normal length
|
||||
css_list_style_position outside inside
|
||||
|
@ -47,6 +47,7 @@ static void parse_font(struct css_style * const s, const struct css_node * v);
|
||||
static void parse_font_family(struct css_style * const s, const struct css_node * v);
|
||||
static void parse_font_size(struct css_style * const s, const struct css_node * const v);
|
||||
static void parse_font_style(struct css_style * const s, const struct css_node * const v);
|
||||
static void parse_font_variant(struct css_style * const s, const struct css_node * const v);
|
||||
static void parse_font_weight(struct css_style * const s, const struct css_node * const v);
|
||||
static void parse_height(struct css_style * const s, const struct css_node * const v);
|
||||
static void parse_line_height(struct css_style * const s, const struct css_node * const v);
|
||||
@ -70,6 +71,7 @@ static const struct property_entry property_table[] = {
|
||||
{ "font-family", parse_font_family },
|
||||
{ "font-size", parse_font_size },
|
||||
{ "font-style", parse_font_style },
|
||||
{ "font-variant", parse_font_variant },
|
||||
{ "font-weight", parse_font_weight },
|
||||
{ "height", parse_height },
|
||||
{ "line-height", parse_line_height },
|
||||
@ -399,6 +401,7 @@ void parse_font(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
css_font_family ff;
|
||||
css_font_style fs;
|
||||
css_font_variant fv;
|
||||
css_font_weight fw;
|
||||
s->font_family = CSS_FONT_FAMILY_SANS_SERIF;
|
||||
s->font_style = CSS_FONT_STYLE_NORMAL;
|
||||
@ -414,13 +417,17 @@ void parse_font(struct css_style * const s, const struct css_node * v)
|
||||
s->font_family = ff;
|
||||
break;
|
||||
}
|
||||
|
||||
/* font-style, font-variant, or font-weight */
|
||||
fs = css_font_style_parse(v->data);
|
||||
if (fs != CSS_FONT_STYLE_UNKNOWN) {
|
||||
s->font_style = fs;
|
||||
break;
|
||||
}
|
||||
fv = css_font_variant_parse(v->data);
|
||||
if (fv != CSS_FONT_VARIANT_UNKNOWN) {
|
||||
s->font_variant = fv;
|
||||
break;
|
||||
}
|
||||
fw = css_font_weight_parse(v->data);
|
||||
if (fw != CSS_FONT_WEIGHT_UNKNOWN) {
|
||||
s->font_weight = fw;
|
||||
@ -507,6 +514,16 @@ void parse_font_style(struct css_style * const s, const struct css_node * const
|
||||
s->font_style = z;
|
||||
}
|
||||
|
||||
void parse_font_variant(struct css_style * const s, const struct css_node * const v)
|
||||
{
|
||||
css_font_variant z;
|
||||
if (v->type != CSS_NODE_IDENT || v->next != 0)
|
||||
return;
|
||||
z = css_font_variant_parse(v->data);
|
||||
if (z != CSS_FONT_VARIANT_UNKNOWN)
|
||||
s->font_variant = z;
|
||||
}
|
||||
|
||||
void parse_font_weight(struct css_style * const s, const struct css_node * const v)
|
||||
{
|
||||
css_font_weight z;
|
||||
@ -516,6 +533,7 @@ void parse_font_weight(struct css_style * const s, const struct css_node * const
|
||||
if (z != CSS_FONT_WEIGHT_UNKNOWN)
|
||||
s->font_weight = z;
|
||||
}
|
||||
|
||||
void parse_height(struct css_style * const s, const struct css_node * const v)
|
||||
{
|
||||
if (v->type == CSS_NODE_IDENT && strcasecmp(v->data, "auto") == 0)
|
||||
|
@ -23,57 +23,81 @@
|
||||
#include "netsurf/utils/utils.h"
|
||||
|
||||
#define FONT_FAMILIES 5 /* Number of families */
|
||||
#define FONT_FACES 8 /* Number of faces */
|
||||
|
||||
/* Font Variants */
|
||||
#define FONT_SMALLCAPS 4
|
||||
|
||||
/* Font Styles */
|
||||
#define FONT_BOLD 2
|
||||
#define FONT_SLANTED 1
|
||||
|
||||
/* Font families */
|
||||
#define FONT_SANS_SERIF 0
|
||||
#define FONT_SERIF 4
|
||||
#define FONT_MONOSPACE 8
|
||||
#define FONT_CURSIVE 12
|
||||
#define FONT_FANTASY 16
|
||||
#define FONT_SANS_SERIF (0 * FONT_FACES)
|
||||
#define FONT_SERIF (1 * FONT_FACES)
|
||||
#define FONT_MONOSPACE (2 * FONT_FACES)
|
||||
#define FONT_CURSIVE (3 * FONT_FACES)
|
||||
#define FONT_FANTASY (4 * FONT_FACES)
|
||||
|
||||
/* a font_set is just a linked list of font_data for each face for now */
|
||||
struct font_set {
|
||||
struct font_data *font[FONT_FAMILIES * 4];
|
||||
struct font_data *font[FONT_FAMILIES * FONT_FACES];
|
||||
};
|
||||
|
||||
/** Table of font names.
|
||||
*
|
||||
* font id = font family * 4 + bold * 2 + slanted
|
||||
* font id = font family * 8 + smallcaps * 4 + bold * 2 + slanted
|
||||
*
|
||||
* font family: 0 = sans-serif, 1 = serif, 2 = monospace, 3 = cursive
|
||||
* 4 = fantasy
|
||||
*/
|
||||
|
||||
const char * const font_table[FONT_FAMILIES * 4] = {
|
||||
const char * const font_table[FONT_FAMILIES * FONT_FACES] = {
|
||||
/* sans-serif */
|
||||
/*0*/ "Homerton.Medium\\ELatin1",
|
||||
/*1*/ "Homerton.Medium.Oblique\\ELatin1",
|
||||
/*2*/ "Homerton.Bold\\ELatin1",
|
||||
/*3*/ "Homerton.Bold.Oblique\\ELatin1",
|
||||
"Homerton.Medium.SmallCaps\\ELatin1",
|
||||
"Homerton.Medium.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
"Homerton.Bold.SmallCaps\\ELatin1",
|
||||
"Homerton.Bold.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/* serif */
|
||||
/*4*/ "Trinity.Medium\\ELatin1",
|
||||
/*5*/ "Trinity.Medium.Italic\\ELatin1",
|
||||
/*6*/ "Trinity.Bold\\ELatin1",
|
||||
/*7*/ "Trinity.Bold.Italic\\ELatin1",
|
||||
/*8*/ "Trinity.Medium\\ELatin1",
|
||||
/*9*/ "Trinity.Medium.Italic\\ELatin1",
|
||||
/*10*/ "Trinity.Bold\\ELatin1",
|
||||
/*11*/ "Trinity.Bold.Italic\\ELatin1",
|
||||
"Trinity.Medium.SmallCaps\\ELatin1",
|
||||
"Trinity.Medium.Italic.SmallCaps\\ELatin1",
|
||||
"Trinity.Bold.SmallCaps\\ELatin1",
|
||||
"Trinity.Bold.Italic.SmallCaps\\ELatin1",
|
||||
/* monospace */
|
||||
/*8*/ "Corpus.Medium\\ELatin1",
|
||||
/*9*/ "Corpus.Medium.Oblique\\ELatin1",
|
||||
/*10*/ "Corpus.Bold\\ELatin1",
|
||||
/*11*/ "Corpus.Bold.Oblique\\ELatin1",
|
||||
/*16*/ "Corpus.Medium\\ELatin1",
|
||||
/*17*/ "Corpus.Medium.Oblique\\ELatin1",
|
||||
/*18*/ "Corpus.Bold\\ELatin1",
|
||||
/*19*/ "Corpus.Bold.Oblique\\ELatin1",
|
||||
"Corpus.Medium.SmallCaps\\ELatin1",
|
||||
"Corpus.Medium.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
"Corpus.Bold.SmallCaps\\ELatin1",
|
||||
"Corpus.Bold.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/* cursive */
|
||||
/*12*/ "Churchill.Medium\\ELatin1",
|
||||
/*13*/ "Churchill.Medium\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/*14*/ "Churchill.Bold\\ELatin1",
|
||||
/*15*/ "Churchill.Bold\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/*24*/ "Churchill.Medium\\ELatin1",
|
||||
/*25*/ "Churchill.Medium\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/*26*/ "Churchill.Bold\\ELatin1",
|
||||
/*27*/ "Churchill.Bold\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
"Churchill.Medium.SmallCaps\\ELatin1",
|
||||
"Churchill.Medium.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
"Churchill.Bold.SmallCaps\\ELatin1",
|
||||
"Churchill.Bold.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/* fantasy */
|
||||
/*16*/ "Sassoon.Primary\\ELatin1",
|
||||
/*17*/ "Sassoon.Primary\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/*18*/ "Sassoon.Primary.Bold\\ELatin1",
|
||||
/*19*/ "Sassoon.Primary.Bold\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/*32*/ "Sassoon.Primary\\ELatin1",
|
||||
/*33*/ "Sassoon.Primary\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
/*34*/ "Sassoon.Primary.Bold\\ELatin1",
|
||||
/*35*/ "Sassoon.Primary.Bold\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
"Sassoon.Primary.SmallCaps\\ELatin1",
|
||||
"Sassoon.Primary.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
"Sassoon.Primary.Bold.SmallCaps\\ELatin1",
|
||||
"Sassoon.Primary.Bold.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
|
||||
};
|
||||
|
||||
|
||||
@ -88,7 +112,7 @@ struct font_set *font_new_set()
|
||||
struct font_set *set = xcalloc(1, sizeof(*set));
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < FONT_FAMILIES * 4; i++)
|
||||
for (i = 0; i < FONT_FAMILIES * FONT_FACES; i++)
|
||||
set->font[i] = 0;
|
||||
|
||||
return set;
|
||||
@ -139,6 +163,14 @@ struct font_data *font_open(struct font_set *set, struct css_style *style)
|
||||
break;
|
||||
}
|
||||
|
||||
switch (style->font_variant) {
|
||||
case CSS_FONT_VARIANT_SMALL_CAPS:
|
||||
f += FONT_SMALLCAPS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (style->font_weight) {
|
||||
case CSS_FONT_WEIGHT_BOLD:
|
||||
case CSS_FONT_WEIGHT_600:
|
||||
@ -171,7 +203,8 @@ struct font_data *font_open(struct font_set *set, struct css_style *style)
|
||||
|
||||
if (error) { /* fall back to Homerton */
|
||||
LOG(("font_find_font failed; falling back to Homerton"));
|
||||
error = xfont_find_font(font_table[f % 4], (int)size, (int)size,
|
||||
error = xfont_find_font(font_table[f % 4],
|
||||
(int)size, (int)size,
|
||||
0, 0, &handle, 0, 0);
|
||||
if (error) {
|
||||
LOG(("%i: %s\n", error->errnum, error->errmess));
|
||||
@ -203,7 +236,7 @@ void font_free_set(struct font_set *set)
|
||||
|
||||
assert(set != 0);
|
||||
|
||||
for (i = 0; i < FONT_FAMILIES * 4; i++) {
|
||||
for (i = 0; i < FONT_FAMILIES * FONT_FACES; i++) {
|
||||
for (data = set->font[i]; data != 0; data = next) {
|
||||
next = data->next;
|
||||
font_lose_font((font_f)(data->handle));
|
||||
|
Loading…
Reference in New Issue
Block a user